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 AdvertisedPeripheralControlHandle {
693    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
694        self.inner.shutdown_with_epitaph(status.into())
695    }
696}
697
698impl fidl::endpoints::ControlHandle for AdvertisedPeripheralControlHandle {
699    fn shutdown(&self) {
700        self.inner.shutdown()
701    }
702
703    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
704        self.inner.shutdown_with_epitaph(status)
705    }
706
707    fn is_closed(&self) -> bool {
708        self.inner.channel().is_closed()
709    }
710    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
711        self.inner.channel().on_closed()
712    }
713
714    #[cfg(target_os = "fuchsia")]
715    fn signal_peer(
716        &self,
717        clear_mask: zx::Signals,
718        set_mask: zx::Signals,
719    ) -> Result<(), zx_status::Status> {
720        use fidl::Peered;
721        self.inner.channel().signal_peer(clear_mask, set_mask)
722    }
723}
724
725impl AdvertisedPeripheralControlHandle {}
726
727#[must_use = "FIDL methods require a response to be sent"]
728#[derive(Debug)]
729pub struct AdvertisedPeripheralOnConnectedResponder {
730    control_handle: std::mem::ManuallyDrop<AdvertisedPeripheralControlHandle>,
731    tx_id: u32,
732}
733
734/// Set the the channel to be shutdown (see [`AdvertisedPeripheralControlHandle::shutdown`])
735/// if the responder is dropped without sending a response, so that the client
736/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
737impl std::ops::Drop for AdvertisedPeripheralOnConnectedResponder {
738    fn drop(&mut self) {
739        self.control_handle.shutdown();
740        // Safety: drops once, never accessed again
741        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
742    }
743}
744
745impl fidl::endpoints::Responder for AdvertisedPeripheralOnConnectedResponder {
746    type ControlHandle = AdvertisedPeripheralControlHandle;
747
748    fn control_handle(&self) -> &AdvertisedPeripheralControlHandle {
749        &self.control_handle
750    }
751
752    fn drop_without_shutdown(mut self) {
753        // Safety: drops once, never accessed again due to mem::forget
754        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
755        // Prevent Drop from running (which would shut down the channel)
756        std::mem::forget(self);
757    }
758}
759
760impl AdvertisedPeripheralOnConnectedResponder {
761    /// Sends a response to the FIDL transaction.
762    ///
763    /// Sets the channel to shutdown if an error occurs.
764    pub fn send(self) -> Result<(), fidl::Error> {
765        let _result = self.send_raw();
766        if _result.is_err() {
767            self.control_handle.shutdown();
768        }
769        self.drop_without_shutdown();
770        _result
771    }
772
773    /// Similar to "send" but does not shutdown the channel if an error occurs.
774    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
775        let _result = self.send_raw();
776        self.drop_without_shutdown();
777        _result
778    }
779
780    fn send_raw(&self) -> Result<(), fidl::Error> {
781        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
782            (),
783            self.tx_id,
784            0x607b7716457eb178,
785            fidl::encoding::DynamicFlags::empty(),
786        )
787    }
788}
789
790#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
791pub struct AdvertisingHandleMarker;
792
793impl fidl::endpoints::ProtocolMarker for AdvertisingHandleMarker {
794    type Proxy = AdvertisingHandleProxy;
795    type RequestStream = AdvertisingHandleRequestStream;
796    #[cfg(target_os = "fuchsia")]
797    type SynchronousProxy = AdvertisingHandleSynchronousProxy;
798
799    const DEBUG_NAME: &'static str = "(anonymous) AdvertisingHandle";
800}
801
802pub trait AdvertisingHandleProxyInterface: Send + Sync {}
803#[derive(Debug)]
804#[cfg(target_os = "fuchsia")]
805pub struct AdvertisingHandleSynchronousProxy {
806    client: fidl::client::sync::Client,
807}
808
809#[cfg(target_os = "fuchsia")]
810impl fidl::endpoints::SynchronousProxy for AdvertisingHandleSynchronousProxy {
811    type Proxy = AdvertisingHandleProxy;
812    type Protocol = AdvertisingHandleMarker;
813
814    fn from_channel(inner: fidl::Channel) -> Self {
815        Self::new(inner)
816    }
817
818    fn into_channel(self) -> fidl::Channel {
819        self.client.into_channel()
820    }
821
822    fn as_channel(&self) -> &fidl::Channel {
823        self.client.as_channel()
824    }
825}
826
827#[cfg(target_os = "fuchsia")]
828impl AdvertisingHandleSynchronousProxy {
829    pub fn new(channel: fidl::Channel) -> Self {
830        Self { client: fidl::client::sync::Client::new(channel) }
831    }
832
833    pub fn into_channel(self) -> fidl::Channel {
834        self.client.into_channel()
835    }
836
837    /// Waits until an event arrives and returns it. It is safe for other
838    /// threads to make concurrent requests while waiting for an event.
839    pub fn wait_for_event(
840        &self,
841        deadline: zx::MonotonicInstant,
842    ) -> Result<AdvertisingHandleEvent, fidl::Error> {
843        AdvertisingHandleEvent::decode(
844            self.client.wait_for_event::<AdvertisingHandleMarker>(deadline)?,
845        )
846    }
847}
848
849#[cfg(target_os = "fuchsia")]
850impl From<AdvertisingHandleSynchronousProxy> for zx::NullableHandle {
851    fn from(value: AdvertisingHandleSynchronousProxy) -> Self {
852        value.into_channel().into()
853    }
854}
855
856#[cfg(target_os = "fuchsia")]
857impl From<fidl::Channel> for AdvertisingHandleSynchronousProxy {
858    fn from(value: fidl::Channel) -> Self {
859        Self::new(value)
860    }
861}
862
863#[cfg(target_os = "fuchsia")]
864impl fidl::endpoints::FromClient for AdvertisingHandleSynchronousProxy {
865    type Protocol = AdvertisingHandleMarker;
866
867    fn from_client(value: fidl::endpoints::ClientEnd<AdvertisingHandleMarker>) -> Self {
868        Self::new(value.into_channel())
869    }
870}
871
872#[derive(Debug, Clone)]
873pub struct AdvertisingHandleProxy {
874    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
875}
876
877impl fidl::endpoints::Proxy for AdvertisingHandleProxy {
878    type Protocol = AdvertisingHandleMarker;
879
880    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
881        Self::new(inner)
882    }
883
884    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
885        self.client.into_channel().map_err(|client| Self { client })
886    }
887
888    fn as_channel(&self) -> &::fidl::AsyncChannel {
889        self.client.as_channel()
890    }
891}
892
893impl AdvertisingHandleProxy {
894    /// Create a new Proxy for fuchsia.bluetooth.le/AdvertisingHandle.
895    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
896        let protocol_name =
897            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
898        Self { client: fidl::client::Client::new(channel, protocol_name) }
899    }
900
901    /// Get a Stream of events from the remote end of the protocol.
902    ///
903    /// # Panics
904    ///
905    /// Panics if the event stream was already taken.
906    pub fn take_event_stream(&self) -> AdvertisingHandleEventStream {
907        AdvertisingHandleEventStream { event_receiver: self.client.take_event_receiver() }
908    }
909}
910
911impl AdvertisingHandleProxyInterface for AdvertisingHandleProxy {}
912
913pub struct AdvertisingHandleEventStream {
914    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
915}
916
917impl std::marker::Unpin for AdvertisingHandleEventStream {}
918
919impl futures::stream::FusedStream for AdvertisingHandleEventStream {
920    fn is_terminated(&self) -> bool {
921        self.event_receiver.is_terminated()
922    }
923}
924
925impl futures::Stream for AdvertisingHandleEventStream {
926    type Item = Result<AdvertisingHandleEvent, fidl::Error>;
927
928    fn poll_next(
929        mut self: std::pin::Pin<&mut Self>,
930        cx: &mut std::task::Context<'_>,
931    ) -> std::task::Poll<Option<Self::Item>> {
932        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
933            &mut self.event_receiver,
934            cx
935        )?) {
936            Some(buf) => std::task::Poll::Ready(Some(AdvertisingHandleEvent::decode(buf))),
937            None => std::task::Poll::Ready(None),
938        }
939    }
940}
941
942#[derive(Debug)]
943pub enum AdvertisingHandleEvent {}
944
945impl AdvertisingHandleEvent {
946    /// Decodes a message buffer as a [`AdvertisingHandleEvent`].
947    fn decode(
948        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
949    ) -> Result<AdvertisingHandleEvent, fidl::Error> {
950        let (bytes, _handles) = buf.split_mut();
951        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
952        debug_assert_eq!(tx_header.tx_id, 0);
953        match tx_header.ordinal {
954            _ => Err(fidl::Error::UnknownOrdinal {
955                ordinal: tx_header.ordinal,
956                protocol_name:
957                    <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
958            }),
959        }
960    }
961}
962
963/// A Stream of incoming requests for fuchsia.bluetooth.le/AdvertisingHandle.
964pub struct AdvertisingHandleRequestStream {
965    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
966    is_terminated: bool,
967}
968
969impl std::marker::Unpin for AdvertisingHandleRequestStream {}
970
971impl futures::stream::FusedStream for AdvertisingHandleRequestStream {
972    fn is_terminated(&self) -> bool {
973        self.is_terminated
974    }
975}
976
977impl fidl::endpoints::RequestStream for AdvertisingHandleRequestStream {
978    type Protocol = AdvertisingHandleMarker;
979    type ControlHandle = AdvertisingHandleControlHandle;
980
981    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
982        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
983    }
984
985    fn control_handle(&self) -> Self::ControlHandle {
986        AdvertisingHandleControlHandle { inner: self.inner.clone() }
987    }
988
989    fn into_inner(
990        self,
991    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
992    {
993        (self.inner, self.is_terminated)
994    }
995
996    fn from_inner(
997        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
998        is_terminated: bool,
999    ) -> Self {
1000        Self { inner, is_terminated }
1001    }
1002}
1003
1004impl futures::Stream for AdvertisingHandleRequestStream {
1005    type Item = Result<AdvertisingHandleRequest, fidl::Error>;
1006
1007    fn poll_next(
1008        mut self: std::pin::Pin<&mut Self>,
1009        cx: &mut std::task::Context<'_>,
1010    ) -> std::task::Poll<Option<Self::Item>> {
1011        let this = &mut *self;
1012        if this.inner.check_shutdown(cx) {
1013            this.is_terminated = true;
1014            return std::task::Poll::Ready(None);
1015        }
1016        if this.is_terminated {
1017            panic!("polled AdvertisingHandleRequestStream after completion");
1018        }
1019        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1020            |bytes, handles| {
1021                match this.inner.channel().read_etc(cx, bytes, handles) {
1022                    std::task::Poll::Ready(Ok(())) => {}
1023                    std::task::Poll::Pending => return std::task::Poll::Pending,
1024                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1025                        this.is_terminated = true;
1026                        return std::task::Poll::Ready(None);
1027                    }
1028                    std::task::Poll::Ready(Err(e)) => {
1029                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1030                            e.into(),
1031                        ))));
1032                    }
1033                }
1034
1035                // A message has been received from the channel
1036                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1037
1038                std::task::Poll::Ready(Some(match header.ordinal {
1039                    _ => Err(fidl::Error::UnknownOrdinal {
1040                        ordinal: header.ordinal,
1041                        protocol_name:
1042                            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1043                    }),
1044                }))
1045            },
1046        )
1047    }
1048}
1049
1050/// Capability that is valid for the duration of advertising. The caller can close the handle to
1051/// stop advertising. If the system internally stops advertising for any reason, the handle will be
1052/// closed to communicate this to the client.
1053#[derive(Debug)]
1054pub enum AdvertisingHandleRequest {}
1055
1056impl AdvertisingHandleRequest {
1057    /// Name of the method defined in FIDL
1058    pub fn method_name(&self) -> &'static str {
1059        match *self {}
1060    }
1061}
1062
1063#[derive(Debug, Clone)]
1064pub struct AdvertisingHandleControlHandle {
1065    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1066}
1067
1068impl AdvertisingHandleControlHandle {
1069    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1070        self.inner.shutdown_with_epitaph(status.into())
1071    }
1072}
1073
1074impl fidl::endpoints::ControlHandle for AdvertisingHandleControlHandle {
1075    fn shutdown(&self) {
1076        self.inner.shutdown()
1077    }
1078
1079    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1080        self.inner.shutdown_with_epitaph(status)
1081    }
1082
1083    fn is_closed(&self) -> bool {
1084        self.inner.channel().is_closed()
1085    }
1086    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1087        self.inner.channel().on_closed()
1088    }
1089
1090    #[cfg(target_os = "fuchsia")]
1091    fn signal_peer(
1092        &self,
1093        clear_mask: zx::Signals,
1094        set_mask: zx::Signals,
1095    ) -> Result<(), zx_status::Status> {
1096        use fidl::Peered;
1097        self.inner.channel().signal_peer(clear_mask, set_mask)
1098    }
1099}
1100
1101impl AdvertisingHandleControlHandle {}
1102
1103#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1104pub struct CentralMarker;
1105
1106impl fidl::endpoints::ProtocolMarker for CentralMarker {
1107    type Proxy = CentralProxy;
1108    type RequestStream = CentralRequestStream;
1109    #[cfg(target_os = "fuchsia")]
1110    type SynchronousProxy = CentralSynchronousProxy;
1111
1112    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.Central";
1113}
1114impl fidl::endpoints::DiscoverableProtocolMarker for CentralMarker {}
1115pub type CentralCreateConnectedIsochronousGroupResult =
1116    Result<CentralCreateConnectedIsochronousGroupResponse, CreateCigError>;
1117
1118pub trait CentralProxyInterface: Send + Sync {
1119    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
1120        + Send;
1121    fn r#listen_l2cap(
1122        &self,
1123        payload: ChannelListenerRegistryListenL2capRequest,
1124    ) -> Self::ListenL2capResponseFut;
1125    type ScanResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1126    fn r#scan(
1127        &self,
1128        options: &ScanOptions,
1129        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1130    ) -> Self::ScanResponseFut;
1131    fn r#connect(
1132        &self,
1133        id: &fidl_fuchsia_bluetooth::PeerId,
1134        options: &ConnectionOptions,
1135        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1136    ) -> Result<(), fidl::Error>;
1137    fn r#sync_to_periodic_advertising(
1138        &self,
1139        payload: CentralSyncToPeriodicAdvertisingRequest,
1140    ) -> Result<(), fidl::Error>;
1141    type CreateConnectedIsochronousGroupResponseFut: std::future::Future<
1142            Output = Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error>,
1143        > + Send;
1144    fn r#create_connected_isochronous_group(
1145        &self,
1146        payload: CentralCreateConnectedIsochronousGroupRequest,
1147    ) -> Self::CreateConnectedIsochronousGroupResponseFut;
1148    type GetPeripheralsResponseFut: std::future::Future<Output = Result<Vec<RemoteDevice>, fidl::Error>>
1149        + Send;
1150    fn r#get_peripherals(
1151        &self,
1152        service_uuids: Option<&[String]>,
1153    ) -> Self::GetPeripheralsResponseFut;
1154    type GetPeripheralResponseFut: std::future::Future<Output = Result<Option<Box<RemoteDevice>>, fidl::Error>>
1155        + Send;
1156    fn r#get_peripheral(&self, identifier: &str) -> Self::GetPeripheralResponseFut;
1157    type StartScanResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1158        + Send;
1159    fn r#start_scan(&self, filter: Option<&ScanFilter>) -> Self::StartScanResponseFut;
1160    fn r#stop_scan(&self) -> Result<(), fidl::Error>;
1161    type ConnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1162        + Send;
1163    fn r#connect_peripheral(
1164        &self,
1165        identifier: &str,
1166        options: &ConnectionOptions,
1167        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1168    ) -> Self::ConnectPeripheralResponseFut;
1169    type DisconnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1170        + Send;
1171    fn r#disconnect_peripheral(&self, identifier: &str) -> Self::DisconnectPeripheralResponseFut;
1172}
1173#[derive(Debug)]
1174#[cfg(target_os = "fuchsia")]
1175pub struct CentralSynchronousProxy {
1176    client: fidl::client::sync::Client,
1177}
1178
1179#[cfg(target_os = "fuchsia")]
1180impl fidl::endpoints::SynchronousProxy for CentralSynchronousProxy {
1181    type Proxy = CentralProxy;
1182    type Protocol = CentralMarker;
1183
1184    fn from_channel(inner: fidl::Channel) -> Self {
1185        Self::new(inner)
1186    }
1187
1188    fn into_channel(self) -> fidl::Channel {
1189        self.client.into_channel()
1190    }
1191
1192    fn as_channel(&self) -> &fidl::Channel {
1193        self.client.as_channel()
1194    }
1195}
1196
1197#[cfg(target_os = "fuchsia")]
1198impl CentralSynchronousProxy {
1199    pub fn new(channel: fidl::Channel) -> Self {
1200        Self { client: fidl::client::sync::Client::new(channel) }
1201    }
1202
1203    pub fn into_channel(self) -> fidl::Channel {
1204        self.client.into_channel()
1205    }
1206
1207    /// Waits until an event arrives and returns it. It is safe for other
1208    /// threads to make concurrent requests while waiting for an event.
1209    pub fn wait_for_event(
1210        &self,
1211        deadline: zx::MonotonicInstant,
1212    ) -> Result<CentralEvent, fidl::Error> {
1213        CentralEvent::decode(self.client.wait_for_event::<CentralMarker>(deadline)?)
1214    }
1215
1216    /// Register a listener for incoming channels. The registry will assign a
1217    /// PSM value that is unique for the local device, as well as open a
1218    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
1219    /// event that all PSMs have been assigned, this call will fail with
1220    /// `ZX_ERR_NO_RESOURCES`.
1221    ///
1222    /// Note that the method of service discovery or advertising is defined by
1223    /// the service or protocol, so it is the responsibility of the caller to
1224    /// communicate the assigned PSM to any clients.
1225    pub fn r#listen_l2cap(
1226        &self,
1227        mut payload: ChannelListenerRegistryListenL2capRequest,
1228        ___deadline: zx::MonotonicInstant,
1229    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
1230        let _response = self.client.send_query::<
1231            ChannelListenerRegistryListenL2capRequest,
1232            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
1233            CentralMarker,
1234        >(
1235            &mut payload,
1236            0x39c6e9001d102338,
1237            fidl::encoding::DynamicFlags::empty(),
1238            ___deadline,
1239        )?;
1240        Ok(_response.map(|x| x))
1241    }
1242
1243    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
1244    /// initiated, then `result_watcher` will be closed with an epitaph.
1245    ///
1246    /// A Central client is allowed to have only one active scan at a time.
1247    /// Accordingly, only one Scan request can be outstanding at a time.
1248    /// Additional calls to Scan will fail.
1249    ///
1250    /// The lifetime of the scan session is tied to the `result_watcher`
1251    /// protocol provided. The scan will be stopped if the channel is closed.
1252    ///
1253    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
1254    /// can be used to watch for scan results.
1255    ///
1256    /// + request `options` Options used to configure the scan session.
1257    /// + request `result_watcher` Protocol that remains valid for the duration
1258    ///   of this scan session.
1259    /// - response An empty response will be sent to acknowledge the scan has
1260    ///   stopped.
1261    ///
1262    /// The following epitaphs may be sent by the server on error:
1263    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
1264    ///   protocol is only allowed 1 active scan.
1265    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
1266    ///   `ScanOptions` documentation.
1267    /// * error `INTERNAL`: An internal error occurred and a scan could not be
1268    ///   started.
1269    pub fn r#scan(
1270        &self,
1271        mut options: &ScanOptions,
1272        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1273        ___deadline: zx::MonotonicInstant,
1274    ) -> Result<(), fidl::Error> {
1275        let _response = self
1276            .client
1277            .send_query::<CentralScanRequest, fidl::encoding::EmptyPayload, CentralMarker>(
1278                (options, result_watcher),
1279                0x41f7121798dfe15f,
1280                fidl::encoding::DynamicFlags::empty(),
1281                ___deadline,
1282            )?;
1283        Ok(_response)
1284    }
1285
1286    /// Connect to the peer with the given identifier.
1287    ///
1288    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
1289    /// client's interest on the LE connection to the peer. Closing the channel
1290    /// removes interest, but may not result in disconnection if another client
1291    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
1292    ///
1293    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
1294    /// system if the connection to the peer is lost or an error occurs.
1295    ///
1296    /// The following epitaphs may be sent by the server on error:
1297    /// + `INVALID_ARGS`: Some of the parameters are invalid.
1298    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
1299    ///                    Connection should be used.
1300    /// + `NOT_CONNECTED`: A connection could not be established.
1301    /// + `CONNECTION_RESET`: The peer disconnected.
1302    ///
1303    /// + request `id` Identifier of the peer to initiate a connection to.
1304    /// + request `options` Options used to configure the connection.
1305    /// + request `handle` Handle that remains valid for the duration of this
1306    ///   connection.
1307    pub fn r#connect(
1308        &self,
1309        mut id: &fidl_fuchsia_bluetooth::PeerId,
1310        mut options: &ConnectionOptions,
1311        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1312    ) -> Result<(), fidl::Error> {
1313        self.client.send::<CentralConnectRequest>(
1314            (id, options, handle),
1315            0x31a3065f2a6913c4,
1316            fidl::encoding::DynamicFlags::empty(),
1317        )
1318    }
1319
1320    /// Synchronize to a periodic advertising train. Reports will be delivered via the
1321    /// `PeriodicAdvertisingSync` protocol.
1322    pub fn r#sync_to_periodic_advertising(
1323        &self,
1324        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1325    ) -> Result<(), fidl::Error> {
1326        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
1327            &mut payload,
1328            0x1db6df126a00c5b9,
1329            fidl::encoding::DynamicFlags::empty(),
1330        )
1331    }
1332
1333    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
1334    /// operation is only valid when operating in the Central role for a connection.
1335    ///
1336    /// If the Central channel is closed before the CIG is explicitly removed, the group will
1337    /// be removed and disconnected.
1338    ///
1339    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
1340    /// id allocated by the host.
1341    pub fn r#create_connected_isochronous_group(
1342        &self,
1343        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1344        ___deadline: zx::MonotonicInstant,
1345    ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
1346        let _response = self
1347            .client
1348            .send_query::<CentralCreateConnectedIsochronousGroupRequest, fidl::encoding::ResultType<
1349                CentralCreateConnectedIsochronousGroupResponse,
1350                CreateCigError,
1351            >, CentralMarker>(
1352                &mut payload,
1353                0x60323e70ae22e13,
1354                fidl::encoding::DynamicFlags::empty(),
1355                ___deadline,
1356            )?;
1357        Ok(_response.map(|x| x))
1358    }
1359
1360    /// Returns the list of peripherals that are known to the system from previous scan, connection,
1361    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
1362    /// be present on the peripheral.
1363    ///
1364    /// This method only returns peripherals (i.e. connectable devices).
1365    pub fn r#get_peripherals(
1366        &self,
1367        mut service_uuids: Option<&[String]>,
1368        ___deadline: zx::MonotonicInstant,
1369    ) -> Result<Vec<RemoteDevice>, fidl::Error> {
1370        let _response = self.client.send_query::<
1371            CentralGetPeripheralsRequest,
1372            CentralGetPeripheralsResponse,
1373            CentralMarker,
1374        >(
1375            (service_uuids,),
1376            0x37ba777499c683a8,
1377            fidl::encoding::DynamicFlags::empty(),
1378            ___deadline,
1379        )?;
1380        Ok(_response.peripherals)
1381    }
1382
1383    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
1384    ///
1385    /// Returns information about a single peripheral that is known to the system from previous scan,
1386    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
1387    /// `identifier` is not recognized.
1388    pub fn r#get_peripheral(
1389        &self,
1390        mut identifier: &str,
1391        ___deadline: zx::MonotonicInstant,
1392    ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
1393        let _response = self
1394            .client
1395            .send_query::<CentralGetPeripheralRequest, CentralGetPeripheralResponse, CentralMarker>(
1396                (identifier,),
1397                0x97f5a2f2d9c13da,
1398                fidl::encoding::DynamicFlags::empty(),
1399                ___deadline,
1400            )?;
1401        Ok(_response.peripheral)
1402    }
1403
1404    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
1405    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
1406    /// `filter` will replace the existing session's filter.
1407    ///
1408    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
1409    /// will be notified for all discoverable devices that are found. This is not recommended; clients
1410    /// should generally filter results by at least one of `filter.service_uuids`,
1411    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
1412    pub fn r#start_scan(
1413        &self,
1414        mut filter: Option<&ScanFilter>,
1415        ___deadline: zx::MonotonicInstant,
1416    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1417        let _response = self
1418            .client
1419            .send_query::<CentralStartScanRequest, CentralStartScanResponse, CentralMarker>(
1420                (filter,),
1421                0xeb4cf0cd0e1132b,
1422                fidl::encoding::DynamicFlags::empty(),
1423                ___deadline,
1424            )?;
1425        Ok(_response.status)
1426    }
1427
1428    /// Terminate a previously started scan session.
1429    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1430        self.client.send::<fidl::encoding::EmptyPayload>(
1431            (),
1432            0x5f79ee6a0bb037a0,
1433            fidl::encoding::DynamicFlags::empty(),
1434        )
1435    }
1436
1437    /// Creates a connection to the peripheral device with the given identifier.
1438    /// Returns the status of the operation in `status`.
1439    ///
1440    /// On success, `gatt_client` will be bound and can be used for GATT client
1441    /// role procedures. On failure, `gatt_client` will be closed and `status` will
1442    /// indicate an error.
1443    pub fn r#connect_peripheral(
1444        &self,
1445        mut identifier: &str,
1446        mut options: &ConnectionOptions,
1447        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1448        ___deadline: zx::MonotonicInstant,
1449    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1450        let _response = self.client.send_query::<
1451            CentralConnectPeripheralRequest,
1452            CentralConnectPeripheralResponse,
1453            CentralMarker,
1454        >(
1455            (identifier, options, gatt_client,),
1456            0x714d6c32d066d75a,
1457            fidl::encoding::DynamicFlags::empty(),
1458            ___deadline,
1459        )?;
1460        Ok(_response.status)
1461    }
1462
1463    /// Disconnects this Central's connection to the peripheral with the given identifier.
1464    pub fn r#disconnect_peripheral(
1465        &self,
1466        mut identifier: &str,
1467        ___deadline: zx::MonotonicInstant,
1468    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1469        let _response = self.client.send_query::<
1470            CentralDisconnectPeripheralRequest,
1471            CentralDisconnectPeripheralResponse,
1472            CentralMarker,
1473        >(
1474            (identifier,),
1475            0xa9430da197362fd,
1476            fidl::encoding::DynamicFlags::empty(),
1477            ___deadline,
1478        )?;
1479        Ok(_response.status)
1480    }
1481}
1482
1483#[cfg(target_os = "fuchsia")]
1484impl From<CentralSynchronousProxy> for zx::NullableHandle {
1485    fn from(value: CentralSynchronousProxy) -> Self {
1486        value.into_channel().into()
1487    }
1488}
1489
1490#[cfg(target_os = "fuchsia")]
1491impl From<fidl::Channel> for CentralSynchronousProxy {
1492    fn from(value: fidl::Channel) -> Self {
1493        Self::new(value)
1494    }
1495}
1496
1497#[cfg(target_os = "fuchsia")]
1498impl fidl::endpoints::FromClient for CentralSynchronousProxy {
1499    type Protocol = CentralMarker;
1500
1501    fn from_client(value: fidl::endpoints::ClientEnd<CentralMarker>) -> Self {
1502        Self::new(value.into_channel())
1503    }
1504}
1505
1506#[derive(Debug, Clone)]
1507pub struct CentralProxy {
1508    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1509}
1510
1511impl fidl::endpoints::Proxy for CentralProxy {
1512    type Protocol = CentralMarker;
1513
1514    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1515        Self::new(inner)
1516    }
1517
1518    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1519        self.client.into_channel().map_err(|client| Self { client })
1520    }
1521
1522    fn as_channel(&self) -> &::fidl::AsyncChannel {
1523        self.client.as_channel()
1524    }
1525}
1526
1527impl CentralProxy {
1528    /// Create a new Proxy for fuchsia.bluetooth.le/Central.
1529    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1530        let protocol_name = <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1531        Self { client: fidl::client::Client::new(channel, protocol_name) }
1532    }
1533
1534    /// Get a Stream of events from the remote end of the protocol.
1535    ///
1536    /// # Panics
1537    ///
1538    /// Panics if the event stream was already taken.
1539    pub fn take_event_stream(&self) -> CentralEventStream {
1540        CentralEventStream { event_receiver: self.client.take_event_receiver() }
1541    }
1542
1543    /// Register a listener for incoming channels. The registry will assign a
1544    /// PSM value that is unique for the local device, as well as open a
1545    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
1546    /// event that all PSMs have been assigned, this call will fail with
1547    /// `ZX_ERR_NO_RESOURCES`.
1548    ///
1549    /// Note that the method of service discovery or advertising is defined by
1550    /// the service or protocol, so it is the responsibility of the caller to
1551    /// communicate the assigned PSM to any clients.
1552    pub fn r#listen_l2cap(
1553        &self,
1554        mut payload: ChannelListenerRegistryListenL2capRequest,
1555    ) -> fidl::client::QueryResponseFut<
1556        ChannelListenerRegistryListenL2capResult,
1557        fidl::encoding::DefaultFuchsiaResourceDialect,
1558    > {
1559        CentralProxyInterface::r#listen_l2cap(self, payload)
1560    }
1561
1562    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
1563    /// initiated, then `result_watcher` will be closed with an epitaph.
1564    ///
1565    /// A Central client is allowed to have only one active scan at a time.
1566    /// Accordingly, only one Scan request can be outstanding at a time.
1567    /// Additional calls to Scan will fail.
1568    ///
1569    /// The lifetime of the scan session is tied to the `result_watcher`
1570    /// protocol provided. The scan will be stopped if the channel is closed.
1571    ///
1572    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
1573    /// can be used to watch for scan results.
1574    ///
1575    /// + request `options` Options used to configure the scan session.
1576    /// + request `result_watcher` Protocol that remains valid for the duration
1577    ///   of this scan session.
1578    /// - response An empty response will be sent to acknowledge the scan has
1579    ///   stopped.
1580    ///
1581    /// The following epitaphs may be sent by the server on error:
1582    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
1583    ///   protocol is only allowed 1 active scan.
1584    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
1585    ///   `ScanOptions` documentation.
1586    /// * error `INTERNAL`: An internal error occurred and a scan could not be
1587    ///   started.
1588    pub fn r#scan(
1589        &self,
1590        mut options: &ScanOptions,
1591        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1592    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1593        CentralProxyInterface::r#scan(self, options, result_watcher)
1594    }
1595
1596    /// Connect to the peer with the given identifier.
1597    ///
1598    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
1599    /// client's interest on the LE connection to the peer. Closing the channel
1600    /// removes interest, but may not result in disconnection if another client
1601    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
1602    ///
1603    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
1604    /// system if the connection to the peer is lost or an error occurs.
1605    ///
1606    /// The following epitaphs may be sent by the server on error:
1607    /// + `INVALID_ARGS`: Some of the parameters are invalid.
1608    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
1609    ///                    Connection should be used.
1610    /// + `NOT_CONNECTED`: A connection could not be established.
1611    /// + `CONNECTION_RESET`: The peer disconnected.
1612    ///
1613    /// + request `id` Identifier of the peer to initiate a connection to.
1614    /// + request `options` Options used to configure the connection.
1615    /// + request `handle` Handle that remains valid for the duration of this
1616    ///   connection.
1617    pub fn r#connect(
1618        &self,
1619        mut id: &fidl_fuchsia_bluetooth::PeerId,
1620        mut options: &ConnectionOptions,
1621        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1622    ) -> Result<(), fidl::Error> {
1623        CentralProxyInterface::r#connect(self, id, options, handle)
1624    }
1625
1626    /// Synchronize to a periodic advertising train. Reports will be delivered via the
1627    /// `PeriodicAdvertisingSync` protocol.
1628    pub fn r#sync_to_periodic_advertising(
1629        &self,
1630        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1631    ) -> Result<(), fidl::Error> {
1632        CentralProxyInterface::r#sync_to_periodic_advertising(self, payload)
1633    }
1634
1635    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
1636    /// operation is only valid when operating in the Central role for a connection.
1637    ///
1638    /// If the Central channel is closed before the CIG is explicitly removed, the group will
1639    /// be removed and disconnected.
1640    ///
1641    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
1642    /// id allocated by the host.
1643    pub fn r#create_connected_isochronous_group(
1644        &self,
1645        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1646    ) -> fidl::client::QueryResponseFut<
1647        CentralCreateConnectedIsochronousGroupResult,
1648        fidl::encoding::DefaultFuchsiaResourceDialect,
1649    > {
1650        CentralProxyInterface::r#create_connected_isochronous_group(self, payload)
1651    }
1652
1653    /// Returns the list of peripherals that are known to the system from previous scan, connection,
1654    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
1655    /// be present on the peripheral.
1656    ///
1657    /// This method only returns peripherals (i.e. connectable devices).
1658    pub fn r#get_peripherals(
1659        &self,
1660        mut service_uuids: Option<&[String]>,
1661    ) -> fidl::client::QueryResponseFut<
1662        Vec<RemoteDevice>,
1663        fidl::encoding::DefaultFuchsiaResourceDialect,
1664    > {
1665        CentralProxyInterface::r#get_peripherals(self, service_uuids)
1666    }
1667
1668    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
1669    ///
1670    /// Returns information about a single peripheral that is known to the system from previous scan,
1671    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
1672    /// `identifier` is not recognized.
1673    pub fn r#get_peripheral(
1674        &self,
1675        mut identifier: &str,
1676    ) -> fidl::client::QueryResponseFut<
1677        Option<Box<RemoteDevice>>,
1678        fidl::encoding::DefaultFuchsiaResourceDialect,
1679    > {
1680        CentralProxyInterface::r#get_peripheral(self, identifier)
1681    }
1682
1683    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
1684    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
1685    /// `filter` will replace the existing session's filter.
1686    ///
1687    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
1688    /// will be notified for all discoverable devices that are found. This is not recommended; clients
1689    /// should generally filter results by at least one of `filter.service_uuids`,
1690    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
1691    pub fn r#start_scan(
1692        &self,
1693        mut filter: Option<&ScanFilter>,
1694    ) -> fidl::client::QueryResponseFut<
1695        fidl_fuchsia_bluetooth::Status,
1696        fidl::encoding::DefaultFuchsiaResourceDialect,
1697    > {
1698        CentralProxyInterface::r#start_scan(self, filter)
1699    }
1700
1701    /// Terminate a previously started scan session.
1702    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1703        CentralProxyInterface::r#stop_scan(self)
1704    }
1705
1706    /// Creates a connection to the peripheral device with the given identifier.
1707    /// Returns the status of the operation in `status`.
1708    ///
1709    /// On success, `gatt_client` will be bound and can be used for GATT client
1710    /// role procedures. On failure, `gatt_client` will be closed and `status` will
1711    /// indicate an error.
1712    pub fn r#connect_peripheral(
1713        &self,
1714        mut identifier: &str,
1715        mut options: &ConnectionOptions,
1716        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1717    ) -> fidl::client::QueryResponseFut<
1718        fidl_fuchsia_bluetooth::Status,
1719        fidl::encoding::DefaultFuchsiaResourceDialect,
1720    > {
1721        CentralProxyInterface::r#connect_peripheral(self, identifier, options, gatt_client)
1722    }
1723
1724    /// Disconnects this Central's connection to the peripheral with the given identifier.
1725    pub fn r#disconnect_peripheral(
1726        &self,
1727        mut identifier: &str,
1728    ) -> fidl::client::QueryResponseFut<
1729        fidl_fuchsia_bluetooth::Status,
1730        fidl::encoding::DefaultFuchsiaResourceDialect,
1731    > {
1732        CentralProxyInterface::r#disconnect_peripheral(self, identifier)
1733    }
1734}
1735
1736impl CentralProxyInterface for CentralProxy {
1737    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
1738        ChannelListenerRegistryListenL2capResult,
1739        fidl::encoding::DefaultFuchsiaResourceDialect,
1740    >;
1741    fn r#listen_l2cap(
1742        &self,
1743        mut payload: ChannelListenerRegistryListenL2capRequest,
1744    ) -> Self::ListenL2capResponseFut {
1745        fn _decode(
1746            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1747        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
1748            let _response = fidl::client::decode_transaction_body::<
1749                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
1750                fidl::encoding::DefaultFuchsiaResourceDialect,
1751                0x39c6e9001d102338,
1752            >(_buf?)?;
1753            Ok(_response.map(|x| x))
1754        }
1755        self.client.send_query_and_decode::<
1756            ChannelListenerRegistryListenL2capRequest,
1757            ChannelListenerRegistryListenL2capResult,
1758        >(
1759            &mut payload,
1760            0x39c6e9001d102338,
1761            fidl::encoding::DynamicFlags::empty(),
1762            _decode,
1763        )
1764    }
1765
1766    type ScanResponseFut =
1767        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1768    fn r#scan(
1769        &self,
1770        mut options: &ScanOptions,
1771        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1772    ) -> Self::ScanResponseFut {
1773        fn _decode(
1774            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1775        ) -> Result<(), fidl::Error> {
1776            let _response = fidl::client::decode_transaction_body::<
1777                fidl::encoding::EmptyPayload,
1778                fidl::encoding::DefaultFuchsiaResourceDialect,
1779                0x41f7121798dfe15f,
1780            >(_buf?)?;
1781            Ok(_response)
1782        }
1783        self.client.send_query_and_decode::<CentralScanRequest, ()>(
1784            (options, result_watcher),
1785            0x41f7121798dfe15f,
1786            fidl::encoding::DynamicFlags::empty(),
1787            _decode,
1788        )
1789    }
1790
1791    fn r#connect(
1792        &self,
1793        mut id: &fidl_fuchsia_bluetooth::PeerId,
1794        mut options: &ConnectionOptions,
1795        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1796    ) -> Result<(), fidl::Error> {
1797        self.client.send::<CentralConnectRequest>(
1798            (id, options, handle),
1799            0x31a3065f2a6913c4,
1800            fidl::encoding::DynamicFlags::empty(),
1801        )
1802    }
1803
1804    fn r#sync_to_periodic_advertising(
1805        &self,
1806        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1807    ) -> Result<(), fidl::Error> {
1808        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
1809            &mut payload,
1810            0x1db6df126a00c5b9,
1811            fidl::encoding::DynamicFlags::empty(),
1812        )
1813    }
1814
1815    type CreateConnectedIsochronousGroupResponseFut = fidl::client::QueryResponseFut<
1816        CentralCreateConnectedIsochronousGroupResult,
1817        fidl::encoding::DefaultFuchsiaResourceDialect,
1818    >;
1819    fn r#create_connected_isochronous_group(
1820        &self,
1821        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1822    ) -> Self::CreateConnectedIsochronousGroupResponseFut {
1823        fn _decode(
1824            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1825        ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
1826            let _response = fidl::client::decode_transaction_body::<
1827                fidl::encoding::ResultType<
1828                    CentralCreateConnectedIsochronousGroupResponse,
1829                    CreateCigError,
1830                >,
1831                fidl::encoding::DefaultFuchsiaResourceDialect,
1832                0x60323e70ae22e13,
1833            >(_buf?)?;
1834            Ok(_response.map(|x| x))
1835        }
1836        self.client.send_query_and_decode::<
1837            CentralCreateConnectedIsochronousGroupRequest,
1838            CentralCreateConnectedIsochronousGroupResult,
1839        >(
1840            &mut payload,
1841            0x60323e70ae22e13,
1842            fidl::encoding::DynamicFlags::empty(),
1843            _decode,
1844        )
1845    }
1846
1847    type GetPeripheralsResponseFut = fidl::client::QueryResponseFut<
1848        Vec<RemoteDevice>,
1849        fidl::encoding::DefaultFuchsiaResourceDialect,
1850    >;
1851    fn r#get_peripherals(
1852        &self,
1853        mut service_uuids: Option<&[String]>,
1854    ) -> Self::GetPeripheralsResponseFut {
1855        fn _decode(
1856            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1857        ) -> Result<Vec<RemoteDevice>, fidl::Error> {
1858            let _response = fidl::client::decode_transaction_body::<
1859                CentralGetPeripheralsResponse,
1860                fidl::encoding::DefaultFuchsiaResourceDialect,
1861                0x37ba777499c683a8,
1862            >(_buf?)?;
1863            Ok(_response.peripherals)
1864        }
1865        self.client.send_query_and_decode::<CentralGetPeripheralsRequest, Vec<RemoteDevice>>(
1866            (service_uuids,),
1867            0x37ba777499c683a8,
1868            fidl::encoding::DynamicFlags::empty(),
1869            _decode,
1870        )
1871    }
1872
1873    type GetPeripheralResponseFut = fidl::client::QueryResponseFut<
1874        Option<Box<RemoteDevice>>,
1875        fidl::encoding::DefaultFuchsiaResourceDialect,
1876    >;
1877    fn r#get_peripheral(&self, mut identifier: &str) -> Self::GetPeripheralResponseFut {
1878        fn _decode(
1879            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1880        ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
1881            let _response = fidl::client::decode_transaction_body::<
1882                CentralGetPeripheralResponse,
1883                fidl::encoding::DefaultFuchsiaResourceDialect,
1884                0x97f5a2f2d9c13da,
1885            >(_buf?)?;
1886            Ok(_response.peripheral)
1887        }
1888        self.client.send_query_and_decode::<CentralGetPeripheralRequest, Option<Box<RemoteDevice>>>(
1889            (identifier,),
1890            0x97f5a2f2d9c13da,
1891            fidl::encoding::DynamicFlags::empty(),
1892            _decode,
1893        )
1894    }
1895
1896    type StartScanResponseFut = fidl::client::QueryResponseFut<
1897        fidl_fuchsia_bluetooth::Status,
1898        fidl::encoding::DefaultFuchsiaResourceDialect,
1899    >;
1900    fn r#start_scan(&self, mut filter: Option<&ScanFilter>) -> Self::StartScanResponseFut {
1901        fn _decode(
1902            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1903        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1904            let _response = fidl::client::decode_transaction_body::<
1905                CentralStartScanResponse,
1906                fidl::encoding::DefaultFuchsiaResourceDialect,
1907                0xeb4cf0cd0e1132b,
1908            >(_buf?)?;
1909            Ok(_response.status)
1910        }
1911        self.client
1912            .send_query_and_decode::<CentralStartScanRequest, fidl_fuchsia_bluetooth::Status>(
1913                (filter,),
1914                0xeb4cf0cd0e1132b,
1915                fidl::encoding::DynamicFlags::empty(),
1916                _decode,
1917            )
1918    }
1919
1920    fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1921        self.client.send::<fidl::encoding::EmptyPayload>(
1922            (),
1923            0x5f79ee6a0bb037a0,
1924            fidl::encoding::DynamicFlags::empty(),
1925        )
1926    }
1927
1928    type ConnectPeripheralResponseFut = fidl::client::QueryResponseFut<
1929        fidl_fuchsia_bluetooth::Status,
1930        fidl::encoding::DefaultFuchsiaResourceDialect,
1931    >;
1932    fn r#connect_peripheral(
1933        &self,
1934        mut identifier: &str,
1935        mut options: &ConnectionOptions,
1936        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1937    ) -> Self::ConnectPeripheralResponseFut {
1938        fn _decode(
1939            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1940        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1941            let _response = fidl::client::decode_transaction_body::<
1942                CentralConnectPeripheralResponse,
1943                fidl::encoding::DefaultFuchsiaResourceDialect,
1944                0x714d6c32d066d75a,
1945            >(_buf?)?;
1946            Ok(_response.status)
1947        }
1948        self.client.send_query_and_decode::<
1949            CentralConnectPeripheralRequest,
1950            fidl_fuchsia_bluetooth::Status,
1951        >(
1952            (identifier, options, gatt_client,),
1953            0x714d6c32d066d75a,
1954            fidl::encoding::DynamicFlags::empty(),
1955            _decode,
1956        )
1957    }
1958
1959    type DisconnectPeripheralResponseFut = fidl::client::QueryResponseFut<
1960        fidl_fuchsia_bluetooth::Status,
1961        fidl::encoding::DefaultFuchsiaResourceDialect,
1962    >;
1963    fn r#disconnect_peripheral(
1964        &self,
1965        mut identifier: &str,
1966    ) -> Self::DisconnectPeripheralResponseFut {
1967        fn _decode(
1968            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1969        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1970            let _response = fidl::client::decode_transaction_body::<
1971                CentralDisconnectPeripheralResponse,
1972                fidl::encoding::DefaultFuchsiaResourceDialect,
1973                0xa9430da197362fd,
1974            >(_buf?)?;
1975            Ok(_response.status)
1976        }
1977        self.client.send_query_and_decode::<
1978            CentralDisconnectPeripheralRequest,
1979            fidl_fuchsia_bluetooth::Status,
1980        >(
1981            (identifier,),
1982            0xa9430da197362fd,
1983            fidl::encoding::DynamicFlags::empty(),
1984            _decode,
1985        )
1986    }
1987}
1988
1989pub struct CentralEventStream {
1990    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1991}
1992
1993impl std::marker::Unpin for CentralEventStream {}
1994
1995impl futures::stream::FusedStream for CentralEventStream {
1996    fn is_terminated(&self) -> bool {
1997        self.event_receiver.is_terminated()
1998    }
1999}
2000
2001impl futures::Stream for CentralEventStream {
2002    type Item = Result<CentralEvent, fidl::Error>;
2003
2004    fn poll_next(
2005        mut self: std::pin::Pin<&mut Self>,
2006        cx: &mut std::task::Context<'_>,
2007    ) -> std::task::Poll<Option<Self::Item>> {
2008        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2009            &mut self.event_receiver,
2010            cx
2011        )?) {
2012            Some(buf) => std::task::Poll::Ready(Some(CentralEvent::decode(buf))),
2013            None => std::task::Poll::Ready(None),
2014        }
2015    }
2016}
2017
2018#[derive(Debug)]
2019pub enum CentralEvent {
2020    OnScanStateChanged { scanning: bool },
2021    OnDeviceDiscovered { device: RemoteDevice },
2022    OnPeripheralDisconnected { identifier: String },
2023}
2024
2025impl CentralEvent {
2026    #[allow(irrefutable_let_patterns)]
2027    pub fn into_on_scan_state_changed(self) -> Option<bool> {
2028        if let CentralEvent::OnScanStateChanged { scanning } = self {
2029            Some((scanning))
2030        } else {
2031            None
2032        }
2033    }
2034    #[allow(irrefutable_let_patterns)]
2035    pub fn into_on_device_discovered(self) -> Option<RemoteDevice> {
2036        if let CentralEvent::OnDeviceDiscovered { device } = self { Some((device)) } else { None }
2037    }
2038    #[allow(irrefutable_let_patterns)]
2039    pub fn into_on_peripheral_disconnected(self) -> Option<String> {
2040        if let CentralEvent::OnPeripheralDisconnected { identifier } = self {
2041            Some((identifier))
2042        } else {
2043            None
2044        }
2045    }
2046
2047    /// Decodes a message buffer as a [`CentralEvent`].
2048    fn decode(
2049        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2050    ) -> Result<CentralEvent, fidl::Error> {
2051        let (bytes, _handles) = buf.split_mut();
2052        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2053        debug_assert_eq!(tx_header.tx_id, 0);
2054        match tx_header.ordinal {
2055            0x5f8edc23cad04d3f => {
2056                let mut out = fidl::new_empty!(
2057                    CentralOnScanStateChangedRequest,
2058                    fidl::encoding::DefaultFuchsiaResourceDialect
2059                );
2060                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnScanStateChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2061                Ok((CentralEvent::OnScanStateChanged { scanning: out.scanning }))
2062            }
2063            0x708dadf20d66db6 => {
2064                let mut out = fidl::new_empty!(
2065                    CentralOnDeviceDiscoveredRequest,
2066                    fidl::encoding::DefaultFuchsiaResourceDialect
2067                );
2068                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnDeviceDiscoveredRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2069                Ok((CentralEvent::OnDeviceDiscovered { device: out.device }))
2070            }
2071            0x4e4c6b979b2126df => {
2072                let mut out = fidl::new_empty!(
2073                    CentralOnPeripheralDisconnectedRequest,
2074                    fidl::encoding::DefaultFuchsiaResourceDialect
2075                );
2076                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnPeripheralDisconnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2077                Ok((CentralEvent::OnPeripheralDisconnected { identifier: out.identifier }))
2078            }
2079            _ => Err(fidl::Error::UnknownOrdinal {
2080                ordinal: tx_header.ordinal,
2081                protocol_name: <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2082            }),
2083        }
2084    }
2085}
2086
2087/// A Stream of incoming requests for fuchsia.bluetooth.le/Central.
2088pub struct CentralRequestStream {
2089    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2090    is_terminated: bool,
2091}
2092
2093impl std::marker::Unpin for CentralRequestStream {}
2094
2095impl futures::stream::FusedStream for CentralRequestStream {
2096    fn is_terminated(&self) -> bool {
2097        self.is_terminated
2098    }
2099}
2100
2101impl fidl::endpoints::RequestStream for CentralRequestStream {
2102    type Protocol = CentralMarker;
2103    type ControlHandle = CentralControlHandle;
2104
2105    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2106        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2107    }
2108
2109    fn control_handle(&self) -> Self::ControlHandle {
2110        CentralControlHandle { inner: self.inner.clone() }
2111    }
2112
2113    fn into_inner(
2114        self,
2115    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2116    {
2117        (self.inner, self.is_terminated)
2118    }
2119
2120    fn from_inner(
2121        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2122        is_terminated: bool,
2123    ) -> Self {
2124        Self { inner, is_terminated }
2125    }
2126}
2127
2128impl futures::Stream for CentralRequestStream {
2129    type Item = Result<CentralRequest, fidl::Error>;
2130
2131    fn poll_next(
2132        mut self: std::pin::Pin<&mut Self>,
2133        cx: &mut std::task::Context<'_>,
2134    ) -> std::task::Poll<Option<Self::Item>> {
2135        let this = &mut *self;
2136        if this.inner.check_shutdown(cx) {
2137            this.is_terminated = true;
2138            return std::task::Poll::Ready(None);
2139        }
2140        if this.is_terminated {
2141            panic!("polled CentralRequestStream after completion");
2142        }
2143        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2144            |bytes, handles| {
2145                match this.inner.channel().read_etc(cx, bytes, handles) {
2146                    std::task::Poll::Ready(Ok(())) => {}
2147                    std::task::Poll::Pending => return std::task::Poll::Pending,
2148                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2149                        this.is_terminated = true;
2150                        return std::task::Poll::Ready(None);
2151                    }
2152                    std::task::Poll::Ready(Err(e)) => {
2153                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2154                            e.into(),
2155                        ))));
2156                    }
2157                }
2158
2159                // A message has been received from the channel
2160                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2161
2162                std::task::Poll::Ready(Some(match header.ordinal {
2163                    0x39c6e9001d102338 => {
2164                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2165                        let mut req = fidl::new_empty!(
2166                            ChannelListenerRegistryListenL2capRequest,
2167                            fidl::encoding::DefaultFuchsiaResourceDialect
2168                        );
2169                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
2170                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2171                        Ok(CentralRequest::ListenL2cap {
2172                            payload: req,
2173                            responder: CentralListenL2capResponder {
2174                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2175                                tx_id: header.tx_id,
2176                            },
2177                        })
2178                    }
2179                    0x41f7121798dfe15f => {
2180                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2181                        let mut req = fidl::new_empty!(
2182                            CentralScanRequest,
2183                            fidl::encoding::DefaultFuchsiaResourceDialect
2184                        );
2185                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralScanRequest>(&header, _body_bytes, handles, &mut req)?;
2186                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2187                        Ok(CentralRequest::Scan {
2188                            options: req.options,
2189                            result_watcher: req.result_watcher,
2190
2191                            responder: CentralScanResponder {
2192                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2193                                tx_id: header.tx_id,
2194                            },
2195                        })
2196                    }
2197                    0x31a3065f2a6913c4 => {
2198                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2199                        let mut req = fidl::new_empty!(
2200                            CentralConnectRequest,
2201                            fidl::encoding::DefaultFuchsiaResourceDialect
2202                        );
2203                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectRequest>(&header, _body_bytes, handles, &mut req)?;
2204                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2205                        Ok(CentralRequest::Connect {
2206                            id: req.id,
2207                            options: req.options,
2208                            handle: req.handle,
2209
2210                            control_handle,
2211                        })
2212                    }
2213                    0x1db6df126a00c5b9 => {
2214                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2215                        let mut req = fidl::new_empty!(
2216                            CentralSyncToPeriodicAdvertisingRequest,
2217                            fidl::encoding::DefaultFuchsiaResourceDialect
2218                        );
2219                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralSyncToPeriodicAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
2220                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2221                        Ok(CentralRequest::SyncToPeriodicAdvertising {
2222                            payload: req,
2223                            control_handle,
2224                        })
2225                    }
2226                    0x60323e70ae22e13 => {
2227                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2228                        let mut req = fidl::new_empty!(
2229                            CentralCreateConnectedIsochronousGroupRequest,
2230                            fidl::encoding::DefaultFuchsiaResourceDialect
2231                        );
2232                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralCreateConnectedIsochronousGroupRequest>(&header, _body_bytes, handles, &mut req)?;
2233                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2234                        Ok(CentralRequest::CreateConnectedIsochronousGroup {
2235                            payload: req,
2236                            responder: CentralCreateConnectedIsochronousGroupResponder {
2237                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2238                                tx_id: header.tx_id,
2239                            },
2240                        })
2241                    }
2242                    0x37ba777499c683a8 => {
2243                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2244                        let mut req = fidl::new_empty!(
2245                            CentralGetPeripheralsRequest,
2246                            fidl::encoding::DefaultFuchsiaResourceDialect
2247                        );
2248                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralsRequest>(&header, _body_bytes, handles, &mut req)?;
2249                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2250                        Ok(CentralRequest::GetPeripherals {
2251                            service_uuids: req.service_uuids,
2252
2253                            responder: CentralGetPeripheralsResponder {
2254                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2255                                tx_id: header.tx_id,
2256                            },
2257                        })
2258                    }
2259                    0x97f5a2f2d9c13da => {
2260                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2261                        let mut req = fidl::new_empty!(
2262                            CentralGetPeripheralRequest,
2263                            fidl::encoding::DefaultFuchsiaResourceDialect
2264                        );
2265                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2266                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2267                        Ok(CentralRequest::GetPeripheral {
2268                            identifier: req.identifier,
2269
2270                            responder: CentralGetPeripheralResponder {
2271                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2272                                tx_id: header.tx_id,
2273                            },
2274                        })
2275                    }
2276                    0xeb4cf0cd0e1132b => {
2277                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2278                        let mut req = fidl::new_empty!(
2279                            CentralStartScanRequest,
2280                            fidl::encoding::DefaultFuchsiaResourceDialect
2281                        );
2282                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralStartScanRequest>(&header, _body_bytes, handles, &mut req)?;
2283                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2284                        Ok(CentralRequest::StartScan {
2285                            filter: req.filter,
2286
2287                            responder: CentralStartScanResponder {
2288                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2289                                tx_id: header.tx_id,
2290                            },
2291                        })
2292                    }
2293                    0x5f79ee6a0bb037a0 => {
2294                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2295                        let mut req = fidl::new_empty!(
2296                            fidl::encoding::EmptyPayload,
2297                            fidl::encoding::DefaultFuchsiaResourceDialect
2298                        );
2299                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2300                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2301                        Ok(CentralRequest::StopScan { control_handle })
2302                    }
2303                    0x714d6c32d066d75a => {
2304                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2305                        let mut req = fidl::new_empty!(
2306                            CentralConnectPeripheralRequest,
2307                            fidl::encoding::DefaultFuchsiaResourceDialect
2308                        );
2309                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2310                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2311                        Ok(CentralRequest::ConnectPeripheral {
2312                            identifier: req.identifier,
2313                            options: req.options,
2314                            gatt_client: req.gatt_client,
2315
2316                            responder: CentralConnectPeripheralResponder {
2317                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2318                                tx_id: header.tx_id,
2319                            },
2320                        })
2321                    }
2322                    0xa9430da197362fd => {
2323                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2324                        let mut req = fidl::new_empty!(
2325                            CentralDisconnectPeripheralRequest,
2326                            fidl::encoding::DefaultFuchsiaResourceDialect
2327                        );
2328                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralDisconnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2329                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2330                        Ok(CentralRequest::DisconnectPeripheral {
2331                            identifier: req.identifier,
2332
2333                            responder: CentralDisconnectPeripheralResponder {
2334                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2335                                tx_id: header.tx_id,
2336                            },
2337                        })
2338                    }
2339                    _ => Err(fidl::Error::UnknownOrdinal {
2340                        ordinal: header.ordinal,
2341                        protocol_name:
2342                            <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2343                    }),
2344                }))
2345            },
2346        )
2347    }
2348}
2349
2350#[derive(Debug)]
2351pub enum CentralRequest {
2352    /// Register a listener for incoming channels. The registry will assign a
2353    /// PSM value that is unique for the local device, as well as open a
2354    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
2355    /// event that all PSMs have been assigned, this call will fail with
2356    /// `ZX_ERR_NO_RESOURCES`.
2357    ///
2358    /// Note that the method of service discovery or advertising is defined by
2359    /// the service or protocol, so it is the responsibility of the caller to
2360    /// communicate the assigned PSM to any clients.
2361    ListenL2cap {
2362        payload: ChannelListenerRegistryListenL2capRequest,
2363        responder: CentralListenL2capResponder,
2364    },
2365    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
2366    /// initiated, then `result_watcher` will be closed with an epitaph.
2367    ///
2368    /// A Central client is allowed to have only one active scan at a time.
2369    /// Accordingly, only one Scan request can be outstanding at a time.
2370    /// Additional calls to Scan will fail.
2371    ///
2372    /// The lifetime of the scan session is tied to the `result_watcher`
2373    /// protocol provided. The scan will be stopped if the channel is closed.
2374    ///
2375    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
2376    /// can be used to watch for scan results.
2377    ///
2378    /// + request `options` Options used to configure the scan session.
2379    /// + request `result_watcher` Protocol that remains valid for the duration
2380    ///   of this scan session.
2381    /// - response An empty response will be sent to acknowledge the scan has
2382    ///   stopped.
2383    ///
2384    /// The following epitaphs may be sent by the server on error:
2385    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
2386    ///   protocol is only allowed 1 active scan.
2387    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
2388    ///   `ScanOptions` documentation.
2389    /// * error `INTERNAL`: An internal error occurred and a scan could not be
2390    ///   started.
2391    Scan {
2392        options: ScanOptions,
2393        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
2394        responder: CentralScanResponder,
2395    },
2396    /// Connect to the peer with the given identifier.
2397    ///
2398    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
2399    /// client's interest on the LE connection to the peer. Closing the channel
2400    /// removes interest, but may not result in disconnection if another client
2401    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
2402    ///
2403    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
2404    /// system if the connection to the peer is lost or an error occurs.
2405    ///
2406    /// The following epitaphs may be sent by the server on error:
2407    /// + `INVALID_ARGS`: Some of the parameters are invalid.
2408    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
2409    ///                    Connection should be used.
2410    /// + `NOT_CONNECTED`: A connection could not be established.
2411    /// + `CONNECTION_RESET`: The peer disconnected.
2412    ///
2413    /// + request `id` Identifier of the peer to initiate a connection to.
2414    /// + request `options` Options used to configure the connection.
2415    /// + request `handle` Handle that remains valid for the duration of this
2416    ///   connection.
2417    Connect {
2418        id: fidl_fuchsia_bluetooth::PeerId,
2419        options: ConnectionOptions,
2420        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
2421        control_handle: CentralControlHandle,
2422    },
2423    /// Synchronize to a periodic advertising train. Reports will be delivered via the
2424    /// `PeriodicAdvertisingSync` protocol.
2425    SyncToPeriodicAdvertising {
2426        payload: CentralSyncToPeriodicAdvertisingRequest,
2427        control_handle: CentralControlHandle,
2428    },
2429    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
2430    /// operation is only valid when operating in the Central role for a connection.
2431    ///
2432    /// If the Central channel is closed before the CIG is explicitly removed, the group will
2433    /// be removed and disconnected.
2434    ///
2435    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
2436    /// id allocated by the host.
2437    CreateConnectedIsochronousGroup {
2438        payload: CentralCreateConnectedIsochronousGroupRequest,
2439        responder: CentralCreateConnectedIsochronousGroupResponder,
2440    },
2441    /// Returns the list of peripherals that are known to the system from previous scan, connection,
2442    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
2443    /// be present on the peripheral.
2444    ///
2445    /// This method only returns peripherals (i.e. connectable devices).
2446    GetPeripherals { service_uuids: Option<Vec<String>>, responder: CentralGetPeripheralsResponder },
2447    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
2448    ///
2449    /// Returns information about a single peripheral that is known to the system from previous scan,
2450    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
2451    /// `identifier` is not recognized.
2452    GetPeripheral { identifier: String, responder: CentralGetPeripheralResponder },
2453    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
2454    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
2455    /// `filter` will replace the existing session's filter.
2456    ///
2457    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
2458    /// will be notified for all discoverable devices that are found. This is not recommended; clients
2459    /// should generally filter results by at least one of `filter.service_uuids`,
2460    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
2461    StartScan { filter: Option<Box<ScanFilter>>, responder: CentralStartScanResponder },
2462    /// Terminate a previously started scan session.
2463    StopScan { control_handle: CentralControlHandle },
2464    /// Creates a connection to the peripheral device with the given identifier.
2465    /// Returns the status of the operation in `status`.
2466    ///
2467    /// On success, `gatt_client` will be bound and can be used for GATT client
2468    /// role procedures. On failure, `gatt_client` will be closed and `status` will
2469    /// indicate an error.
2470    ConnectPeripheral {
2471        identifier: String,
2472        options: ConnectionOptions,
2473        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
2474        responder: CentralConnectPeripheralResponder,
2475    },
2476    /// Disconnects this Central's connection to the peripheral with the given identifier.
2477    DisconnectPeripheral { identifier: String, responder: CentralDisconnectPeripheralResponder },
2478}
2479
2480impl CentralRequest {
2481    #[allow(irrefutable_let_patterns)]
2482    pub fn into_listen_l2cap(
2483        self,
2484    ) -> Option<(ChannelListenerRegistryListenL2capRequest, CentralListenL2capResponder)> {
2485        if let CentralRequest::ListenL2cap { payload, responder } = self {
2486            Some((payload, responder))
2487        } else {
2488            None
2489        }
2490    }
2491
2492    #[allow(irrefutable_let_patterns)]
2493    pub fn into_scan(
2494        self,
2495    ) -> Option<(
2496        ScanOptions,
2497        fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
2498        CentralScanResponder,
2499    )> {
2500        if let CentralRequest::Scan { options, result_watcher, responder } = self {
2501            Some((options, result_watcher, responder))
2502        } else {
2503            None
2504        }
2505    }
2506
2507    #[allow(irrefutable_let_patterns)]
2508    pub fn into_connect(
2509        self,
2510    ) -> Option<(
2511        fidl_fuchsia_bluetooth::PeerId,
2512        ConnectionOptions,
2513        fidl::endpoints::ServerEnd<ConnectionMarker>,
2514        CentralControlHandle,
2515    )> {
2516        if let CentralRequest::Connect { id, options, handle, control_handle } = self {
2517            Some((id, options, handle, control_handle))
2518        } else {
2519            None
2520        }
2521    }
2522
2523    #[allow(irrefutable_let_patterns)]
2524    pub fn into_sync_to_periodic_advertising(
2525        self,
2526    ) -> Option<(CentralSyncToPeriodicAdvertisingRequest, CentralControlHandle)> {
2527        if let CentralRequest::SyncToPeriodicAdvertising { payload, control_handle } = self {
2528            Some((payload, control_handle))
2529        } else {
2530            None
2531        }
2532    }
2533
2534    #[allow(irrefutable_let_patterns)]
2535    pub fn into_create_connected_isochronous_group(
2536        self,
2537    ) -> Option<(
2538        CentralCreateConnectedIsochronousGroupRequest,
2539        CentralCreateConnectedIsochronousGroupResponder,
2540    )> {
2541        if let CentralRequest::CreateConnectedIsochronousGroup { payload, responder } = self {
2542            Some((payload, responder))
2543        } else {
2544            None
2545        }
2546    }
2547
2548    #[allow(irrefutable_let_patterns)]
2549    pub fn into_get_peripherals(
2550        self,
2551    ) -> Option<(Option<Vec<String>>, CentralGetPeripheralsResponder)> {
2552        if let CentralRequest::GetPeripherals { service_uuids, responder } = self {
2553            Some((service_uuids, responder))
2554        } else {
2555            None
2556        }
2557    }
2558
2559    #[allow(irrefutable_let_patterns)]
2560    pub fn into_get_peripheral(self) -> Option<(String, CentralGetPeripheralResponder)> {
2561        if let CentralRequest::GetPeripheral { identifier, responder } = self {
2562            Some((identifier, responder))
2563        } else {
2564            None
2565        }
2566    }
2567
2568    #[allow(irrefutable_let_patterns)]
2569    pub fn into_start_scan(self) -> Option<(Option<Box<ScanFilter>>, CentralStartScanResponder)> {
2570        if let CentralRequest::StartScan { filter, responder } = self {
2571            Some((filter, responder))
2572        } else {
2573            None
2574        }
2575    }
2576
2577    #[allow(irrefutable_let_patterns)]
2578    pub fn into_stop_scan(self) -> Option<(CentralControlHandle)> {
2579        if let CentralRequest::StopScan { control_handle } = self {
2580            Some((control_handle))
2581        } else {
2582            None
2583        }
2584    }
2585
2586    #[allow(irrefutable_let_patterns)]
2587    pub fn into_connect_peripheral(
2588        self,
2589    ) -> Option<(
2590        String,
2591        ConnectionOptions,
2592        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
2593        CentralConnectPeripheralResponder,
2594    )> {
2595        if let CentralRequest::ConnectPeripheral { identifier, options, gatt_client, responder } =
2596            self
2597        {
2598            Some((identifier, options, gatt_client, responder))
2599        } else {
2600            None
2601        }
2602    }
2603
2604    #[allow(irrefutable_let_patterns)]
2605    pub fn into_disconnect_peripheral(
2606        self,
2607    ) -> Option<(String, CentralDisconnectPeripheralResponder)> {
2608        if let CentralRequest::DisconnectPeripheral { identifier, responder } = self {
2609            Some((identifier, responder))
2610        } else {
2611            None
2612        }
2613    }
2614
2615    /// Name of the method defined in FIDL
2616    pub fn method_name(&self) -> &'static str {
2617        match *self {
2618            CentralRequest::ListenL2cap { .. } => "listen_l2cap",
2619            CentralRequest::Scan { .. } => "scan",
2620            CentralRequest::Connect { .. } => "connect",
2621            CentralRequest::SyncToPeriodicAdvertising { .. } => "sync_to_periodic_advertising",
2622            CentralRequest::CreateConnectedIsochronousGroup { .. } => {
2623                "create_connected_isochronous_group"
2624            }
2625            CentralRequest::GetPeripherals { .. } => "get_peripherals",
2626            CentralRequest::GetPeripheral { .. } => "get_peripheral",
2627            CentralRequest::StartScan { .. } => "start_scan",
2628            CentralRequest::StopScan { .. } => "stop_scan",
2629            CentralRequest::ConnectPeripheral { .. } => "connect_peripheral",
2630            CentralRequest::DisconnectPeripheral { .. } => "disconnect_peripheral",
2631        }
2632    }
2633}
2634
2635#[derive(Debug, Clone)]
2636pub struct CentralControlHandle {
2637    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2638}
2639
2640impl CentralControlHandle {
2641    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2642        self.inner.shutdown_with_epitaph(status.into())
2643    }
2644}
2645
2646impl fidl::endpoints::ControlHandle for CentralControlHandle {
2647    fn shutdown(&self) {
2648        self.inner.shutdown()
2649    }
2650
2651    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2652        self.inner.shutdown_with_epitaph(status)
2653    }
2654
2655    fn is_closed(&self) -> bool {
2656        self.inner.channel().is_closed()
2657    }
2658    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2659        self.inner.channel().on_closed()
2660    }
2661
2662    #[cfg(target_os = "fuchsia")]
2663    fn signal_peer(
2664        &self,
2665        clear_mask: zx::Signals,
2666        set_mask: zx::Signals,
2667    ) -> Result<(), zx_status::Status> {
2668        use fidl::Peered;
2669        self.inner.channel().signal_peer(clear_mask, set_mask)
2670    }
2671}
2672
2673impl CentralControlHandle {
2674    pub fn send_on_scan_state_changed(&self, mut scanning: bool) -> Result<(), fidl::Error> {
2675        self.inner.send::<CentralOnScanStateChangedRequest>(
2676            (scanning,),
2677            0,
2678            0x5f8edc23cad04d3f,
2679            fidl::encoding::DynamicFlags::empty(),
2680        )
2681    }
2682
2683    pub fn send_on_device_discovered(&self, mut device: &RemoteDevice) -> Result<(), fidl::Error> {
2684        self.inner.send::<CentralOnDeviceDiscoveredRequest>(
2685            (device,),
2686            0,
2687            0x708dadf20d66db6,
2688            fidl::encoding::DynamicFlags::empty(),
2689        )
2690    }
2691
2692    pub fn send_on_peripheral_disconnected(&self, mut identifier: &str) -> Result<(), fidl::Error> {
2693        self.inner.send::<CentralOnPeripheralDisconnectedRequest>(
2694            (identifier,),
2695            0,
2696            0x4e4c6b979b2126df,
2697            fidl::encoding::DynamicFlags::empty(),
2698        )
2699    }
2700}
2701
2702#[must_use = "FIDL methods require a response to be sent"]
2703#[derive(Debug)]
2704pub struct CentralListenL2capResponder {
2705    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2706    tx_id: u32,
2707}
2708
2709/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2710/// if the responder is dropped without sending a response, so that the client
2711/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2712impl std::ops::Drop for CentralListenL2capResponder {
2713    fn drop(&mut self) {
2714        self.control_handle.shutdown();
2715        // Safety: drops once, never accessed again
2716        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2717    }
2718}
2719
2720impl fidl::endpoints::Responder for CentralListenL2capResponder {
2721    type ControlHandle = CentralControlHandle;
2722
2723    fn control_handle(&self) -> &CentralControlHandle {
2724        &self.control_handle
2725    }
2726
2727    fn drop_without_shutdown(mut self) {
2728        // Safety: drops once, never accessed again due to mem::forget
2729        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2730        // Prevent Drop from running (which would shut down the channel)
2731        std::mem::forget(self);
2732    }
2733}
2734
2735impl CentralListenL2capResponder {
2736    /// Sends a response to the FIDL transaction.
2737    ///
2738    /// Sets the channel to shutdown if an error occurs.
2739    pub fn send(
2740        self,
2741        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2742    ) -> Result<(), fidl::Error> {
2743        let _result = self.send_raw(result);
2744        if _result.is_err() {
2745            self.control_handle.shutdown();
2746        }
2747        self.drop_without_shutdown();
2748        _result
2749    }
2750
2751    /// Similar to "send" but does not shutdown the channel if an error occurs.
2752    pub fn send_no_shutdown_on_err(
2753        self,
2754        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2755    ) -> Result<(), fidl::Error> {
2756        let _result = self.send_raw(result);
2757        self.drop_without_shutdown();
2758        _result
2759    }
2760
2761    fn send_raw(
2762        &self,
2763        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2764    ) -> Result<(), fidl::Error> {
2765        self.control_handle.inner.send::<fidl::encoding::ResultType<
2766            ChannelListenerRegistryListenL2capResponse,
2767            i32,
2768        >>(
2769            result,
2770            self.tx_id,
2771            0x39c6e9001d102338,
2772            fidl::encoding::DynamicFlags::empty(),
2773        )
2774    }
2775}
2776
2777#[must_use = "FIDL methods require a response to be sent"]
2778#[derive(Debug)]
2779pub struct CentralScanResponder {
2780    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2781    tx_id: u32,
2782}
2783
2784/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2785/// if the responder is dropped without sending a response, so that the client
2786/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2787impl std::ops::Drop for CentralScanResponder {
2788    fn drop(&mut self) {
2789        self.control_handle.shutdown();
2790        // Safety: drops once, never accessed again
2791        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2792    }
2793}
2794
2795impl fidl::endpoints::Responder for CentralScanResponder {
2796    type ControlHandle = CentralControlHandle;
2797
2798    fn control_handle(&self) -> &CentralControlHandle {
2799        &self.control_handle
2800    }
2801
2802    fn drop_without_shutdown(mut self) {
2803        // Safety: drops once, never accessed again due to mem::forget
2804        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2805        // Prevent Drop from running (which would shut down the channel)
2806        std::mem::forget(self);
2807    }
2808}
2809
2810impl CentralScanResponder {
2811    /// Sends a response to the FIDL transaction.
2812    ///
2813    /// Sets the channel to shutdown if an error occurs.
2814    pub fn send(self) -> Result<(), fidl::Error> {
2815        let _result = self.send_raw();
2816        if _result.is_err() {
2817            self.control_handle.shutdown();
2818        }
2819        self.drop_without_shutdown();
2820        _result
2821    }
2822
2823    /// Similar to "send" but does not shutdown the channel if an error occurs.
2824    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2825        let _result = self.send_raw();
2826        self.drop_without_shutdown();
2827        _result
2828    }
2829
2830    fn send_raw(&self) -> Result<(), fidl::Error> {
2831        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2832            (),
2833            self.tx_id,
2834            0x41f7121798dfe15f,
2835            fidl::encoding::DynamicFlags::empty(),
2836        )
2837    }
2838}
2839
2840#[must_use = "FIDL methods require a response to be sent"]
2841#[derive(Debug)]
2842pub struct CentralCreateConnectedIsochronousGroupResponder {
2843    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2844    tx_id: u32,
2845}
2846
2847/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2848/// if the responder is dropped without sending a response, so that the client
2849/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2850impl std::ops::Drop for CentralCreateConnectedIsochronousGroupResponder {
2851    fn drop(&mut self) {
2852        self.control_handle.shutdown();
2853        // Safety: drops once, never accessed again
2854        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2855    }
2856}
2857
2858impl fidl::endpoints::Responder for CentralCreateConnectedIsochronousGroupResponder {
2859    type ControlHandle = CentralControlHandle;
2860
2861    fn control_handle(&self) -> &CentralControlHandle {
2862        &self.control_handle
2863    }
2864
2865    fn drop_without_shutdown(mut self) {
2866        // Safety: drops once, never accessed again due to mem::forget
2867        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2868        // Prevent Drop from running (which would shut down the channel)
2869        std::mem::forget(self);
2870    }
2871}
2872
2873impl CentralCreateConnectedIsochronousGroupResponder {
2874    /// Sends a response to the FIDL transaction.
2875    ///
2876    /// Sets the channel to shutdown if an error occurs.
2877    pub fn send(
2878        self,
2879        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2880    ) -> Result<(), fidl::Error> {
2881        let _result = self.send_raw(result);
2882        if _result.is_err() {
2883            self.control_handle.shutdown();
2884        }
2885        self.drop_without_shutdown();
2886        _result
2887    }
2888
2889    /// Similar to "send" but does not shutdown the channel if an error occurs.
2890    pub fn send_no_shutdown_on_err(
2891        self,
2892        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2893    ) -> Result<(), fidl::Error> {
2894        let _result = self.send_raw(result);
2895        self.drop_without_shutdown();
2896        _result
2897    }
2898
2899    fn send_raw(
2900        &self,
2901        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2902    ) -> Result<(), fidl::Error> {
2903        self.control_handle.inner.send::<fidl::encoding::ResultType<
2904            CentralCreateConnectedIsochronousGroupResponse,
2905            CreateCigError,
2906        >>(
2907            result,
2908            self.tx_id,
2909            0x60323e70ae22e13,
2910            fidl::encoding::DynamicFlags::empty(),
2911        )
2912    }
2913}
2914
2915#[must_use = "FIDL methods require a response to be sent"]
2916#[derive(Debug)]
2917pub struct CentralGetPeripheralsResponder {
2918    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2919    tx_id: u32,
2920}
2921
2922/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2923/// if the responder is dropped without sending a response, so that the client
2924/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2925impl std::ops::Drop for CentralGetPeripheralsResponder {
2926    fn drop(&mut self) {
2927        self.control_handle.shutdown();
2928        // Safety: drops once, never accessed again
2929        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2930    }
2931}
2932
2933impl fidl::endpoints::Responder for CentralGetPeripheralsResponder {
2934    type ControlHandle = CentralControlHandle;
2935
2936    fn control_handle(&self) -> &CentralControlHandle {
2937        &self.control_handle
2938    }
2939
2940    fn drop_without_shutdown(mut self) {
2941        // Safety: drops once, never accessed again due to mem::forget
2942        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2943        // Prevent Drop from running (which would shut down the channel)
2944        std::mem::forget(self);
2945    }
2946}
2947
2948impl CentralGetPeripheralsResponder {
2949    /// Sends a response to the FIDL transaction.
2950    ///
2951    /// Sets the channel to shutdown if an error occurs.
2952    pub fn send(self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
2953        let _result = self.send_raw(peripherals);
2954        if _result.is_err() {
2955            self.control_handle.shutdown();
2956        }
2957        self.drop_without_shutdown();
2958        _result
2959    }
2960
2961    /// Similar to "send" but does not shutdown the channel if an error occurs.
2962    pub fn send_no_shutdown_on_err(
2963        self,
2964        mut peripherals: &[RemoteDevice],
2965    ) -> Result<(), fidl::Error> {
2966        let _result = self.send_raw(peripherals);
2967        self.drop_without_shutdown();
2968        _result
2969    }
2970
2971    fn send_raw(&self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
2972        self.control_handle.inner.send::<CentralGetPeripheralsResponse>(
2973            (peripherals,),
2974            self.tx_id,
2975            0x37ba777499c683a8,
2976            fidl::encoding::DynamicFlags::empty(),
2977        )
2978    }
2979}
2980
2981#[must_use = "FIDL methods require a response to be sent"]
2982#[derive(Debug)]
2983pub struct CentralGetPeripheralResponder {
2984    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2985    tx_id: u32,
2986}
2987
2988/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2989/// if the responder is dropped without sending a response, so that the client
2990/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2991impl std::ops::Drop for CentralGetPeripheralResponder {
2992    fn drop(&mut self) {
2993        self.control_handle.shutdown();
2994        // Safety: drops once, never accessed again
2995        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2996    }
2997}
2998
2999impl fidl::endpoints::Responder for CentralGetPeripheralResponder {
3000    type ControlHandle = CentralControlHandle;
3001
3002    fn control_handle(&self) -> &CentralControlHandle {
3003        &self.control_handle
3004    }
3005
3006    fn drop_without_shutdown(mut self) {
3007        // Safety: drops once, never accessed again due to mem::forget
3008        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3009        // Prevent Drop from running (which would shut down the channel)
3010        std::mem::forget(self);
3011    }
3012}
3013
3014impl CentralGetPeripheralResponder {
3015    /// Sends a response to the FIDL transaction.
3016    ///
3017    /// Sets the channel to shutdown if an error occurs.
3018    pub fn send(self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
3019        let _result = self.send_raw(peripheral);
3020        if _result.is_err() {
3021            self.control_handle.shutdown();
3022        }
3023        self.drop_without_shutdown();
3024        _result
3025    }
3026
3027    /// Similar to "send" but does not shutdown the channel if an error occurs.
3028    pub fn send_no_shutdown_on_err(
3029        self,
3030        mut peripheral: Option<&RemoteDevice>,
3031    ) -> Result<(), fidl::Error> {
3032        let _result = self.send_raw(peripheral);
3033        self.drop_without_shutdown();
3034        _result
3035    }
3036
3037    fn send_raw(&self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
3038        self.control_handle.inner.send::<CentralGetPeripheralResponse>(
3039            (peripheral,),
3040            self.tx_id,
3041            0x97f5a2f2d9c13da,
3042            fidl::encoding::DynamicFlags::empty(),
3043        )
3044    }
3045}
3046
3047#[must_use = "FIDL methods require a response to be sent"]
3048#[derive(Debug)]
3049pub struct CentralStartScanResponder {
3050    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
3051    tx_id: u32,
3052}
3053
3054/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3055/// if the responder is dropped without sending a response, so that the client
3056/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3057impl std::ops::Drop for CentralStartScanResponder {
3058    fn drop(&mut self) {
3059        self.control_handle.shutdown();
3060        // Safety: drops once, never accessed again
3061        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3062    }
3063}
3064
3065impl fidl::endpoints::Responder for CentralStartScanResponder {
3066    type ControlHandle = CentralControlHandle;
3067
3068    fn control_handle(&self) -> &CentralControlHandle {
3069        &self.control_handle
3070    }
3071
3072    fn drop_without_shutdown(mut self) {
3073        // Safety: drops once, never accessed again due to mem::forget
3074        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3075        // Prevent Drop from running (which would shut down the channel)
3076        std::mem::forget(self);
3077    }
3078}
3079
3080impl CentralStartScanResponder {
3081    /// Sends a response to the FIDL transaction.
3082    ///
3083    /// Sets the channel to shutdown if an error occurs.
3084    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3085        let _result = self.send_raw(status);
3086        if _result.is_err() {
3087            self.control_handle.shutdown();
3088        }
3089        self.drop_without_shutdown();
3090        _result
3091    }
3092
3093    /// Similar to "send" but does not shutdown the channel if an error occurs.
3094    pub fn send_no_shutdown_on_err(
3095        self,
3096        mut status: &fidl_fuchsia_bluetooth::Status,
3097    ) -> Result<(), fidl::Error> {
3098        let _result = self.send_raw(status);
3099        self.drop_without_shutdown();
3100        _result
3101    }
3102
3103    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3104        self.control_handle.inner.send::<CentralStartScanResponse>(
3105            (status,),
3106            self.tx_id,
3107            0xeb4cf0cd0e1132b,
3108            fidl::encoding::DynamicFlags::empty(),
3109        )
3110    }
3111}
3112
3113#[must_use = "FIDL methods require a response to be sent"]
3114#[derive(Debug)]
3115pub struct CentralConnectPeripheralResponder {
3116    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
3117    tx_id: u32,
3118}
3119
3120/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3121/// if the responder is dropped without sending a response, so that the client
3122/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3123impl std::ops::Drop for CentralConnectPeripheralResponder {
3124    fn drop(&mut self) {
3125        self.control_handle.shutdown();
3126        // Safety: drops once, never accessed again
3127        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3128    }
3129}
3130
3131impl fidl::endpoints::Responder for CentralConnectPeripheralResponder {
3132    type ControlHandle = CentralControlHandle;
3133
3134    fn control_handle(&self) -> &CentralControlHandle {
3135        &self.control_handle
3136    }
3137
3138    fn drop_without_shutdown(mut self) {
3139        // Safety: drops once, never accessed again due to mem::forget
3140        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3141        // Prevent Drop from running (which would shut down the channel)
3142        std::mem::forget(self);
3143    }
3144}
3145
3146impl CentralConnectPeripheralResponder {
3147    /// Sends a response to the FIDL transaction.
3148    ///
3149    /// Sets the channel to shutdown if an error occurs.
3150    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3151        let _result = self.send_raw(status);
3152        if _result.is_err() {
3153            self.control_handle.shutdown();
3154        }
3155        self.drop_without_shutdown();
3156        _result
3157    }
3158
3159    /// Similar to "send" but does not shutdown the channel if an error occurs.
3160    pub fn send_no_shutdown_on_err(
3161        self,
3162        mut status: &fidl_fuchsia_bluetooth::Status,
3163    ) -> Result<(), fidl::Error> {
3164        let _result = self.send_raw(status);
3165        self.drop_without_shutdown();
3166        _result
3167    }
3168
3169    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3170        self.control_handle.inner.send::<CentralConnectPeripheralResponse>(
3171            (status,),
3172            self.tx_id,
3173            0x714d6c32d066d75a,
3174            fidl::encoding::DynamicFlags::empty(),
3175        )
3176    }
3177}
3178
3179#[must_use = "FIDL methods require a response to be sent"]
3180#[derive(Debug)]
3181pub struct CentralDisconnectPeripheralResponder {
3182    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
3183    tx_id: u32,
3184}
3185
3186/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3187/// if the responder is dropped without sending a response, so that the client
3188/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3189impl std::ops::Drop for CentralDisconnectPeripheralResponder {
3190    fn drop(&mut self) {
3191        self.control_handle.shutdown();
3192        // Safety: drops once, never accessed again
3193        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3194    }
3195}
3196
3197impl fidl::endpoints::Responder for CentralDisconnectPeripheralResponder {
3198    type ControlHandle = CentralControlHandle;
3199
3200    fn control_handle(&self) -> &CentralControlHandle {
3201        &self.control_handle
3202    }
3203
3204    fn drop_without_shutdown(mut self) {
3205        // Safety: drops once, never accessed again due to mem::forget
3206        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3207        // Prevent Drop from running (which would shut down the channel)
3208        std::mem::forget(self);
3209    }
3210}
3211
3212impl CentralDisconnectPeripheralResponder {
3213    /// Sends a response to the FIDL transaction.
3214    ///
3215    /// Sets the channel to shutdown if an error occurs.
3216    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3217        let _result = self.send_raw(status);
3218        if _result.is_err() {
3219            self.control_handle.shutdown();
3220        }
3221        self.drop_without_shutdown();
3222        _result
3223    }
3224
3225    /// Similar to "send" but does not shutdown the channel if an error occurs.
3226    pub fn send_no_shutdown_on_err(
3227        self,
3228        mut status: &fidl_fuchsia_bluetooth::Status,
3229    ) -> Result<(), fidl::Error> {
3230        let _result = self.send_raw(status);
3231        self.drop_without_shutdown();
3232        _result
3233    }
3234
3235    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3236        self.control_handle.inner.send::<CentralDisconnectPeripheralResponse>(
3237            (status,),
3238            self.tx_id,
3239            0xa9430da197362fd,
3240            fidl::encoding::DynamicFlags::empty(),
3241        )
3242    }
3243}
3244
3245#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3246pub struct ChannelListenerMarker;
3247
3248impl fidl::endpoints::ProtocolMarker for ChannelListenerMarker {
3249    type Proxy = ChannelListenerProxy;
3250    type RequestStream = ChannelListenerRequestStream;
3251    #[cfg(target_os = "fuchsia")]
3252    type SynchronousProxy = ChannelListenerSynchronousProxy;
3253
3254    const DEBUG_NAME: &'static str = "(anonymous) ChannelListener";
3255}
3256
3257pub trait ChannelListenerProxyInterface: Send + Sync {
3258    type AcceptResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3259    fn r#accept(
3260        &self,
3261        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3262    ) -> Self::AcceptResponseFut;
3263    type ConnectedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3264    fn r#connected(&self, payload: ChannelListenerConnectedRequest) -> Self::ConnectedResponseFut;
3265}
3266#[derive(Debug)]
3267#[cfg(target_os = "fuchsia")]
3268pub struct ChannelListenerSynchronousProxy {
3269    client: fidl::client::sync::Client,
3270}
3271
3272#[cfg(target_os = "fuchsia")]
3273impl fidl::endpoints::SynchronousProxy for ChannelListenerSynchronousProxy {
3274    type Proxy = ChannelListenerProxy;
3275    type Protocol = ChannelListenerMarker;
3276
3277    fn from_channel(inner: fidl::Channel) -> Self {
3278        Self::new(inner)
3279    }
3280
3281    fn into_channel(self) -> fidl::Channel {
3282        self.client.into_channel()
3283    }
3284
3285    fn as_channel(&self) -> &fidl::Channel {
3286        self.client.as_channel()
3287    }
3288}
3289
3290#[cfg(target_os = "fuchsia")]
3291impl ChannelListenerSynchronousProxy {
3292    pub fn new(channel: fidl::Channel) -> Self {
3293        Self { client: fidl::client::sync::Client::new(channel) }
3294    }
3295
3296    pub fn into_channel(self) -> fidl::Channel {
3297        self.client.into_channel()
3298    }
3299
3300    /// Waits until an event arrives and returns it. It is safe for other
3301    /// threads to make concurrent requests while waiting for an event.
3302    pub fn wait_for_event(
3303        &self,
3304        deadline: zx::MonotonicInstant,
3305    ) -> Result<ChannelListenerEvent, fidl::Error> {
3306        ChannelListenerEvent::decode(self.client.wait_for_event::<ChannelListenerMarker>(deadline)?)
3307    }
3308
3309    pub fn r#accept(
3310        &self,
3311        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3312        ___deadline: zx::MonotonicInstant,
3313    ) -> Result<(), fidl::Error> {
3314        let _response = self.client.send_query::<
3315            ChannelListenerAcceptRequest,
3316            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3317            ChannelListenerMarker,
3318        >(
3319            (channel,),
3320            0x6f535bd36b20fc7b,
3321            fidl::encoding::DynamicFlags::FLEXIBLE,
3322            ___deadline,
3323        )?
3324        .into_result::<ChannelListenerMarker>("accept")?;
3325        Ok(_response)
3326    }
3327
3328    /// Called for each successful incoming channel connection.
3329    pub fn r#connected(
3330        &self,
3331        mut payload: ChannelListenerConnectedRequest,
3332        ___deadline: zx::MonotonicInstant,
3333    ) -> Result<(), fidl::Error> {
3334        let _response = self.client.send_query::<
3335            ChannelListenerConnectedRequest,
3336            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3337            ChannelListenerMarker,
3338        >(
3339            &mut payload,
3340            0xf40756858f21866,
3341            fidl::encoding::DynamicFlags::FLEXIBLE,
3342            ___deadline,
3343        )?
3344        .into_result::<ChannelListenerMarker>("connected")?;
3345        Ok(_response)
3346    }
3347}
3348
3349#[cfg(target_os = "fuchsia")]
3350impl From<ChannelListenerSynchronousProxy> for zx::NullableHandle {
3351    fn from(value: ChannelListenerSynchronousProxy) -> Self {
3352        value.into_channel().into()
3353    }
3354}
3355
3356#[cfg(target_os = "fuchsia")]
3357impl From<fidl::Channel> for ChannelListenerSynchronousProxy {
3358    fn from(value: fidl::Channel) -> Self {
3359        Self::new(value)
3360    }
3361}
3362
3363#[cfg(target_os = "fuchsia")]
3364impl fidl::endpoints::FromClient for ChannelListenerSynchronousProxy {
3365    type Protocol = ChannelListenerMarker;
3366
3367    fn from_client(value: fidl::endpoints::ClientEnd<ChannelListenerMarker>) -> Self {
3368        Self::new(value.into_channel())
3369    }
3370}
3371
3372#[derive(Debug, Clone)]
3373pub struct ChannelListenerProxy {
3374    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3375}
3376
3377impl fidl::endpoints::Proxy for ChannelListenerProxy {
3378    type Protocol = ChannelListenerMarker;
3379
3380    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3381        Self::new(inner)
3382    }
3383
3384    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3385        self.client.into_channel().map_err(|client| Self { client })
3386    }
3387
3388    fn as_channel(&self) -> &::fidl::AsyncChannel {
3389        self.client.as_channel()
3390    }
3391}
3392
3393impl ChannelListenerProxy {
3394    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelListener.
3395    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3396        let protocol_name = <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3397        Self { client: fidl::client::Client::new(channel, protocol_name) }
3398    }
3399
3400    /// Get a Stream of events from the remote end of the protocol.
3401    ///
3402    /// # Panics
3403    ///
3404    /// Panics if the event stream was already taken.
3405    pub fn take_event_stream(&self) -> ChannelListenerEventStream {
3406        ChannelListenerEventStream { event_receiver: self.client.take_event_receiver() }
3407    }
3408
3409    pub fn r#accept(
3410        &self,
3411        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3412    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3413        ChannelListenerProxyInterface::r#accept(self, channel)
3414    }
3415
3416    /// Called for each successful incoming channel connection.
3417    pub fn r#connected(
3418        &self,
3419        mut payload: ChannelListenerConnectedRequest,
3420    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3421        ChannelListenerProxyInterface::r#connected(self, payload)
3422    }
3423}
3424
3425impl ChannelListenerProxyInterface for ChannelListenerProxy {
3426    type AcceptResponseFut =
3427        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3428    fn r#accept(
3429        &self,
3430        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3431    ) -> Self::AcceptResponseFut {
3432        fn _decode(
3433            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3434        ) -> Result<(), fidl::Error> {
3435            let _response = fidl::client::decode_transaction_body::<
3436                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3437                fidl::encoding::DefaultFuchsiaResourceDialect,
3438                0x6f535bd36b20fc7b,
3439            >(_buf?)?
3440            .into_result::<ChannelListenerMarker>("accept")?;
3441            Ok(_response)
3442        }
3443        self.client.send_query_and_decode::<ChannelListenerAcceptRequest, ()>(
3444            (channel,),
3445            0x6f535bd36b20fc7b,
3446            fidl::encoding::DynamicFlags::FLEXIBLE,
3447            _decode,
3448        )
3449    }
3450
3451    type ConnectedResponseFut =
3452        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3453    fn r#connected(
3454        &self,
3455        mut payload: ChannelListenerConnectedRequest,
3456    ) -> Self::ConnectedResponseFut {
3457        fn _decode(
3458            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3459        ) -> Result<(), fidl::Error> {
3460            let _response = fidl::client::decode_transaction_body::<
3461                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3462                fidl::encoding::DefaultFuchsiaResourceDialect,
3463                0xf40756858f21866,
3464            >(_buf?)?
3465            .into_result::<ChannelListenerMarker>("connected")?;
3466            Ok(_response)
3467        }
3468        self.client.send_query_and_decode::<ChannelListenerConnectedRequest, ()>(
3469            &mut payload,
3470            0xf40756858f21866,
3471            fidl::encoding::DynamicFlags::FLEXIBLE,
3472            _decode,
3473        )
3474    }
3475}
3476
3477pub struct ChannelListenerEventStream {
3478    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3479}
3480
3481impl std::marker::Unpin for ChannelListenerEventStream {}
3482
3483impl futures::stream::FusedStream for ChannelListenerEventStream {
3484    fn is_terminated(&self) -> bool {
3485        self.event_receiver.is_terminated()
3486    }
3487}
3488
3489impl futures::Stream for ChannelListenerEventStream {
3490    type Item = Result<ChannelListenerEvent, fidl::Error>;
3491
3492    fn poll_next(
3493        mut self: std::pin::Pin<&mut Self>,
3494        cx: &mut std::task::Context<'_>,
3495    ) -> std::task::Poll<Option<Self::Item>> {
3496        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3497            &mut self.event_receiver,
3498            cx
3499        )?) {
3500            Some(buf) => std::task::Poll::Ready(Some(ChannelListenerEvent::decode(buf))),
3501            None => std::task::Poll::Ready(None),
3502        }
3503    }
3504}
3505
3506#[derive(Debug)]
3507pub enum ChannelListenerEvent {
3508    #[non_exhaustive]
3509    _UnknownEvent {
3510        /// Ordinal of the event that was sent.
3511        ordinal: u64,
3512    },
3513}
3514
3515impl ChannelListenerEvent {
3516    /// Decodes a message buffer as a [`ChannelListenerEvent`].
3517    fn decode(
3518        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3519    ) -> Result<ChannelListenerEvent, fidl::Error> {
3520        let (bytes, _handles) = buf.split_mut();
3521        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3522        debug_assert_eq!(tx_header.tx_id, 0);
3523        match tx_header.ordinal {
3524            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3525                Ok(ChannelListenerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3526            }
3527            _ => Err(fidl::Error::UnknownOrdinal {
3528                ordinal: tx_header.ordinal,
3529                protocol_name:
3530                    <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3531            }),
3532        }
3533    }
3534}
3535
3536/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelListener.
3537pub struct ChannelListenerRequestStream {
3538    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3539    is_terminated: bool,
3540}
3541
3542impl std::marker::Unpin for ChannelListenerRequestStream {}
3543
3544impl futures::stream::FusedStream for ChannelListenerRequestStream {
3545    fn is_terminated(&self) -> bool {
3546        self.is_terminated
3547    }
3548}
3549
3550impl fidl::endpoints::RequestStream for ChannelListenerRequestStream {
3551    type Protocol = ChannelListenerMarker;
3552    type ControlHandle = ChannelListenerControlHandle;
3553
3554    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3555        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3556    }
3557
3558    fn control_handle(&self) -> Self::ControlHandle {
3559        ChannelListenerControlHandle { inner: self.inner.clone() }
3560    }
3561
3562    fn into_inner(
3563        self,
3564    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3565    {
3566        (self.inner, self.is_terminated)
3567    }
3568
3569    fn from_inner(
3570        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3571        is_terminated: bool,
3572    ) -> Self {
3573        Self { inner, is_terminated }
3574    }
3575}
3576
3577impl futures::Stream for ChannelListenerRequestStream {
3578    type Item = Result<ChannelListenerRequest, fidl::Error>;
3579
3580    fn poll_next(
3581        mut self: std::pin::Pin<&mut Self>,
3582        cx: &mut std::task::Context<'_>,
3583    ) -> std::task::Poll<Option<Self::Item>> {
3584        let this = &mut *self;
3585        if this.inner.check_shutdown(cx) {
3586            this.is_terminated = true;
3587            return std::task::Poll::Ready(None);
3588        }
3589        if this.is_terminated {
3590            panic!("polled ChannelListenerRequestStream after completion");
3591        }
3592        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3593            |bytes, handles| {
3594                match this.inner.channel().read_etc(cx, bytes, handles) {
3595                    std::task::Poll::Ready(Ok(())) => {}
3596                    std::task::Poll::Pending => return std::task::Poll::Pending,
3597                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3598                        this.is_terminated = true;
3599                        return std::task::Poll::Ready(None);
3600                    }
3601                    std::task::Poll::Ready(Err(e)) => {
3602                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3603                            e.into(),
3604                        ))));
3605                    }
3606                }
3607
3608                // A message has been received from the channel
3609                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3610
3611                std::task::Poll::Ready(Some(match header.ordinal {
3612                    0x6f535bd36b20fc7b => {
3613                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3614                        let mut req = fidl::new_empty!(
3615                            ChannelListenerAcceptRequest,
3616                            fidl::encoding::DefaultFuchsiaResourceDialect
3617                        );
3618                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
3619                        let control_handle =
3620                            ChannelListenerControlHandle { inner: this.inner.clone() };
3621                        Ok(ChannelListenerRequest::Accept {
3622                            channel: req.channel,
3623
3624                            responder: ChannelListenerAcceptResponder {
3625                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3626                                tx_id: header.tx_id,
3627                            },
3628                        })
3629                    }
3630                    0xf40756858f21866 => {
3631                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3632                        let mut req = fidl::new_empty!(
3633                            ChannelListenerConnectedRequest,
3634                            fidl::encoding::DefaultFuchsiaResourceDialect
3635                        );
3636                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerConnectedRequest>(&header, _body_bytes, handles, &mut req)?;
3637                        let control_handle =
3638                            ChannelListenerControlHandle { inner: this.inner.clone() };
3639                        Ok(ChannelListenerRequest::Connected {
3640                            payload: req,
3641                            responder: ChannelListenerConnectedResponder {
3642                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3643                                tx_id: header.tx_id,
3644                            },
3645                        })
3646                    }
3647                    _ if header.tx_id == 0
3648                        && header
3649                            .dynamic_flags()
3650                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3651                    {
3652                        Ok(ChannelListenerRequest::_UnknownMethod {
3653                            ordinal: header.ordinal,
3654                            control_handle: ChannelListenerControlHandle {
3655                                inner: this.inner.clone(),
3656                            },
3657                            method_type: fidl::MethodType::OneWay,
3658                        })
3659                    }
3660                    _ if header
3661                        .dynamic_flags()
3662                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3663                    {
3664                        this.inner.send_framework_err(
3665                            fidl::encoding::FrameworkErr::UnknownMethod,
3666                            header.tx_id,
3667                            header.ordinal,
3668                            header.dynamic_flags(),
3669                            (bytes, handles),
3670                        )?;
3671                        Ok(ChannelListenerRequest::_UnknownMethod {
3672                            ordinal: header.ordinal,
3673                            control_handle: ChannelListenerControlHandle {
3674                                inner: this.inner.clone(),
3675                            },
3676                            method_type: fidl::MethodType::TwoWay,
3677                        })
3678                    }
3679                    _ => Err(fidl::Error::UnknownOrdinal {
3680                        ordinal: header.ordinal,
3681                        protocol_name:
3682                            <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3683                    }),
3684                }))
3685            },
3686        )
3687    }
3688}
3689
3690/// Represents a service or protocol that accepts incoming channel requests.
3691/// Incoming channel requests for the associated PSM will be connected via this
3692/// protocol. Closing this protocol will also cease accepting any incoming
3693/// channel requests, but existing established channels will not be affected.
3694/// Additionally, once this protocol is closed the implementation is free to
3695/// reuse the PSM that was previously assigned for this instance.
3696#[derive(Debug)]
3697pub enum ChannelListenerRequest {
3698    Accept {
3699        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3700        responder: ChannelListenerAcceptResponder,
3701    },
3702    /// Called for each successful incoming channel connection.
3703    Connected {
3704        payload: ChannelListenerConnectedRequest,
3705        responder: ChannelListenerConnectedResponder,
3706    },
3707    /// An interaction was received which does not match any known method.
3708    #[non_exhaustive]
3709    _UnknownMethod {
3710        /// Ordinal of the method that was called.
3711        ordinal: u64,
3712        control_handle: ChannelListenerControlHandle,
3713        method_type: fidl::MethodType,
3714    },
3715}
3716
3717impl ChannelListenerRequest {
3718    #[allow(irrefutable_let_patterns)]
3719    pub fn into_accept(
3720        self,
3721    ) -> Option<(
3722        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3723        ChannelListenerAcceptResponder,
3724    )> {
3725        if let ChannelListenerRequest::Accept { channel, responder } = self {
3726            Some((channel, responder))
3727        } else {
3728            None
3729        }
3730    }
3731
3732    #[allow(irrefutable_let_patterns)]
3733    pub fn into_connected(
3734        self,
3735    ) -> Option<(ChannelListenerConnectedRequest, ChannelListenerConnectedResponder)> {
3736        if let ChannelListenerRequest::Connected { payload, responder } = self {
3737            Some((payload, responder))
3738        } else {
3739            None
3740        }
3741    }
3742
3743    /// Name of the method defined in FIDL
3744    pub fn method_name(&self) -> &'static str {
3745        match *self {
3746            ChannelListenerRequest::Accept { .. } => "accept",
3747            ChannelListenerRequest::Connected { .. } => "connected",
3748            ChannelListenerRequest::_UnknownMethod {
3749                method_type: fidl::MethodType::OneWay,
3750                ..
3751            } => "unknown one-way method",
3752            ChannelListenerRequest::_UnknownMethod {
3753                method_type: fidl::MethodType::TwoWay,
3754                ..
3755            } => "unknown two-way method",
3756        }
3757    }
3758}
3759
3760#[derive(Debug, Clone)]
3761pub struct ChannelListenerControlHandle {
3762    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3763}
3764
3765impl ChannelListenerControlHandle {
3766    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3767        self.inner.shutdown_with_epitaph(status.into())
3768    }
3769}
3770
3771impl fidl::endpoints::ControlHandle for ChannelListenerControlHandle {
3772    fn shutdown(&self) {
3773        self.inner.shutdown()
3774    }
3775
3776    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3777        self.inner.shutdown_with_epitaph(status)
3778    }
3779
3780    fn is_closed(&self) -> bool {
3781        self.inner.channel().is_closed()
3782    }
3783    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3784        self.inner.channel().on_closed()
3785    }
3786
3787    #[cfg(target_os = "fuchsia")]
3788    fn signal_peer(
3789        &self,
3790        clear_mask: zx::Signals,
3791        set_mask: zx::Signals,
3792    ) -> Result<(), zx_status::Status> {
3793        use fidl::Peered;
3794        self.inner.channel().signal_peer(clear_mask, set_mask)
3795    }
3796}
3797
3798impl ChannelListenerControlHandle {}
3799
3800#[must_use = "FIDL methods require a response to be sent"]
3801#[derive(Debug)]
3802pub struct ChannelListenerAcceptResponder {
3803    control_handle: std::mem::ManuallyDrop<ChannelListenerControlHandle>,
3804    tx_id: u32,
3805}
3806
3807/// Set the the channel to be shutdown (see [`ChannelListenerControlHandle::shutdown`])
3808/// if the responder is dropped without sending a response, so that the client
3809/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3810impl std::ops::Drop for ChannelListenerAcceptResponder {
3811    fn drop(&mut self) {
3812        self.control_handle.shutdown();
3813        // Safety: drops once, never accessed again
3814        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3815    }
3816}
3817
3818impl fidl::endpoints::Responder for ChannelListenerAcceptResponder {
3819    type ControlHandle = ChannelListenerControlHandle;
3820
3821    fn control_handle(&self) -> &ChannelListenerControlHandle {
3822        &self.control_handle
3823    }
3824
3825    fn drop_without_shutdown(mut self) {
3826        // Safety: drops once, never accessed again due to mem::forget
3827        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3828        // Prevent Drop from running (which would shut down the channel)
3829        std::mem::forget(self);
3830    }
3831}
3832
3833impl ChannelListenerAcceptResponder {
3834    /// Sends a response to the FIDL transaction.
3835    ///
3836    /// Sets the channel to shutdown if an error occurs.
3837    pub fn send(self) -> Result<(), fidl::Error> {
3838        let _result = self.send_raw();
3839        if _result.is_err() {
3840            self.control_handle.shutdown();
3841        }
3842        self.drop_without_shutdown();
3843        _result
3844    }
3845
3846    /// Similar to "send" but does not shutdown the channel if an error occurs.
3847    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3848        let _result = self.send_raw();
3849        self.drop_without_shutdown();
3850        _result
3851    }
3852
3853    fn send_raw(&self) -> Result<(), fidl::Error> {
3854        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3855            fidl::encoding::Flexible::new(()),
3856            self.tx_id,
3857            0x6f535bd36b20fc7b,
3858            fidl::encoding::DynamicFlags::FLEXIBLE,
3859        )
3860    }
3861}
3862
3863#[must_use = "FIDL methods require a response to be sent"]
3864#[derive(Debug)]
3865pub struct ChannelListenerConnectedResponder {
3866    control_handle: std::mem::ManuallyDrop<ChannelListenerControlHandle>,
3867    tx_id: u32,
3868}
3869
3870/// Set the the channel to be shutdown (see [`ChannelListenerControlHandle::shutdown`])
3871/// if the responder is dropped without sending a response, so that the client
3872/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3873impl std::ops::Drop for ChannelListenerConnectedResponder {
3874    fn drop(&mut self) {
3875        self.control_handle.shutdown();
3876        // Safety: drops once, never accessed again
3877        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3878    }
3879}
3880
3881impl fidl::endpoints::Responder for ChannelListenerConnectedResponder {
3882    type ControlHandle = ChannelListenerControlHandle;
3883
3884    fn control_handle(&self) -> &ChannelListenerControlHandle {
3885        &self.control_handle
3886    }
3887
3888    fn drop_without_shutdown(mut self) {
3889        // Safety: drops once, never accessed again due to mem::forget
3890        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3891        // Prevent Drop from running (which would shut down the channel)
3892        std::mem::forget(self);
3893    }
3894}
3895
3896impl ChannelListenerConnectedResponder {
3897    /// Sends a response to the FIDL transaction.
3898    ///
3899    /// Sets the channel to shutdown if an error occurs.
3900    pub fn send(self) -> Result<(), fidl::Error> {
3901        let _result = self.send_raw();
3902        if _result.is_err() {
3903            self.control_handle.shutdown();
3904        }
3905        self.drop_without_shutdown();
3906        _result
3907    }
3908
3909    /// Similar to "send" but does not shutdown the channel if an error occurs.
3910    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3911        let _result = self.send_raw();
3912        self.drop_without_shutdown();
3913        _result
3914    }
3915
3916    fn send_raw(&self) -> Result<(), fidl::Error> {
3917        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3918            fidl::encoding::Flexible::new(()),
3919            self.tx_id,
3920            0xf40756858f21866,
3921            fidl::encoding::DynamicFlags::FLEXIBLE,
3922        )
3923    }
3924}
3925
3926#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3927pub struct ChannelListenerRegistryMarker;
3928
3929impl fidl::endpoints::ProtocolMarker for ChannelListenerRegistryMarker {
3930    type Proxy = ChannelListenerRegistryProxy;
3931    type RequestStream = ChannelListenerRegistryRequestStream;
3932    #[cfg(target_os = "fuchsia")]
3933    type SynchronousProxy = ChannelListenerRegistrySynchronousProxy;
3934
3935    const DEBUG_NAME: &'static str = "(anonymous) ChannelListenerRegistry";
3936}
3937pub type ChannelListenerRegistryListenL2capResult =
3938    Result<ChannelListenerRegistryListenL2capResponse, i32>;
3939
3940pub trait ChannelListenerRegistryProxyInterface: Send + Sync {
3941    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
3942        + Send;
3943    fn r#listen_l2cap(
3944        &self,
3945        payload: ChannelListenerRegistryListenL2capRequest,
3946    ) -> Self::ListenL2capResponseFut;
3947}
3948#[derive(Debug)]
3949#[cfg(target_os = "fuchsia")]
3950pub struct ChannelListenerRegistrySynchronousProxy {
3951    client: fidl::client::sync::Client,
3952}
3953
3954#[cfg(target_os = "fuchsia")]
3955impl fidl::endpoints::SynchronousProxy for ChannelListenerRegistrySynchronousProxy {
3956    type Proxy = ChannelListenerRegistryProxy;
3957    type Protocol = ChannelListenerRegistryMarker;
3958
3959    fn from_channel(inner: fidl::Channel) -> Self {
3960        Self::new(inner)
3961    }
3962
3963    fn into_channel(self) -> fidl::Channel {
3964        self.client.into_channel()
3965    }
3966
3967    fn as_channel(&self) -> &fidl::Channel {
3968        self.client.as_channel()
3969    }
3970}
3971
3972#[cfg(target_os = "fuchsia")]
3973impl ChannelListenerRegistrySynchronousProxy {
3974    pub fn new(channel: fidl::Channel) -> Self {
3975        Self { client: fidl::client::sync::Client::new(channel) }
3976    }
3977
3978    pub fn into_channel(self) -> fidl::Channel {
3979        self.client.into_channel()
3980    }
3981
3982    /// Waits until an event arrives and returns it. It is safe for other
3983    /// threads to make concurrent requests while waiting for an event.
3984    pub fn wait_for_event(
3985        &self,
3986        deadline: zx::MonotonicInstant,
3987    ) -> Result<ChannelListenerRegistryEvent, fidl::Error> {
3988        ChannelListenerRegistryEvent::decode(
3989            self.client.wait_for_event::<ChannelListenerRegistryMarker>(deadline)?,
3990        )
3991    }
3992
3993    /// Register a listener for incoming channels. The registry will assign a
3994    /// PSM value that is unique for the local device, as well as open a
3995    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
3996    /// event that all PSMs have been assigned, this call will fail with
3997    /// `ZX_ERR_NO_RESOURCES`.
3998    ///
3999    /// Note that the method of service discovery or advertising is defined by
4000    /// the service or protocol, so it is the responsibility of the caller to
4001    /// communicate the assigned PSM to any clients.
4002    pub fn r#listen_l2cap(
4003        &self,
4004        mut payload: ChannelListenerRegistryListenL2capRequest,
4005        ___deadline: zx::MonotonicInstant,
4006    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
4007        let _response = self.client.send_query::<
4008            ChannelListenerRegistryListenL2capRequest,
4009            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
4010            ChannelListenerRegistryMarker,
4011        >(
4012            &mut payload,
4013            0x39c6e9001d102338,
4014            fidl::encoding::DynamicFlags::empty(),
4015            ___deadline,
4016        )?;
4017        Ok(_response.map(|x| x))
4018    }
4019}
4020
4021#[cfg(target_os = "fuchsia")]
4022impl From<ChannelListenerRegistrySynchronousProxy> for zx::NullableHandle {
4023    fn from(value: ChannelListenerRegistrySynchronousProxy) -> Self {
4024        value.into_channel().into()
4025    }
4026}
4027
4028#[cfg(target_os = "fuchsia")]
4029impl From<fidl::Channel> for ChannelListenerRegistrySynchronousProxy {
4030    fn from(value: fidl::Channel) -> Self {
4031        Self::new(value)
4032    }
4033}
4034
4035#[cfg(target_os = "fuchsia")]
4036impl fidl::endpoints::FromClient for ChannelListenerRegistrySynchronousProxy {
4037    type Protocol = ChannelListenerRegistryMarker;
4038
4039    fn from_client(value: fidl::endpoints::ClientEnd<ChannelListenerRegistryMarker>) -> Self {
4040        Self::new(value.into_channel())
4041    }
4042}
4043
4044#[derive(Debug, Clone)]
4045pub struct ChannelListenerRegistryProxy {
4046    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4047}
4048
4049impl fidl::endpoints::Proxy for ChannelListenerRegistryProxy {
4050    type Protocol = ChannelListenerRegistryMarker;
4051
4052    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4053        Self::new(inner)
4054    }
4055
4056    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4057        self.client.into_channel().map_err(|client| Self { client })
4058    }
4059
4060    fn as_channel(&self) -> &::fidl::AsyncChannel {
4061        self.client.as_channel()
4062    }
4063}
4064
4065impl ChannelListenerRegistryProxy {
4066    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelListenerRegistry.
4067    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4068        let protocol_name =
4069            <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4070        Self { client: fidl::client::Client::new(channel, protocol_name) }
4071    }
4072
4073    /// Get a Stream of events from the remote end of the protocol.
4074    ///
4075    /// # Panics
4076    ///
4077    /// Panics if the event stream was already taken.
4078    pub fn take_event_stream(&self) -> ChannelListenerRegistryEventStream {
4079        ChannelListenerRegistryEventStream { event_receiver: self.client.take_event_receiver() }
4080    }
4081
4082    /// Register a listener for incoming channels. The registry will assign a
4083    /// PSM value that is unique for the local device, as well as open a
4084    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
4085    /// event that all PSMs have been assigned, this call will fail with
4086    /// `ZX_ERR_NO_RESOURCES`.
4087    ///
4088    /// Note that the method of service discovery or advertising is defined by
4089    /// the service or protocol, so it is the responsibility of the caller to
4090    /// communicate the assigned PSM to any clients.
4091    pub fn r#listen_l2cap(
4092        &self,
4093        mut payload: ChannelListenerRegistryListenL2capRequest,
4094    ) -> fidl::client::QueryResponseFut<
4095        ChannelListenerRegistryListenL2capResult,
4096        fidl::encoding::DefaultFuchsiaResourceDialect,
4097    > {
4098        ChannelListenerRegistryProxyInterface::r#listen_l2cap(self, payload)
4099    }
4100}
4101
4102impl ChannelListenerRegistryProxyInterface for ChannelListenerRegistryProxy {
4103    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
4104        ChannelListenerRegistryListenL2capResult,
4105        fidl::encoding::DefaultFuchsiaResourceDialect,
4106    >;
4107    fn r#listen_l2cap(
4108        &self,
4109        mut payload: ChannelListenerRegistryListenL2capRequest,
4110    ) -> Self::ListenL2capResponseFut {
4111        fn _decode(
4112            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4113        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
4114            let _response = fidl::client::decode_transaction_body::<
4115                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
4116                fidl::encoding::DefaultFuchsiaResourceDialect,
4117                0x39c6e9001d102338,
4118            >(_buf?)?;
4119            Ok(_response.map(|x| x))
4120        }
4121        self.client.send_query_and_decode::<
4122            ChannelListenerRegistryListenL2capRequest,
4123            ChannelListenerRegistryListenL2capResult,
4124        >(
4125            &mut payload,
4126            0x39c6e9001d102338,
4127            fidl::encoding::DynamicFlags::empty(),
4128            _decode,
4129        )
4130    }
4131}
4132
4133pub struct ChannelListenerRegistryEventStream {
4134    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4135}
4136
4137impl std::marker::Unpin for ChannelListenerRegistryEventStream {}
4138
4139impl futures::stream::FusedStream for ChannelListenerRegistryEventStream {
4140    fn is_terminated(&self) -> bool {
4141        self.event_receiver.is_terminated()
4142    }
4143}
4144
4145impl futures::Stream for ChannelListenerRegistryEventStream {
4146    type Item = Result<ChannelListenerRegistryEvent, fidl::Error>;
4147
4148    fn poll_next(
4149        mut self: std::pin::Pin<&mut Self>,
4150        cx: &mut std::task::Context<'_>,
4151    ) -> std::task::Poll<Option<Self::Item>> {
4152        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4153            &mut self.event_receiver,
4154            cx
4155        )?) {
4156            Some(buf) => std::task::Poll::Ready(Some(ChannelListenerRegistryEvent::decode(buf))),
4157            None => std::task::Poll::Ready(None),
4158        }
4159    }
4160}
4161
4162#[derive(Debug)]
4163pub enum ChannelListenerRegistryEvent {}
4164
4165impl ChannelListenerRegistryEvent {
4166    /// Decodes a message buffer as a [`ChannelListenerRegistryEvent`].
4167    fn decode(
4168        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4169    ) -> Result<ChannelListenerRegistryEvent, fidl::Error> {
4170        let (bytes, _handles) = buf.split_mut();
4171        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4172        debug_assert_eq!(tx_header.tx_id, 0);
4173        match tx_header.ordinal {
4174            _ => Err(fidl::Error::UnknownOrdinal {
4175                ordinal: tx_header.ordinal,
4176                protocol_name:
4177                    <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4178            }),
4179        }
4180    }
4181}
4182
4183/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelListenerRegistry.
4184pub struct ChannelListenerRegistryRequestStream {
4185    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4186    is_terminated: bool,
4187}
4188
4189impl std::marker::Unpin for ChannelListenerRegistryRequestStream {}
4190
4191impl futures::stream::FusedStream for ChannelListenerRegistryRequestStream {
4192    fn is_terminated(&self) -> bool {
4193        self.is_terminated
4194    }
4195}
4196
4197impl fidl::endpoints::RequestStream for ChannelListenerRegistryRequestStream {
4198    type Protocol = ChannelListenerRegistryMarker;
4199    type ControlHandle = ChannelListenerRegistryControlHandle;
4200
4201    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4202        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4203    }
4204
4205    fn control_handle(&self) -> Self::ControlHandle {
4206        ChannelListenerRegistryControlHandle { inner: self.inner.clone() }
4207    }
4208
4209    fn into_inner(
4210        self,
4211    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4212    {
4213        (self.inner, self.is_terminated)
4214    }
4215
4216    fn from_inner(
4217        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4218        is_terminated: bool,
4219    ) -> Self {
4220        Self { inner, is_terminated }
4221    }
4222}
4223
4224impl futures::Stream for ChannelListenerRegistryRequestStream {
4225    type Item = Result<ChannelListenerRegistryRequest, fidl::Error>;
4226
4227    fn poll_next(
4228        mut self: std::pin::Pin<&mut Self>,
4229        cx: &mut std::task::Context<'_>,
4230    ) -> std::task::Poll<Option<Self::Item>> {
4231        let this = &mut *self;
4232        if this.inner.check_shutdown(cx) {
4233            this.is_terminated = true;
4234            return std::task::Poll::Ready(None);
4235        }
4236        if this.is_terminated {
4237            panic!("polled ChannelListenerRegistryRequestStream after completion");
4238        }
4239        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4240            |bytes, handles| {
4241                match this.inner.channel().read_etc(cx, bytes, handles) {
4242                    std::task::Poll::Ready(Ok(())) => {}
4243                    std::task::Poll::Pending => return std::task::Poll::Pending,
4244                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4245                        this.is_terminated = true;
4246                        return std::task::Poll::Ready(None);
4247                    }
4248                    std::task::Poll::Ready(Err(e)) => {
4249                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4250                            e.into(),
4251                        ))));
4252                    }
4253                }
4254
4255                // A message has been received from the channel
4256                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4257
4258                std::task::Poll::Ready(Some(match header.ordinal {
4259                0x39c6e9001d102338 => {
4260                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4261                    let mut req = fidl::new_empty!(ChannelListenerRegistryListenL2capRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4262                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
4263                    let control_handle = ChannelListenerRegistryControlHandle {
4264                        inner: this.inner.clone(),
4265                    };
4266                    Ok(ChannelListenerRegistryRequest::ListenL2cap {payload: req,
4267                        responder: ChannelListenerRegistryListenL2capResponder {
4268                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4269                            tx_id: header.tx_id,
4270                        },
4271                    })
4272                }
4273                _ => Err(fidl::Error::UnknownOrdinal {
4274                    ordinal: header.ordinal,
4275                    protocol_name: <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4276                }),
4277            }))
4278            },
4279        )
4280    }
4281}
4282
4283/// Represents the ability to register and accept incoming connections on
4284/// connection oriented channels.
4285#[derive(Debug)]
4286pub enum ChannelListenerRegistryRequest {
4287    /// Register a listener for incoming channels. The registry will assign a
4288    /// PSM value that is unique for the local device, as well as open a
4289    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
4290    /// event that all PSMs have been assigned, this call will fail with
4291    /// `ZX_ERR_NO_RESOURCES`.
4292    ///
4293    /// Note that the method of service discovery or advertising is defined by
4294    /// the service or protocol, so it is the responsibility of the caller to
4295    /// communicate the assigned PSM to any clients.
4296    ListenL2cap {
4297        payload: ChannelListenerRegistryListenL2capRequest,
4298        responder: ChannelListenerRegistryListenL2capResponder,
4299    },
4300}
4301
4302impl ChannelListenerRegistryRequest {
4303    #[allow(irrefutable_let_patterns)]
4304    pub fn into_listen_l2cap(
4305        self,
4306    ) -> Option<(
4307        ChannelListenerRegistryListenL2capRequest,
4308        ChannelListenerRegistryListenL2capResponder,
4309    )> {
4310        if let ChannelListenerRegistryRequest::ListenL2cap { payload, responder } = self {
4311            Some((payload, responder))
4312        } else {
4313            None
4314        }
4315    }
4316
4317    /// Name of the method defined in FIDL
4318    pub fn method_name(&self) -> &'static str {
4319        match *self {
4320            ChannelListenerRegistryRequest::ListenL2cap { .. } => "listen_l2cap",
4321        }
4322    }
4323}
4324
4325#[derive(Debug, Clone)]
4326pub struct ChannelListenerRegistryControlHandle {
4327    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4328}
4329
4330impl ChannelListenerRegistryControlHandle {
4331    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4332        self.inner.shutdown_with_epitaph(status.into())
4333    }
4334}
4335
4336impl fidl::endpoints::ControlHandle for ChannelListenerRegistryControlHandle {
4337    fn shutdown(&self) {
4338        self.inner.shutdown()
4339    }
4340
4341    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4342        self.inner.shutdown_with_epitaph(status)
4343    }
4344
4345    fn is_closed(&self) -> bool {
4346        self.inner.channel().is_closed()
4347    }
4348    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4349        self.inner.channel().on_closed()
4350    }
4351
4352    #[cfg(target_os = "fuchsia")]
4353    fn signal_peer(
4354        &self,
4355        clear_mask: zx::Signals,
4356        set_mask: zx::Signals,
4357    ) -> Result<(), zx_status::Status> {
4358        use fidl::Peered;
4359        self.inner.channel().signal_peer(clear_mask, set_mask)
4360    }
4361}
4362
4363impl ChannelListenerRegistryControlHandle {}
4364
4365#[must_use = "FIDL methods require a response to be sent"]
4366#[derive(Debug)]
4367pub struct ChannelListenerRegistryListenL2capResponder {
4368    control_handle: std::mem::ManuallyDrop<ChannelListenerRegistryControlHandle>,
4369    tx_id: u32,
4370}
4371
4372/// Set the the channel to be shutdown (see [`ChannelListenerRegistryControlHandle::shutdown`])
4373/// if the responder is dropped without sending a response, so that the client
4374/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4375impl std::ops::Drop for ChannelListenerRegistryListenL2capResponder {
4376    fn drop(&mut self) {
4377        self.control_handle.shutdown();
4378        // Safety: drops once, never accessed again
4379        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4380    }
4381}
4382
4383impl fidl::endpoints::Responder for ChannelListenerRegistryListenL2capResponder {
4384    type ControlHandle = ChannelListenerRegistryControlHandle;
4385
4386    fn control_handle(&self) -> &ChannelListenerRegistryControlHandle {
4387        &self.control_handle
4388    }
4389
4390    fn drop_without_shutdown(mut self) {
4391        // Safety: drops once, never accessed again due to mem::forget
4392        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4393        // Prevent Drop from running (which would shut down the channel)
4394        std::mem::forget(self);
4395    }
4396}
4397
4398impl ChannelListenerRegistryListenL2capResponder {
4399    /// Sends a response to the FIDL transaction.
4400    ///
4401    /// Sets the channel to shutdown if an error occurs.
4402    pub fn send(
4403        self,
4404        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4405    ) -> Result<(), fidl::Error> {
4406        let _result = self.send_raw(result);
4407        if _result.is_err() {
4408            self.control_handle.shutdown();
4409        }
4410        self.drop_without_shutdown();
4411        _result
4412    }
4413
4414    /// Similar to "send" but does not shutdown the channel if an error occurs.
4415    pub fn send_no_shutdown_on_err(
4416        self,
4417        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4418    ) -> Result<(), fidl::Error> {
4419        let _result = self.send_raw(result);
4420        self.drop_without_shutdown();
4421        _result
4422    }
4423
4424    fn send_raw(
4425        &self,
4426        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4427    ) -> Result<(), fidl::Error> {
4428        self.control_handle.inner.send::<fidl::encoding::ResultType<
4429            ChannelListenerRegistryListenL2capResponse,
4430            i32,
4431        >>(
4432            result,
4433            self.tx_id,
4434            0x39c6e9001d102338,
4435            fidl::encoding::DynamicFlags::empty(),
4436        )
4437    }
4438}
4439
4440#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4441pub struct ChannelOffloadExtMarker;
4442
4443impl fidl::endpoints::ProtocolMarker for ChannelOffloadExtMarker {
4444    type Proxy = ChannelOffloadExtProxy;
4445    type RequestStream = ChannelOffloadExtRequestStream;
4446    #[cfg(target_os = "fuchsia")]
4447    type SynchronousProxy = ChannelOffloadExtSynchronousProxy;
4448
4449    const DEBUG_NAME: &'static str = "(anonymous) ChannelOffloadExt";
4450}
4451pub type ChannelOffloadExtStartOffloadResult = Result<ChannelOffloadExtStartOffloadResponse, i32>;
4452
4453pub trait ChannelOffloadExtProxyInterface: Send + Sync {
4454    type StartOffloadResponseFut: std::future::Future<Output = Result<ChannelOffloadExtStartOffloadResult, fidl::Error>>
4455        + Send;
4456    fn r#start_offload(
4457        &self,
4458        payload: &ChannelOffloadExtStartOffloadRequest,
4459    ) -> Self::StartOffloadResponseFut;
4460}
4461#[derive(Debug)]
4462#[cfg(target_os = "fuchsia")]
4463pub struct ChannelOffloadExtSynchronousProxy {
4464    client: fidl::client::sync::Client,
4465}
4466
4467#[cfg(target_os = "fuchsia")]
4468impl fidl::endpoints::SynchronousProxy for ChannelOffloadExtSynchronousProxy {
4469    type Proxy = ChannelOffloadExtProxy;
4470    type Protocol = ChannelOffloadExtMarker;
4471
4472    fn from_channel(inner: fidl::Channel) -> Self {
4473        Self::new(inner)
4474    }
4475
4476    fn into_channel(self) -> fidl::Channel {
4477        self.client.into_channel()
4478    }
4479
4480    fn as_channel(&self) -> &fidl::Channel {
4481        self.client.as_channel()
4482    }
4483}
4484
4485#[cfg(target_os = "fuchsia")]
4486impl ChannelOffloadExtSynchronousProxy {
4487    pub fn new(channel: fidl::Channel) -> Self {
4488        Self { client: fidl::client::sync::Client::new(channel) }
4489    }
4490
4491    pub fn into_channel(self) -> fidl::Channel {
4492        self.client.into_channel()
4493    }
4494
4495    /// Waits until an event arrives and returns it. It is safe for other
4496    /// threads to make concurrent requests while waiting for an event.
4497    pub fn wait_for_event(
4498        &self,
4499        deadline: zx::MonotonicInstant,
4500    ) -> Result<ChannelOffloadExtEvent, fidl::Error> {
4501        ChannelOffloadExtEvent::decode(
4502            self.client.wait_for_event::<ChannelOffloadExtMarker>(deadline)?,
4503        )
4504    }
4505
4506    /// StartOffload MUST be called before Channel.Receive(). The offloaded
4507    /// channel will have 0 RX credits given to the peer to prevent the peer
4508    /// from sending data until the offload processor is ready. This method may
4509    /// be called a maximum of one time.
4510    ///
4511    /// The following errors may be returned:
4512    /// * error `BAD_STATE` : Channel.Receive() has already been called or
4513    ///     StartOffload() has already been called.
4514    /// * error `INTERNAL`: An internal error occurred and the channel could not be offloaded.
4515    pub fn r#start_offload(
4516        &self,
4517        mut payload: &ChannelOffloadExtStartOffloadRequest,
4518        ___deadline: zx::MonotonicInstant,
4519    ) -> Result<ChannelOffloadExtStartOffloadResult, fidl::Error> {
4520        let _response = self.client.send_query::<
4521            ChannelOffloadExtStartOffloadRequest,
4522            fidl::encoding::FlexibleResultType<ChannelOffloadExtStartOffloadResponse, i32>,
4523            ChannelOffloadExtMarker,
4524        >(
4525            payload,
4526            0x2dd620feea793fe8,
4527            fidl::encoding::DynamicFlags::FLEXIBLE,
4528            ___deadline,
4529        )?
4530        .into_result::<ChannelOffloadExtMarker>("start_offload")?;
4531        Ok(_response.map(|x| x))
4532    }
4533}
4534
4535#[cfg(target_os = "fuchsia")]
4536impl From<ChannelOffloadExtSynchronousProxy> for zx::NullableHandle {
4537    fn from(value: ChannelOffloadExtSynchronousProxy) -> Self {
4538        value.into_channel().into()
4539    }
4540}
4541
4542#[cfg(target_os = "fuchsia")]
4543impl From<fidl::Channel> for ChannelOffloadExtSynchronousProxy {
4544    fn from(value: fidl::Channel) -> Self {
4545        Self::new(value)
4546    }
4547}
4548
4549#[cfg(target_os = "fuchsia")]
4550impl fidl::endpoints::FromClient for ChannelOffloadExtSynchronousProxy {
4551    type Protocol = ChannelOffloadExtMarker;
4552
4553    fn from_client(value: fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>) -> Self {
4554        Self::new(value.into_channel())
4555    }
4556}
4557
4558#[derive(Debug, Clone)]
4559pub struct ChannelOffloadExtProxy {
4560    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4561}
4562
4563impl fidl::endpoints::Proxy for ChannelOffloadExtProxy {
4564    type Protocol = ChannelOffloadExtMarker;
4565
4566    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4567        Self::new(inner)
4568    }
4569
4570    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4571        self.client.into_channel().map_err(|client| Self { client })
4572    }
4573
4574    fn as_channel(&self) -> &::fidl::AsyncChannel {
4575        self.client.as_channel()
4576    }
4577}
4578
4579impl ChannelOffloadExtProxy {
4580    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelOffloadExt.
4581    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4582        let protocol_name =
4583            <ChannelOffloadExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4584        Self { client: fidl::client::Client::new(channel, protocol_name) }
4585    }
4586
4587    /// Get a Stream of events from the remote end of the protocol.
4588    ///
4589    /// # Panics
4590    ///
4591    /// Panics if the event stream was already taken.
4592    pub fn take_event_stream(&self) -> ChannelOffloadExtEventStream {
4593        ChannelOffloadExtEventStream { event_receiver: self.client.take_event_receiver() }
4594    }
4595
4596    /// StartOffload MUST be called before Channel.Receive(). The offloaded
4597    /// channel will have 0 RX credits given to the peer to prevent the peer
4598    /// from sending data until the offload processor is ready. This method may
4599    /// be called a maximum of one time.
4600    ///
4601    /// The following errors may be returned:
4602    /// * error `BAD_STATE` : Channel.Receive() has already been called or
4603    ///     StartOffload() has already been called.
4604    /// * error `INTERNAL`: An internal error occurred and the channel could not be offloaded.
4605    pub fn r#start_offload(
4606        &self,
4607        mut payload: &ChannelOffloadExtStartOffloadRequest,
4608    ) -> fidl::client::QueryResponseFut<
4609        ChannelOffloadExtStartOffloadResult,
4610        fidl::encoding::DefaultFuchsiaResourceDialect,
4611    > {
4612        ChannelOffloadExtProxyInterface::r#start_offload(self, payload)
4613    }
4614}
4615
4616impl ChannelOffloadExtProxyInterface for ChannelOffloadExtProxy {
4617    type StartOffloadResponseFut = fidl::client::QueryResponseFut<
4618        ChannelOffloadExtStartOffloadResult,
4619        fidl::encoding::DefaultFuchsiaResourceDialect,
4620    >;
4621    fn r#start_offload(
4622        &self,
4623        mut payload: &ChannelOffloadExtStartOffloadRequest,
4624    ) -> Self::StartOffloadResponseFut {
4625        fn _decode(
4626            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4627        ) -> Result<ChannelOffloadExtStartOffloadResult, fidl::Error> {
4628            let _response = fidl::client::decode_transaction_body::<
4629                fidl::encoding::FlexibleResultType<ChannelOffloadExtStartOffloadResponse, i32>,
4630                fidl::encoding::DefaultFuchsiaResourceDialect,
4631                0x2dd620feea793fe8,
4632            >(_buf?)?
4633            .into_result::<ChannelOffloadExtMarker>("start_offload")?;
4634            Ok(_response.map(|x| x))
4635        }
4636        self.client.send_query_and_decode::<
4637            ChannelOffloadExtStartOffloadRequest,
4638            ChannelOffloadExtStartOffloadResult,
4639        >(
4640            payload,
4641            0x2dd620feea793fe8,
4642            fidl::encoding::DynamicFlags::FLEXIBLE,
4643            _decode,
4644        )
4645    }
4646}
4647
4648pub struct ChannelOffloadExtEventStream {
4649    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4650}
4651
4652impl std::marker::Unpin for ChannelOffloadExtEventStream {}
4653
4654impl futures::stream::FusedStream for ChannelOffloadExtEventStream {
4655    fn is_terminated(&self) -> bool {
4656        self.event_receiver.is_terminated()
4657    }
4658}
4659
4660impl futures::Stream for ChannelOffloadExtEventStream {
4661    type Item = Result<ChannelOffloadExtEvent, fidl::Error>;
4662
4663    fn poll_next(
4664        mut self: std::pin::Pin<&mut Self>,
4665        cx: &mut std::task::Context<'_>,
4666    ) -> std::task::Poll<Option<Self::Item>> {
4667        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4668            &mut self.event_receiver,
4669            cx
4670        )?) {
4671            Some(buf) => std::task::Poll::Ready(Some(ChannelOffloadExtEvent::decode(buf))),
4672            None => std::task::Poll::Ready(None),
4673        }
4674    }
4675}
4676
4677#[derive(Debug)]
4678pub enum ChannelOffloadExtEvent {
4679    #[non_exhaustive]
4680    _UnknownEvent {
4681        /// Ordinal of the event that was sent.
4682        ordinal: u64,
4683    },
4684}
4685
4686impl ChannelOffloadExtEvent {
4687    /// Decodes a message buffer as a [`ChannelOffloadExtEvent`].
4688    fn decode(
4689        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4690    ) -> Result<ChannelOffloadExtEvent, fidl::Error> {
4691        let (bytes, _handles) = buf.split_mut();
4692        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4693        debug_assert_eq!(tx_header.tx_id, 0);
4694        match tx_header.ordinal {
4695            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4696                Ok(ChannelOffloadExtEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4697            }
4698            _ => Err(fidl::Error::UnknownOrdinal {
4699                ordinal: tx_header.ordinal,
4700                protocol_name:
4701                    <ChannelOffloadExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4702            }),
4703        }
4704    }
4705}
4706
4707/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelOffloadExt.
4708pub struct ChannelOffloadExtRequestStream {
4709    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4710    is_terminated: bool,
4711}
4712
4713impl std::marker::Unpin for ChannelOffloadExtRequestStream {}
4714
4715impl futures::stream::FusedStream for ChannelOffloadExtRequestStream {
4716    fn is_terminated(&self) -> bool {
4717        self.is_terminated
4718    }
4719}
4720
4721impl fidl::endpoints::RequestStream for ChannelOffloadExtRequestStream {
4722    type Protocol = ChannelOffloadExtMarker;
4723    type ControlHandle = ChannelOffloadExtControlHandle;
4724
4725    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4726        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4727    }
4728
4729    fn control_handle(&self) -> Self::ControlHandle {
4730        ChannelOffloadExtControlHandle { inner: self.inner.clone() }
4731    }
4732
4733    fn into_inner(
4734        self,
4735    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4736    {
4737        (self.inner, self.is_terminated)
4738    }
4739
4740    fn from_inner(
4741        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4742        is_terminated: bool,
4743    ) -> Self {
4744        Self { inner, is_terminated }
4745    }
4746}
4747
4748impl futures::Stream for ChannelOffloadExtRequestStream {
4749    type Item = Result<ChannelOffloadExtRequest, fidl::Error>;
4750
4751    fn poll_next(
4752        mut self: std::pin::Pin<&mut Self>,
4753        cx: &mut std::task::Context<'_>,
4754    ) -> std::task::Poll<Option<Self::Item>> {
4755        let this = &mut *self;
4756        if this.inner.check_shutdown(cx) {
4757            this.is_terminated = true;
4758            return std::task::Poll::Ready(None);
4759        }
4760        if this.is_terminated {
4761            panic!("polled ChannelOffloadExtRequestStream after completion");
4762        }
4763        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4764            |bytes, handles| {
4765                match this.inner.channel().read_etc(cx, bytes, handles) {
4766                    std::task::Poll::Ready(Ok(())) => {}
4767                    std::task::Poll::Pending => return std::task::Poll::Pending,
4768                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4769                        this.is_terminated = true;
4770                        return std::task::Poll::Ready(None);
4771                    }
4772                    std::task::Poll::Ready(Err(e)) => {
4773                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4774                            e.into(),
4775                        ))));
4776                    }
4777                }
4778
4779                // A message has been received from the channel
4780                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4781
4782                std::task::Poll::Ready(Some(match header.ordinal {
4783                    0x2dd620feea793fe8 => {
4784                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4785                        let mut req = fidl::new_empty!(
4786                            ChannelOffloadExtStartOffloadRequest,
4787                            fidl::encoding::DefaultFuchsiaResourceDialect
4788                        );
4789                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelOffloadExtStartOffloadRequest>(&header, _body_bytes, handles, &mut req)?;
4790                        let control_handle =
4791                            ChannelOffloadExtControlHandle { inner: this.inner.clone() };
4792                        Ok(ChannelOffloadExtRequest::StartOffload {
4793                            payload: req,
4794                            responder: ChannelOffloadExtStartOffloadResponder {
4795                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4796                                tx_id: header.tx_id,
4797                            },
4798                        })
4799                    }
4800                    _ if header.tx_id == 0
4801                        && header
4802                            .dynamic_flags()
4803                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4804                    {
4805                        Ok(ChannelOffloadExtRequest::_UnknownMethod {
4806                            ordinal: header.ordinal,
4807                            control_handle: ChannelOffloadExtControlHandle {
4808                                inner: this.inner.clone(),
4809                            },
4810                            method_type: fidl::MethodType::OneWay,
4811                        })
4812                    }
4813                    _ if header
4814                        .dynamic_flags()
4815                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4816                    {
4817                        this.inner.send_framework_err(
4818                            fidl::encoding::FrameworkErr::UnknownMethod,
4819                            header.tx_id,
4820                            header.ordinal,
4821                            header.dynamic_flags(),
4822                            (bytes, handles),
4823                        )?;
4824                        Ok(ChannelOffloadExtRequest::_UnknownMethod {
4825                            ordinal: header.ordinal,
4826                            control_handle: ChannelOffloadExtControlHandle {
4827                                inner: this.inner.clone(),
4828                            },
4829                            method_type: fidl::MethodType::TwoWay,
4830                        })
4831                    }
4832                    _ => Err(fidl::Error::UnknownOrdinal {
4833                        ordinal: header.ordinal,
4834                        protocol_name:
4835                            <ChannelOffloadExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4836                    }),
4837                }))
4838            },
4839        )
4840    }
4841}
4842
4843/// Protocol extension for a `bt.Channel`. This is typically provided by or to
4844/// privileged clients alongside a `bt.Channel`. This protocol can be closed
4845/// before or after StartOffload has returned with no effect.
4846#[derive(Debug)]
4847pub enum ChannelOffloadExtRequest {
4848    /// StartOffload MUST be called before Channel.Receive(). The offloaded
4849    /// channel will have 0 RX credits given to the peer to prevent the peer
4850    /// from sending data until the offload processor is ready. This method may
4851    /// be called a maximum of one time.
4852    ///
4853    /// The following errors may be returned:
4854    /// * error `BAD_STATE` : Channel.Receive() has already been called or
4855    ///     StartOffload() has already been called.
4856    /// * error `INTERNAL`: An internal error occurred and the channel could not be offloaded.
4857    StartOffload {
4858        payload: ChannelOffloadExtStartOffloadRequest,
4859        responder: ChannelOffloadExtStartOffloadResponder,
4860    },
4861    /// An interaction was received which does not match any known method.
4862    #[non_exhaustive]
4863    _UnknownMethod {
4864        /// Ordinal of the method that was called.
4865        ordinal: u64,
4866        control_handle: ChannelOffloadExtControlHandle,
4867        method_type: fidl::MethodType,
4868    },
4869}
4870
4871impl ChannelOffloadExtRequest {
4872    #[allow(irrefutable_let_patterns)]
4873    pub fn into_start_offload(
4874        self,
4875    ) -> Option<(ChannelOffloadExtStartOffloadRequest, ChannelOffloadExtStartOffloadResponder)>
4876    {
4877        if let ChannelOffloadExtRequest::StartOffload { payload, responder } = self {
4878            Some((payload, responder))
4879        } else {
4880            None
4881        }
4882    }
4883
4884    /// Name of the method defined in FIDL
4885    pub fn method_name(&self) -> &'static str {
4886        match *self {
4887            ChannelOffloadExtRequest::StartOffload { .. } => "start_offload",
4888            ChannelOffloadExtRequest::_UnknownMethod {
4889                method_type: fidl::MethodType::OneWay,
4890                ..
4891            } => "unknown one-way method",
4892            ChannelOffloadExtRequest::_UnknownMethod {
4893                method_type: fidl::MethodType::TwoWay,
4894                ..
4895            } => "unknown two-way method",
4896        }
4897    }
4898}
4899
4900#[derive(Debug, Clone)]
4901pub struct ChannelOffloadExtControlHandle {
4902    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4903}
4904
4905impl ChannelOffloadExtControlHandle {
4906    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4907        self.inner.shutdown_with_epitaph(status.into())
4908    }
4909}
4910
4911impl fidl::endpoints::ControlHandle for ChannelOffloadExtControlHandle {
4912    fn shutdown(&self) {
4913        self.inner.shutdown()
4914    }
4915
4916    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4917        self.inner.shutdown_with_epitaph(status)
4918    }
4919
4920    fn is_closed(&self) -> bool {
4921        self.inner.channel().is_closed()
4922    }
4923    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4924        self.inner.channel().on_closed()
4925    }
4926
4927    #[cfg(target_os = "fuchsia")]
4928    fn signal_peer(
4929        &self,
4930        clear_mask: zx::Signals,
4931        set_mask: zx::Signals,
4932    ) -> Result<(), zx_status::Status> {
4933        use fidl::Peered;
4934        self.inner.channel().signal_peer(clear_mask, set_mask)
4935    }
4936}
4937
4938impl ChannelOffloadExtControlHandle {}
4939
4940#[must_use = "FIDL methods require a response to be sent"]
4941#[derive(Debug)]
4942pub struct ChannelOffloadExtStartOffloadResponder {
4943    control_handle: std::mem::ManuallyDrop<ChannelOffloadExtControlHandle>,
4944    tx_id: u32,
4945}
4946
4947/// Set the the channel to be shutdown (see [`ChannelOffloadExtControlHandle::shutdown`])
4948/// if the responder is dropped without sending a response, so that the client
4949/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4950impl std::ops::Drop for ChannelOffloadExtStartOffloadResponder {
4951    fn drop(&mut self) {
4952        self.control_handle.shutdown();
4953        // Safety: drops once, never accessed again
4954        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4955    }
4956}
4957
4958impl fidl::endpoints::Responder for ChannelOffloadExtStartOffloadResponder {
4959    type ControlHandle = ChannelOffloadExtControlHandle;
4960
4961    fn control_handle(&self) -> &ChannelOffloadExtControlHandle {
4962        &self.control_handle
4963    }
4964
4965    fn drop_without_shutdown(mut self) {
4966        // Safety: drops once, never accessed again due to mem::forget
4967        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4968        // Prevent Drop from running (which would shut down the channel)
4969        std::mem::forget(self);
4970    }
4971}
4972
4973impl ChannelOffloadExtStartOffloadResponder {
4974    /// Sends a response to the FIDL transaction.
4975    ///
4976    /// Sets the channel to shutdown if an error occurs.
4977    pub fn send(
4978        self,
4979        mut result: Result<&ChannelOffloadExtStartOffloadResponse, i32>,
4980    ) -> Result<(), fidl::Error> {
4981        let _result = self.send_raw(result);
4982        if _result.is_err() {
4983            self.control_handle.shutdown();
4984        }
4985        self.drop_without_shutdown();
4986        _result
4987    }
4988
4989    /// Similar to "send" but does not shutdown the channel if an error occurs.
4990    pub fn send_no_shutdown_on_err(
4991        self,
4992        mut result: Result<&ChannelOffloadExtStartOffloadResponse, i32>,
4993    ) -> Result<(), fidl::Error> {
4994        let _result = self.send_raw(result);
4995        self.drop_without_shutdown();
4996        _result
4997    }
4998
4999    fn send_raw(
5000        &self,
5001        mut result: Result<&ChannelOffloadExtStartOffloadResponse, i32>,
5002    ) -> Result<(), fidl::Error> {
5003        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5004            ChannelOffloadExtStartOffloadResponse,
5005            i32,
5006        >>(
5007            fidl::encoding::FlexibleResult::new(result),
5008            self.tx_id,
5009            0x2dd620feea793fe8,
5010            fidl::encoding::DynamicFlags::FLEXIBLE,
5011        )
5012    }
5013}
5014
5015#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5016pub struct CodecDelayMarker;
5017
5018impl fidl::endpoints::ProtocolMarker for CodecDelayMarker {
5019    type Proxy = CodecDelayProxy;
5020    type RequestStream = CodecDelayRequestStream;
5021    #[cfg(target_os = "fuchsia")]
5022    type SynchronousProxy = CodecDelaySynchronousProxy;
5023
5024    const DEBUG_NAME: &'static str = "(anonymous) CodecDelay";
5025}
5026pub type CodecDelayGetCodecLocalDelayRangeResult =
5027    Result<CodecDelayGetCodecLocalDelayRangeResponse, i32>;
5028
5029pub trait CodecDelayProxyInterface: Send + Sync {
5030    type GetCodecLocalDelayRangeResponseFut: std::future::Future<Output = Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error>>
5031        + Send;
5032    fn r#get_codec_local_delay_range(
5033        &self,
5034        payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5035    ) -> Self::GetCodecLocalDelayRangeResponseFut;
5036}
5037#[derive(Debug)]
5038#[cfg(target_os = "fuchsia")]
5039pub struct CodecDelaySynchronousProxy {
5040    client: fidl::client::sync::Client,
5041}
5042
5043#[cfg(target_os = "fuchsia")]
5044impl fidl::endpoints::SynchronousProxy for CodecDelaySynchronousProxy {
5045    type Proxy = CodecDelayProxy;
5046    type Protocol = CodecDelayMarker;
5047
5048    fn from_channel(inner: fidl::Channel) -> Self {
5049        Self::new(inner)
5050    }
5051
5052    fn into_channel(self) -> fidl::Channel {
5053        self.client.into_channel()
5054    }
5055
5056    fn as_channel(&self) -> &fidl::Channel {
5057        self.client.as_channel()
5058    }
5059}
5060
5061#[cfg(target_os = "fuchsia")]
5062impl CodecDelaySynchronousProxy {
5063    pub fn new(channel: fidl::Channel) -> Self {
5064        Self { client: fidl::client::sync::Client::new(channel) }
5065    }
5066
5067    pub fn into_channel(self) -> fidl::Channel {
5068        self.client.into_channel()
5069    }
5070
5071    /// Waits until an event arrives and returns it. It is safe for other
5072    /// threads to make concurrent requests while waiting for an event.
5073    pub fn wait_for_event(
5074        &self,
5075        deadline: zx::MonotonicInstant,
5076    ) -> Result<CodecDelayEvent, fidl::Error> {
5077        CodecDelayEvent::decode(self.client.wait_for_event::<CodecDelayMarker>(deadline)?)
5078    }
5079
5080    /// Retrieve the range of controller delay for the codec specified with the provided stream
5081    /// attributes.
5082    ///
5083    /// On success, returns the minimum and maximum allowed delay.
5084    ///
5085    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5086    /// Returns ZX_ERR_INTERNAL for all other failures.
5087    pub fn r#get_codec_local_delay_range(
5088        &self,
5089        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5090        ___deadline: zx::MonotonicInstant,
5091    ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
5092        let _response = self.client.send_query::<
5093            CodecDelayGetCodecLocalDelayRangeRequest,
5094            fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5095            CodecDelayMarker,
5096        >(
5097            payload,
5098            0x1cf34fdeed80b4d,
5099            fidl::encoding::DynamicFlags::empty(),
5100            ___deadline,
5101        )?;
5102        Ok(_response.map(|x| x))
5103    }
5104}
5105
5106#[cfg(target_os = "fuchsia")]
5107impl From<CodecDelaySynchronousProxy> for zx::NullableHandle {
5108    fn from(value: CodecDelaySynchronousProxy) -> Self {
5109        value.into_channel().into()
5110    }
5111}
5112
5113#[cfg(target_os = "fuchsia")]
5114impl From<fidl::Channel> for CodecDelaySynchronousProxy {
5115    fn from(value: fidl::Channel) -> Self {
5116        Self::new(value)
5117    }
5118}
5119
5120#[cfg(target_os = "fuchsia")]
5121impl fidl::endpoints::FromClient for CodecDelaySynchronousProxy {
5122    type Protocol = CodecDelayMarker;
5123
5124    fn from_client(value: fidl::endpoints::ClientEnd<CodecDelayMarker>) -> Self {
5125        Self::new(value.into_channel())
5126    }
5127}
5128
5129#[derive(Debug, Clone)]
5130pub struct CodecDelayProxy {
5131    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5132}
5133
5134impl fidl::endpoints::Proxy for CodecDelayProxy {
5135    type Protocol = CodecDelayMarker;
5136
5137    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5138        Self::new(inner)
5139    }
5140
5141    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5142        self.client.into_channel().map_err(|client| Self { client })
5143    }
5144
5145    fn as_channel(&self) -> &::fidl::AsyncChannel {
5146        self.client.as_channel()
5147    }
5148}
5149
5150impl CodecDelayProxy {
5151    /// Create a new Proxy for fuchsia.bluetooth.le/CodecDelay.
5152    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5153        let protocol_name = <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5154        Self { client: fidl::client::Client::new(channel, protocol_name) }
5155    }
5156
5157    /// Get a Stream of events from the remote end of the protocol.
5158    ///
5159    /// # Panics
5160    ///
5161    /// Panics if the event stream was already taken.
5162    pub fn take_event_stream(&self) -> CodecDelayEventStream {
5163        CodecDelayEventStream { event_receiver: self.client.take_event_receiver() }
5164    }
5165
5166    /// Retrieve the range of controller delay for the codec specified with the provided stream
5167    /// attributes.
5168    ///
5169    /// On success, returns the minimum and maximum allowed delay.
5170    ///
5171    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5172    /// Returns ZX_ERR_INTERNAL for all other failures.
5173    pub fn r#get_codec_local_delay_range(
5174        &self,
5175        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5176    ) -> fidl::client::QueryResponseFut<
5177        CodecDelayGetCodecLocalDelayRangeResult,
5178        fidl::encoding::DefaultFuchsiaResourceDialect,
5179    > {
5180        CodecDelayProxyInterface::r#get_codec_local_delay_range(self, payload)
5181    }
5182}
5183
5184impl CodecDelayProxyInterface for CodecDelayProxy {
5185    type GetCodecLocalDelayRangeResponseFut = fidl::client::QueryResponseFut<
5186        CodecDelayGetCodecLocalDelayRangeResult,
5187        fidl::encoding::DefaultFuchsiaResourceDialect,
5188    >;
5189    fn r#get_codec_local_delay_range(
5190        &self,
5191        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5192    ) -> Self::GetCodecLocalDelayRangeResponseFut {
5193        fn _decode(
5194            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5195        ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
5196            let _response = fidl::client::decode_transaction_body::<
5197                fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5198                fidl::encoding::DefaultFuchsiaResourceDialect,
5199                0x1cf34fdeed80b4d,
5200            >(_buf?)?;
5201            Ok(_response.map(|x| x))
5202        }
5203        self.client.send_query_and_decode::<
5204            CodecDelayGetCodecLocalDelayRangeRequest,
5205            CodecDelayGetCodecLocalDelayRangeResult,
5206        >(
5207            payload,
5208            0x1cf34fdeed80b4d,
5209            fidl::encoding::DynamicFlags::empty(),
5210            _decode,
5211        )
5212    }
5213}
5214
5215pub struct CodecDelayEventStream {
5216    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5217}
5218
5219impl std::marker::Unpin for CodecDelayEventStream {}
5220
5221impl futures::stream::FusedStream for CodecDelayEventStream {
5222    fn is_terminated(&self) -> bool {
5223        self.event_receiver.is_terminated()
5224    }
5225}
5226
5227impl futures::Stream for CodecDelayEventStream {
5228    type Item = Result<CodecDelayEvent, fidl::Error>;
5229
5230    fn poll_next(
5231        mut self: std::pin::Pin<&mut Self>,
5232        cx: &mut std::task::Context<'_>,
5233    ) -> std::task::Poll<Option<Self::Item>> {
5234        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5235            &mut self.event_receiver,
5236            cx
5237        )?) {
5238            Some(buf) => std::task::Poll::Ready(Some(CodecDelayEvent::decode(buf))),
5239            None => std::task::Poll::Ready(None),
5240        }
5241    }
5242}
5243
5244#[derive(Debug)]
5245pub enum CodecDelayEvent {}
5246
5247impl CodecDelayEvent {
5248    /// Decodes a message buffer as a [`CodecDelayEvent`].
5249    fn decode(
5250        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5251    ) -> Result<CodecDelayEvent, fidl::Error> {
5252        let (bytes, _handles) = buf.split_mut();
5253        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5254        debug_assert_eq!(tx_header.tx_id, 0);
5255        match tx_header.ordinal {
5256            _ => Err(fidl::Error::UnknownOrdinal {
5257                ordinal: tx_header.ordinal,
5258                protocol_name: <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5259            }),
5260        }
5261    }
5262}
5263
5264/// A Stream of incoming requests for fuchsia.bluetooth.le/CodecDelay.
5265pub struct CodecDelayRequestStream {
5266    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5267    is_terminated: bool,
5268}
5269
5270impl std::marker::Unpin for CodecDelayRequestStream {}
5271
5272impl futures::stream::FusedStream for CodecDelayRequestStream {
5273    fn is_terminated(&self) -> bool {
5274        self.is_terminated
5275    }
5276}
5277
5278impl fidl::endpoints::RequestStream for CodecDelayRequestStream {
5279    type Protocol = CodecDelayMarker;
5280    type ControlHandle = CodecDelayControlHandle;
5281
5282    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5283        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5284    }
5285
5286    fn control_handle(&self) -> Self::ControlHandle {
5287        CodecDelayControlHandle { inner: self.inner.clone() }
5288    }
5289
5290    fn into_inner(
5291        self,
5292    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5293    {
5294        (self.inner, self.is_terminated)
5295    }
5296
5297    fn from_inner(
5298        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5299        is_terminated: bool,
5300    ) -> Self {
5301        Self { inner, is_terminated }
5302    }
5303}
5304
5305impl futures::Stream for CodecDelayRequestStream {
5306    type Item = Result<CodecDelayRequest, fidl::Error>;
5307
5308    fn poll_next(
5309        mut self: std::pin::Pin<&mut Self>,
5310        cx: &mut std::task::Context<'_>,
5311    ) -> std::task::Poll<Option<Self::Item>> {
5312        let this = &mut *self;
5313        if this.inner.check_shutdown(cx) {
5314            this.is_terminated = true;
5315            return std::task::Poll::Ready(None);
5316        }
5317        if this.is_terminated {
5318            panic!("polled CodecDelayRequestStream after completion");
5319        }
5320        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5321            |bytes, handles| {
5322                match this.inner.channel().read_etc(cx, bytes, handles) {
5323                    std::task::Poll::Ready(Ok(())) => {}
5324                    std::task::Poll::Pending => return std::task::Poll::Pending,
5325                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5326                        this.is_terminated = true;
5327                        return std::task::Poll::Ready(None);
5328                    }
5329                    std::task::Poll::Ready(Err(e)) => {
5330                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5331                            e.into(),
5332                        ))));
5333                    }
5334                }
5335
5336                // A message has been received from the channel
5337                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5338
5339                std::task::Poll::Ready(Some(match header.ordinal {
5340                    0x1cf34fdeed80b4d => {
5341                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5342                        let mut req = fidl::new_empty!(
5343                            CodecDelayGetCodecLocalDelayRangeRequest,
5344                            fidl::encoding::DefaultFuchsiaResourceDialect
5345                        );
5346                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecDelayGetCodecLocalDelayRangeRequest>(&header, _body_bytes, handles, &mut req)?;
5347                        let control_handle = CodecDelayControlHandle { inner: this.inner.clone() };
5348                        Ok(CodecDelayRequest::GetCodecLocalDelayRange {
5349                            payload: req,
5350                            responder: CodecDelayGetCodecLocalDelayRangeResponder {
5351                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5352                                tx_id: header.tx_id,
5353                            },
5354                        })
5355                    }
5356                    _ => Err(fidl::Error::UnknownOrdinal {
5357                        ordinal: header.ordinal,
5358                        protocol_name:
5359                            <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5360                    }),
5361                }))
5362            },
5363        )
5364    }
5365}
5366
5367/// This protocol allows us to retrieve controller local delay values. It is not intended to be
5368/// used stand-alone, but to be composed into protocols that need access to this information.
5369#[derive(Debug)]
5370pub enum CodecDelayRequest {
5371    /// Retrieve the range of controller delay for the codec specified with the provided stream
5372    /// attributes.
5373    ///
5374    /// On success, returns the minimum and maximum allowed delay.
5375    ///
5376    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5377    /// Returns ZX_ERR_INTERNAL for all other failures.
5378    GetCodecLocalDelayRange {
5379        payload: CodecDelayGetCodecLocalDelayRangeRequest,
5380        responder: CodecDelayGetCodecLocalDelayRangeResponder,
5381    },
5382}
5383
5384impl CodecDelayRequest {
5385    #[allow(irrefutable_let_patterns)]
5386    pub fn into_get_codec_local_delay_range(
5387        self,
5388    ) -> Option<(
5389        CodecDelayGetCodecLocalDelayRangeRequest,
5390        CodecDelayGetCodecLocalDelayRangeResponder,
5391    )> {
5392        if let CodecDelayRequest::GetCodecLocalDelayRange { payload, responder } = self {
5393            Some((payload, responder))
5394        } else {
5395            None
5396        }
5397    }
5398
5399    /// Name of the method defined in FIDL
5400    pub fn method_name(&self) -> &'static str {
5401        match *self {
5402            CodecDelayRequest::GetCodecLocalDelayRange { .. } => "get_codec_local_delay_range",
5403        }
5404    }
5405}
5406
5407#[derive(Debug, Clone)]
5408pub struct CodecDelayControlHandle {
5409    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5410}
5411
5412impl CodecDelayControlHandle {
5413    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5414        self.inner.shutdown_with_epitaph(status.into())
5415    }
5416}
5417
5418impl fidl::endpoints::ControlHandle for CodecDelayControlHandle {
5419    fn shutdown(&self) {
5420        self.inner.shutdown()
5421    }
5422
5423    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5424        self.inner.shutdown_with_epitaph(status)
5425    }
5426
5427    fn is_closed(&self) -> bool {
5428        self.inner.channel().is_closed()
5429    }
5430    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5431        self.inner.channel().on_closed()
5432    }
5433
5434    #[cfg(target_os = "fuchsia")]
5435    fn signal_peer(
5436        &self,
5437        clear_mask: zx::Signals,
5438        set_mask: zx::Signals,
5439    ) -> Result<(), zx_status::Status> {
5440        use fidl::Peered;
5441        self.inner.channel().signal_peer(clear_mask, set_mask)
5442    }
5443}
5444
5445impl CodecDelayControlHandle {}
5446
5447#[must_use = "FIDL methods require a response to be sent"]
5448#[derive(Debug)]
5449pub struct CodecDelayGetCodecLocalDelayRangeResponder {
5450    control_handle: std::mem::ManuallyDrop<CodecDelayControlHandle>,
5451    tx_id: u32,
5452}
5453
5454/// Set the the channel to be shutdown (see [`CodecDelayControlHandle::shutdown`])
5455/// if the responder is dropped without sending a response, so that the client
5456/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5457impl std::ops::Drop for CodecDelayGetCodecLocalDelayRangeResponder {
5458    fn drop(&mut self) {
5459        self.control_handle.shutdown();
5460        // Safety: drops once, never accessed again
5461        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5462    }
5463}
5464
5465impl fidl::endpoints::Responder for CodecDelayGetCodecLocalDelayRangeResponder {
5466    type ControlHandle = CodecDelayControlHandle;
5467
5468    fn control_handle(&self) -> &CodecDelayControlHandle {
5469        &self.control_handle
5470    }
5471
5472    fn drop_without_shutdown(mut self) {
5473        // Safety: drops once, never accessed again due to mem::forget
5474        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5475        // Prevent Drop from running (which would shut down the channel)
5476        std::mem::forget(self);
5477    }
5478}
5479
5480impl CodecDelayGetCodecLocalDelayRangeResponder {
5481    /// Sends a response to the FIDL transaction.
5482    ///
5483    /// Sets the channel to shutdown if an error occurs.
5484    pub fn send(
5485        self,
5486        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5487    ) -> Result<(), fidl::Error> {
5488        let _result = self.send_raw(result);
5489        if _result.is_err() {
5490            self.control_handle.shutdown();
5491        }
5492        self.drop_without_shutdown();
5493        _result
5494    }
5495
5496    /// Similar to "send" but does not shutdown the channel if an error occurs.
5497    pub fn send_no_shutdown_on_err(
5498        self,
5499        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5500    ) -> Result<(), fidl::Error> {
5501        let _result = self.send_raw(result);
5502        self.drop_without_shutdown();
5503        _result
5504    }
5505
5506    fn send_raw(
5507        &self,
5508        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5509    ) -> Result<(), fidl::Error> {
5510        self.control_handle.inner.send::<fidl::encoding::ResultType<
5511            CodecDelayGetCodecLocalDelayRangeResponse,
5512            i32,
5513        >>(
5514            result,
5515            self.tx_id,
5516            0x1cf34fdeed80b4d,
5517            fidl::encoding::DynamicFlags::empty(),
5518        )
5519    }
5520}
5521
5522#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5523pub struct ConnectedIsochronousGroupMarker;
5524
5525impl fidl::endpoints::ProtocolMarker for ConnectedIsochronousGroupMarker {
5526    type Proxy = ConnectedIsochronousGroupProxy;
5527    type RequestStream = ConnectedIsochronousGroupRequestStream;
5528    #[cfg(target_os = "fuchsia")]
5529    type SynchronousProxy = ConnectedIsochronousGroupSynchronousProxy;
5530
5531    const DEBUG_NAME: &'static str = "(anonymous) ConnectedIsochronousGroup";
5532}
5533pub type ConnectedIsochronousGroupEstablishStreamsResult = Result<(), EstablishStreamsError>;
5534
5535pub trait ConnectedIsochronousGroupProxyInterface: Send + Sync {
5536    type EstablishStreamsResponseFut: std::future::Future<
5537            Output = Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error>,
5538        > + Send;
5539    fn r#establish_streams(
5540        &self,
5541        payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
5542    ) -> Self::EstablishStreamsResponseFut;
5543    fn r#remove(&self) -> Result<(), fidl::Error>;
5544}
5545#[derive(Debug)]
5546#[cfg(target_os = "fuchsia")]
5547pub struct ConnectedIsochronousGroupSynchronousProxy {
5548    client: fidl::client::sync::Client,
5549}
5550
5551#[cfg(target_os = "fuchsia")]
5552impl fidl::endpoints::SynchronousProxy for ConnectedIsochronousGroupSynchronousProxy {
5553    type Proxy = ConnectedIsochronousGroupProxy;
5554    type Protocol = ConnectedIsochronousGroupMarker;
5555
5556    fn from_channel(inner: fidl::Channel) -> Self {
5557        Self::new(inner)
5558    }
5559
5560    fn into_channel(self) -> fidl::Channel {
5561        self.client.into_channel()
5562    }
5563
5564    fn as_channel(&self) -> &fidl::Channel {
5565        self.client.as_channel()
5566    }
5567}
5568
5569#[cfg(target_os = "fuchsia")]
5570impl ConnectedIsochronousGroupSynchronousProxy {
5571    pub fn new(channel: fidl::Channel) -> Self {
5572        Self { client: fidl::client::sync::Client::new(channel) }
5573    }
5574
5575    pub fn into_channel(self) -> fidl::Channel {
5576        self.client.into_channel()
5577    }
5578
5579    /// Waits until an event arrives and returns it. It is safe for other
5580    /// threads to make concurrent requests while waiting for an event.
5581    pub fn wait_for_event(
5582        &self,
5583        deadline: zx::MonotonicInstant,
5584    ) -> Result<ConnectedIsochronousGroupEvent, fidl::Error> {
5585        ConnectedIsochronousGroupEvent::decode(
5586            self.client.wait_for_event::<ConnectedIsochronousGroupMarker>(deadline)?,
5587        )
5588    }
5589
5590    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
5591    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
5592    /// be sent on the IsochronousStream.
5593    ///
5594    /// Only one `EstablishStreams` call may be active at a time. Calling `EstablishStreams` while
5595    /// another is pending will result in the channel being closed with `ZX_ERR_BAD_STATE`.
5596    ///
5597    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
5598    /// returned.
5599    ///
5600    /// Otherwise, this call returns once each CIS specified has connected.
5601    pub fn r#establish_streams(
5602        &self,
5603        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
5604        ___deadline: zx::MonotonicInstant,
5605    ) -> Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error> {
5606        let _response = self.client.send_query::<
5607            ConnectedIsochronousGroupEstablishStreamsRequest,
5608            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EstablishStreamsError>,
5609            ConnectedIsochronousGroupMarker,
5610        >(
5611            payload,
5612            0xc7296c5edb4dacc,
5613            fidl::encoding::DynamicFlags::FLEXIBLE,
5614            ___deadline,
5615        )?
5616        .into_result::<ConnectedIsochronousGroupMarker>("establish_streams")?;
5617        Ok(_response.map(|x| x))
5618    }
5619
5620    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
5621    /// all of the associated streams have closed and the group has been removed.
5622    pub fn r#remove(&self) -> Result<(), fidl::Error> {
5623        self.client.send::<fidl::encoding::EmptyPayload>(
5624            (),
5625            0xbed433babd20503,
5626            fidl::encoding::DynamicFlags::FLEXIBLE,
5627        )
5628    }
5629}
5630
5631#[cfg(target_os = "fuchsia")]
5632impl From<ConnectedIsochronousGroupSynchronousProxy> for zx::NullableHandle {
5633    fn from(value: ConnectedIsochronousGroupSynchronousProxy) -> Self {
5634        value.into_channel().into()
5635    }
5636}
5637
5638#[cfg(target_os = "fuchsia")]
5639impl From<fidl::Channel> for ConnectedIsochronousGroupSynchronousProxy {
5640    fn from(value: fidl::Channel) -> Self {
5641        Self::new(value)
5642    }
5643}
5644
5645#[cfg(target_os = "fuchsia")]
5646impl fidl::endpoints::FromClient for ConnectedIsochronousGroupSynchronousProxy {
5647    type Protocol = ConnectedIsochronousGroupMarker;
5648
5649    fn from_client(value: fidl::endpoints::ClientEnd<ConnectedIsochronousGroupMarker>) -> Self {
5650        Self::new(value.into_channel())
5651    }
5652}
5653
5654#[derive(Debug, Clone)]
5655pub struct ConnectedIsochronousGroupProxy {
5656    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5657}
5658
5659impl fidl::endpoints::Proxy for ConnectedIsochronousGroupProxy {
5660    type Protocol = ConnectedIsochronousGroupMarker;
5661
5662    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5663        Self::new(inner)
5664    }
5665
5666    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5667        self.client.into_channel().map_err(|client| Self { client })
5668    }
5669
5670    fn as_channel(&self) -> &::fidl::AsyncChannel {
5671        self.client.as_channel()
5672    }
5673}
5674
5675impl ConnectedIsochronousGroupProxy {
5676    /// Create a new Proxy for fuchsia.bluetooth.le/ConnectedIsochronousGroup.
5677    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5678        let protocol_name =
5679            <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5680        Self { client: fidl::client::Client::new(channel, protocol_name) }
5681    }
5682
5683    /// Get a Stream of events from the remote end of the protocol.
5684    ///
5685    /// # Panics
5686    ///
5687    /// Panics if the event stream was already taken.
5688    pub fn take_event_stream(&self) -> ConnectedIsochronousGroupEventStream {
5689        ConnectedIsochronousGroupEventStream { event_receiver: self.client.take_event_receiver() }
5690    }
5691
5692    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
5693    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
5694    /// be sent on the IsochronousStream.
5695    ///
5696    /// Only one `EstablishStreams` call may be active at a time. Calling `EstablishStreams` while
5697    /// another is pending will result in the channel being closed with `ZX_ERR_BAD_STATE`.
5698    ///
5699    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
5700    /// returned.
5701    ///
5702    /// Otherwise, this call returns once each CIS specified has connected.
5703    pub fn r#establish_streams(
5704        &self,
5705        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
5706    ) -> fidl::client::QueryResponseFut<
5707        ConnectedIsochronousGroupEstablishStreamsResult,
5708        fidl::encoding::DefaultFuchsiaResourceDialect,
5709    > {
5710        ConnectedIsochronousGroupProxyInterface::r#establish_streams(self, payload)
5711    }
5712
5713    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
5714    /// all of the associated streams have closed and the group has been removed.
5715    pub fn r#remove(&self) -> Result<(), fidl::Error> {
5716        ConnectedIsochronousGroupProxyInterface::r#remove(self)
5717    }
5718}
5719
5720impl ConnectedIsochronousGroupProxyInterface for ConnectedIsochronousGroupProxy {
5721    type EstablishStreamsResponseFut = fidl::client::QueryResponseFut<
5722        ConnectedIsochronousGroupEstablishStreamsResult,
5723        fidl::encoding::DefaultFuchsiaResourceDialect,
5724    >;
5725    fn r#establish_streams(
5726        &self,
5727        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
5728    ) -> Self::EstablishStreamsResponseFut {
5729        fn _decode(
5730            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5731        ) -> Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error> {
5732            let _response = fidl::client::decode_transaction_body::<
5733                fidl::encoding::FlexibleResultType<
5734                    fidl::encoding::EmptyStruct,
5735                    EstablishStreamsError,
5736                >,
5737                fidl::encoding::DefaultFuchsiaResourceDialect,
5738                0xc7296c5edb4dacc,
5739            >(_buf?)?
5740            .into_result::<ConnectedIsochronousGroupMarker>("establish_streams")?;
5741            Ok(_response.map(|x| x))
5742        }
5743        self.client.send_query_and_decode::<
5744            ConnectedIsochronousGroupEstablishStreamsRequest,
5745            ConnectedIsochronousGroupEstablishStreamsResult,
5746        >(
5747            payload,
5748            0xc7296c5edb4dacc,
5749            fidl::encoding::DynamicFlags::FLEXIBLE,
5750            _decode,
5751        )
5752    }
5753
5754    fn r#remove(&self) -> Result<(), fidl::Error> {
5755        self.client.send::<fidl::encoding::EmptyPayload>(
5756            (),
5757            0xbed433babd20503,
5758            fidl::encoding::DynamicFlags::FLEXIBLE,
5759        )
5760    }
5761}
5762
5763pub struct ConnectedIsochronousGroupEventStream {
5764    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5765}
5766
5767impl std::marker::Unpin for ConnectedIsochronousGroupEventStream {}
5768
5769impl futures::stream::FusedStream for ConnectedIsochronousGroupEventStream {
5770    fn is_terminated(&self) -> bool {
5771        self.event_receiver.is_terminated()
5772    }
5773}
5774
5775impl futures::Stream for ConnectedIsochronousGroupEventStream {
5776    type Item = Result<ConnectedIsochronousGroupEvent, fidl::Error>;
5777
5778    fn poll_next(
5779        mut self: std::pin::Pin<&mut Self>,
5780        cx: &mut std::task::Context<'_>,
5781    ) -> std::task::Poll<Option<Self::Item>> {
5782        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5783            &mut self.event_receiver,
5784            cx
5785        )?) {
5786            Some(buf) => std::task::Poll::Ready(Some(ConnectedIsochronousGroupEvent::decode(buf))),
5787            None => std::task::Poll::Ready(None),
5788        }
5789    }
5790}
5791
5792#[derive(Debug)]
5793pub enum ConnectedIsochronousGroupEvent {
5794    #[non_exhaustive]
5795    _UnknownEvent {
5796        /// Ordinal of the event that was sent.
5797        ordinal: u64,
5798    },
5799}
5800
5801impl ConnectedIsochronousGroupEvent {
5802    /// Decodes a message buffer as a [`ConnectedIsochronousGroupEvent`].
5803    fn decode(
5804        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5805    ) -> Result<ConnectedIsochronousGroupEvent, fidl::Error> {
5806        let (bytes, _handles) = buf.split_mut();
5807        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5808        debug_assert_eq!(tx_header.tx_id, 0);
5809        match tx_header.ordinal {
5810            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5811                Ok(ConnectedIsochronousGroupEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5812            }
5813            _ => Err(fidl::Error::UnknownOrdinal {
5814                ordinal: tx_header.ordinal,
5815                protocol_name:
5816                    <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5817            }),
5818        }
5819    }
5820}
5821
5822/// A Stream of incoming requests for fuchsia.bluetooth.le/ConnectedIsochronousGroup.
5823pub struct ConnectedIsochronousGroupRequestStream {
5824    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5825    is_terminated: bool,
5826}
5827
5828impl std::marker::Unpin for ConnectedIsochronousGroupRequestStream {}
5829
5830impl futures::stream::FusedStream for ConnectedIsochronousGroupRequestStream {
5831    fn is_terminated(&self) -> bool {
5832        self.is_terminated
5833    }
5834}
5835
5836impl fidl::endpoints::RequestStream for ConnectedIsochronousGroupRequestStream {
5837    type Protocol = ConnectedIsochronousGroupMarker;
5838    type ControlHandle = ConnectedIsochronousGroupControlHandle;
5839
5840    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5841        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5842    }
5843
5844    fn control_handle(&self) -> Self::ControlHandle {
5845        ConnectedIsochronousGroupControlHandle { inner: self.inner.clone() }
5846    }
5847
5848    fn into_inner(
5849        self,
5850    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5851    {
5852        (self.inner, self.is_terminated)
5853    }
5854
5855    fn from_inner(
5856        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5857        is_terminated: bool,
5858    ) -> Self {
5859        Self { inner, is_terminated }
5860    }
5861}
5862
5863impl futures::Stream for ConnectedIsochronousGroupRequestStream {
5864    type Item = Result<ConnectedIsochronousGroupRequest, fidl::Error>;
5865
5866    fn poll_next(
5867        mut self: std::pin::Pin<&mut Self>,
5868        cx: &mut std::task::Context<'_>,
5869    ) -> std::task::Poll<Option<Self::Item>> {
5870        let this = &mut *self;
5871        if this.inner.check_shutdown(cx) {
5872            this.is_terminated = true;
5873            return std::task::Poll::Ready(None);
5874        }
5875        if this.is_terminated {
5876            panic!("polled ConnectedIsochronousGroupRequestStream after completion");
5877        }
5878        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5879            |bytes, handles| {
5880                match this.inner.channel().read_etc(cx, bytes, handles) {
5881                    std::task::Poll::Ready(Ok(())) => {}
5882                    std::task::Poll::Pending => return std::task::Poll::Pending,
5883                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5884                        this.is_terminated = true;
5885                        return std::task::Poll::Ready(None);
5886                    }
5887                    std::task::Poll::Ready(Err(e)) => {
5888                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5889                            e.into(),
5890                        ))));
5891                    }
5892                }
5893
5894                // A message has been received from the channel
5895                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5896
5897                std::task::Poll::Ready(Some(match header.ordinal {
5898                0xc7296c5edb4dacc => {
5899                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5900                    let mut req = fidl::new_empty!(ConnectedIsochronousGroupEstablishStreamsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5901                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectedIsochronousGroupEstablishStreamsRequest>(&header, _body_bytes, handles, &mut req)?;
5902                    let control_handle = ConnectedIsochronousGroupControlHandle {
5903                        inner: this.inner.clone(),
5904                    };
5905                    Ok(ConnectedIsochronousGroupRequest::EstablishStreams {payload: req,
5906                        responder: ConnectedIsochronousGroupEstablishStreamsResponder {
5907                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5908                            tx_id: header.tx_id,
5909                        },
5910                    })
5911                }
5912                0xbed433babd20503 => {
5913                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5914                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5915                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5916                    let control_handle = ConnectedIsochronousGroupControlHandle {
5917                        inner: this.inner.clone(),
5918                    };
5919                    Ok(ConnectedIsochronousGroupRequest::Remove {
5920                        control_handle,
5921                    })
5922                }
5923                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5924                    Ok(ConnectedIsochronousGroupRequest::_UnknownMethod {
5925                        ordinal: header.ordinal,
5926                        control_handle: ConnectedIsochronousGroupControlHandle { inner: this.inner.clone() },
5927                        method_type: fidl::MethodType::OneWay,
5928                    })
5929                }
5930                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5931                    this.inner.send_framework_err(
5932                        fidl::encoding::FrameworkErr::UnknownMethod,
5933                        header.tx_id,
5934                        header.ordinal,
5935                        header.dynamic_flags(),
5936                        (bytes, handles),
5937                    )?;
5938                    Ok(ConnectedIsochronousGroupRequest::_UnknownMethod {
5939                        ordinal: header.ordinal,
5940                        control_handle: ConnectedIsochronousGroupControlHandle { inner: this.inner.clone() },
5941                        method_type: fidl::MethodType::TwoWay,
5942                    })
5943                }
5944                _ => Err(fidl::Error::UnknownOrdinal {
5945                    ordinal: header.ordinal,
5946                    protocol_name: <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5947                }),
5948            }))
5949            },
5950        )
5951    }
5952}
5953
5954#[derive(Debug)]
5955pub enum ConnectedIsochronousGroupRequest {
5956    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
5957    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
5958    /// be sent on the IsochronousStream.
5959    ///
5960    /// Only one `EstablishStreams` call may be active at a time. Calling `EstablishStreams` while
5961    /// another is pending will result in the channel being closed with `ZX_ERR_BAD_STATE`.
5962    ///
5963    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
5964    /// returned.
5965    ///
5966    /// Otherwise, this call returns once each CIS specified has connected.
5967    EstablishStreams {
5968        payload: ConnectedIsochronousGroupEstablishStreamsRequest,
5969        responder: ConnectedIsochronousGroupEstablishStreamsResponder,
5970    },
5971    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
5972    /// all of the associated streams have closed and the group has been removed.
5973    Remove { control_handle: ConnectedIsochronousGroupControlHandle },
5974    /// An interaction was received which does not match any known method.
5975    #[non_exhaustive]
5976    _UnknownMethod {
5977        /// Ordinal of the method that was called.
5978        ordinal: u64,
5979        control_handle: ConnectedIsochronousGroupControlHandle,
5980        method_type: fidl::MethodType,
5981    },
5982}
5983
5984impl ConnectedIsochronousGroupRequest {
5985    #[allow(irrefutable_let_patterns)]
5986    pub fn into_establish_streams(
5987        self,
5988    ) -> Option<(
5989        ConnectedIsochronousGroupEstablishStreamsRequest,
5990        ConnectedIsochronousGroupEstablishStreamsResponder,
5991    )> {
5992        if let ConnectedIsochronousGroupRequest::EstablishStreams { payload, responder } = self {
5993            Some((payload, responder))
5994        } else {
5995            None
5996        }
5997    }
5998
5999    #[allow(irrefutable_let_patterns)]
6000    pub fn into_remove(self) -> Option<(ConnectedIsochronousGroupControlHandle)> {
6001        if let ConnectedIsochronousGroupRequest::Remove { control_handle } = self {
6002            Some((control_handle))
6003        } else {
6004            None
6005        }
6006    }
6007
6008    /// Name of the method defined in FIDL
6009    pub fn method_name(&self) -> &'static str {
6010        match *self {
6011            ConnectedIsochronousGroupRequest::EstablishStreams { .. } => "establish_streams",
6012            ConnectedIsochronousGroupRequest::Remove { .. } => "remove",
6013            ConnectedIsochronousGroupRequest::_UnknownMethod {
6014                method_type: fidl::MethodType::OneWay,
6015                ..
6016            } => "unknown one-way method",
6017            ConnectedIsochronousGroupRequest::_UnknownMethod {
6018                method_type: fidl::MethodType::TwoWay,
6019                ..
6020            } => "unknown two-way method",
6021        }
6022    }
6023}
6024
6025#[derive(Debug, Clone)]
6026pub struct ConnectedIsochronousGroupControlHandle {
6027    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6028}
6029
6030impl ConnectedIsochronousGroupControlHandle {
6031    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6032        self.inner.shutdown_with_epitaph(status.into())
6033    }
6034}
6035
6036impl fidl::endpoints::ControlHandle for ConnectedIsochronousGroupControlHandle {
6037    fn shutdown(&self) {
6038        self.inner.shutdown()
6039    }
6040
6041    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6042        self.inner.shutdown_with_epitaph(status)
6043    }
6044
6045    fn is_closed(&self) -> bool {
6046        self.inner.channel().is_closed()
6047    }
6048    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6049        self.inner.channel().on_closed()
6050    }
6051
6052    #[cfg(target_os = "fuchsia")]
6053    fn signal_peer(
6054        &self,
6055        clear_mask: zx::Signals,
6056        set_mask: zx::Signals,
6057    ) -> Result<(), zx_status::Status> {
6058        use fidl::Peered;
6059        self.inner.channel().signal_peer(clear_mask, set_mask)
6060    }
6061}
6062
6063impl ConnectedIsochronousGroupControlHandle {}
6064
6065#[must_use = "FIDL methods require a response to be sent"]
6066#[derive(Debug)]
6067pub struct ConnectedIsochronousGroupEstablishStreamsResponder {
6068    control_handle: std::mem::ManuallyDrop<ConnectedIsochronousGroupControlHandle>,
6069    tx_id: u32,
6070}
6071
6072/// Set the the channel to be shutdown (see [`ConnectedIsochronousGroupControlHandle::shutdown`])
6073/// if the responder is dropped without sending a response, so that the client
6074/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6075impl std::ops::Drop for ConnectedIsochronousGroupEstablishStreamsResponder {
6076    fn drop(&mut self) {
6077        self.control_handle.shutdown();
6078        // Safety: drops once, never accessed again
6079        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6080    }
6081}
6082
6083impl fidl::endpoints::Responder for ConnectedIsochronousGroupEstablishStreamsResponder {
6084    type ControlHandle = ConnectedIsochronousGroupControlHandle;
6085
6086    fn control_handle(&self) -> &ConnectedIsochronousGroupControlHandle {
6087        &self.control_handle
6088    }
6089
6090    fn drop_without_shutdown(mut self) {
6091        // Safety: drops once, never accessed again due to mem::forget
6092        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6093        // Prevent Drop from running (which would shut down the channel)
6094        std::mem::forget(self);
6095    }
6096}
6097
6098impl ConnectedIsochronousGroupEstablishStreamsResponder {
6099    /// Sends a response to the FIDL transaction.
6100    ///
6101    /// Sets the channel to shutdown if an error occurs.
6102    pub fn send(self, mut result: Result<(), EstablishStreamsError>) -> Result<(), fidl::Error> {
6103        let _result = self.send_raw(result);
6104        if _result.is_err() {
6105            self.control_handle.shutdown();
6106        }
6107        self.drop_without_shutdown();
6108        _result
6109    }
6110
6111    /// Similar to "send" but does not shutdown the channel if an error occurs.
6112    pub fn send_no_shutdown_on_err(
6113        self,
6114        mut result: Result<(), EstablishStreamsError>,
6115    ) -> Result<(), fidl::Error> {
6116        let _result = self.send_raw(result);
6117        self.drop_without_shutdown();
6118        _result
6119    }
6120
6121    fn send_raw(&self, mut result: Result<(), EstablishStreamsError>) -> Result<(), fidl::Error> {
6122        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6123            fidl::encoding::EmptyStruct,
6124            EstablishStreamsError,
6125        >>(
6126            fidl::encoding::FlexibleResult::new(result),
6127            self.tx_id,
6128            0xc7296c5edb4dacc,
6129            fidl::encoding::DynamicFlags::FLEXIBLE,
6130        )
6131    }
6132}
6133
6134#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6135pub struct ConnectionMarker;
6136
6137impl fidl::endpoints::ProtocolMarker for ConnectionMarker {
6138    type Proxy = ConnectionProxy;
6139    type RequestStream = ConnectionRequestStream;
6140    #[cfg(target_os = "fuchsia")]
6141    type SynchronousProxy = ConnectionSynchronousProxy;
6142
6143    const DEBUG_NAME: &'static str = "(anonymous) Connection";
6144}
6145pub type ConnectionTransferPeriodicAdvertisingSyncResult =
6146    Result<(), PeriodicAdvertisingSyncTransferError>;
6147pub type ConnectionAcceptPeriodicAdvertisingSyncTransferResult =
6148    Result<(), PeriodicAdvertisingSyncTransferError>;
6149
6150pub trait ConnectionProxyInterface: Send + Sync {
6151    type GetCodecLocalDelayRangeResponseFut: std::future::Future<Output = Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error>>
6152        + Send;
6153    fn r#get_codec_local_delay_range(
6154        &self,
6155        payload: &CodecDelayGetCodecLocalDelayRangeRequest,
6156    ) -> Self::GetCodecLocalDelayRangeResponseFut;
6157    fn r#request_gatt_client(
6158        &self,
6159        client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6160    ) -> Result<(), fidl::Error>;
6161    fn r#accept_cis(&self, payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error>;
6162    fn r#connect_l2cap(&self, payload: ConnectionConnectL2capRequest) -> Result<(), fidl::Error>;
6163    type TransferPeriodicAdvertisingSyncResponseFut: std::future::Future<
6164            Output = Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error>,
6165        > + Send;
6166    fn r#transfer_periodic_advertising_sync(
6167        &self,
6168        payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
6169    ) -> Self::TransferPeriodicAdvertisingSyncResponseFut;
6170    type AcceptPeriodicAdvertisingSyncTransferResponseFut: std::future::Future<
6171            Output = Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error>,
6172        > + Send;
6173    fn r#accept_periodic_advertising_sync_transfer(
6174        &self,
6175        payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6176    ) -> Self::AcceptPeriodicAdvertisingSyncTransferResponseFut;
6177}
6178#[derive(Debug)]
6179#[cfg(target_os = "fuchsia")]
6180pub struct ConnectionSynchronousProxy {
6181    client: fidl::client::sync::Client,
6182}
6183
6184#[cfg(target_os = "fuchsia")]
6185impl fidl::endpoints::SynchronousProxy for ConnectionSynchronousProxy {
6186    type Proxy = ConnectionProxy;
6187    type Protocol = ConnectionMarker;
6188
6189    fn from_channel(inner: fidl::Channel) -> Self {
6190        Self::new(inner)
6191    }
6192
6193    fn into_channel(self) -> fidl::Channel {
6194        self.client.into_channel()
6195    }
6196
6197    fn as_channel(&self) -> &fidl::Channel {
6198        self.client.as_channel()
6199    }
6200}
6201
6202#[cfg(target_os = "fuchsia")]
6203impl ConnectionSynchronousProxy {
6204    pub fn new(channel: fidl::Channel) -> Self {
6205        Self { client: fidl::client::sync::Client::new(channel) }
6206    }
6207
6208    pub fn into_channel(self) -> fidl::Channel {
6209        self.client.into_channel()
6210    }
6211
6212    /// Waits until an event arrives and returns it. It is safe for other
6213    /// threads to make concurrent requests while waiting for an event.
6214    pub fn wait_for_event(
6215        &self,
6216        deadline: zx::MonotonicInstant,
6217    ) -> Result<ConnectionEvent, fidl::Error> {
6218        ConnectionEvent::decode(self.client.wait_for_event::<ConnectionMarker>(deadline)?)
6219    }
6220
6221    /// Retrieve the range of controller delay for the codec specified with the provided stream
6222    /// attributes.
6223    ///
6224    /// On success, returns the minimum and maximum allowed delay.
6225    ///
6226    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
6227    /// Returns ZX_ERR_INTERNAL for all other failures.
6228    pub fn r#get_codec_local_delay_range(
6229        &self,
6230        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
6231        ___deadline: zx::MonotonicInstant,
6232    ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
6233        let _response = self.client.send_query::<
6234            CodecDelayGetCodecLocalDelayRangeRequest,
6235            fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
6236            ConnectionMarker,
6237        >(
6238            payload,
6239            0x1cf34fdeed80b4d,
6240            fidl::encoding::DynamicFlags::empty(),
6241            ___deadline,
6242        )?;
6243        Ok(_response.map(|x| x))
6244    }
6245
6246    /// The following epitaphs may be sent by the server on error:
6247    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
6248    ///                           protocol. The existing Client should be used.
6249    pub fn r#request_gatt_client(
6250        &self,
6251        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6252    ) -> Result<(), fidl::Error> {
6253        self.client.send::<ConnectionRequestGattClientRequest>(
6254            (client,),
6255            0x2a670e0fec6ccc6b,
6256            fidl::encoding::DynamicFlags::empty(),
6257        )
6258    }
6259
6260    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
6261    /// CIS requests that have not explicitly been allowed will be rejected.
6262    ///
6263    /// The provided IsochronousStream will be used for future notification of established
6264    /// connections.
6265    ///
6266    /// The host may wait for multiple incoming connections simultaneously, although each
6267    /// must have a combination of CIG/CIS values that is unique to this connection.
6268    ///
6269    /// If we are not operating in the peripheral role in this connection, connection_stream
6270    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
6271    ///
6272    /// If we are already waiting for another connection with the same combination of CIG/CIS
6273    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
6274    pub fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
6275        self.client.send::<ConnectionAcceptCisRequest>(
6276            &mut payload,
6277            0x7e6338c237088144,
6278            fidl::encoding::DynamicFlags::empty(),
6279        )
6280    }
6281
6282    /// Connect to an L2CAP LE connection-oriented channel.
6283    pub fn r#connect_l2cap(
6284        &self,
6285        mut payload: ConnectionConnectL2capRequest,
6286    ) -> Result<(), fidl::Error> {
6287        self.client.send::<ConnectionConnectL2capRequest>(
6288            &mut payload,
6289            0x12351316feaebce9,
6290            fidl::encoding::DynamicFlags::empty(),
6291        )
6292    }
6293
6294    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
6295    /// the connected peer.
6296    pub fn r#transfer_periodic_advertising_sync(
6297        &self,
6298        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
6299        ___deadline: zx::MonotonicInstant,
6300    ) -> Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error> {
6301        let _response = self.client.send_query::<
6302            ConnectionTransferPeriodicAdvertisingSyncRequest,
6303            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeriodicAdvertisingSyncTransferError>,
6304            ConnectionMarker,
6305        >(
6306            payload,
6307            0x1117a10b5ba1e219,
6308            fidl::encoding::DynamicFlags::empty(),
6309            ___deadline,
6310        )?;
6311        Ok(_response.map(|x| x))
6312    }
6313
6314    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
6315    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
6316    pub fn r#accept_periodic_advertising_sync_transfer(
6317        &self,
6318        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6319        ___deadline: zx::MonotonicInstant,
6320    ) -> Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error> {
6321        let _response = self.client.send_query::<
6322            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6323            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeriodicAdvertisingSyncTransferError>,
6324            ConnectionMarker,
6325        >(
6326            &mut payload,
6327            0x441a31a7effa7e2b,
6328            fidl::encoding::DynamicFlags::empty(),
6329            ___deadline,
6330        )?;
6331        Ok(_response.map(|x| x))
6332    }
6333}
6334
6335#[cfg(target_os = "fuchsia")]
6336impl From<ConnectionSynchronousProxy> for zx::NullableHandle {
6337    fn from(value: ConnectionSynchronousProxy) -> Self {
6338        value.into_channel().into()
6339    }
6340}
6341
6342#[cfg(target_os = "fuchsia")]
6343impl From<fidl::Channel> for ConnectionSynchronousProxy {
6344    fn from(value: fidl::Channel) -> Self {
6345        Self::new(value)
6346    }
6347}
6348
6349#[cfg(target_os = "fuchsia")]
6350impl fidl::endpoints::FromClient for ConnectionSynchronousProxy {
6351    type Protocol = ConnectionMarker;
6352
6353    fn from_client(value: fidl::endpoints::ClientEnd<ConnectionMarker>) -> Self {
6354        Self::new(value.into_channel())
6355    }
6356}
6357
6358#[derive(Debug, Clone)]
6359pub struct ConnectionProxy {
6360    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6361}
6362
6363impl fidl::endpoints::Proxy for ConnectionProxy {
6364    type Protocol = ConnectionMarker;
6365
6366    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6367        Self::new(inner)
6368    }
6369
6370    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6371        self.client.into_channel().map_err(|client| Self { client })
6372    }
6373
6374    fn as_channel(&self) -> &::fidl::AsyncChannel {
6375        self.client.as_channel()
6376    }
6377}
6378
6379impl ConnectionProxy {
6380    /// Create a new Proxy for fuchsia.bluetooth.le/Connection.
6381    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6382        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6383        Self { client: fidl::client::Client::new(channel, protocol_name) }
6384    }
6385
6386    /// Get a Stream of events from the remote end of the protocol.
6387    ///
6388    /// # Panics
6389    ///
6390    /// Panics if the event stream was already taken.
6391    pub fn take_event_stream(&self) -> ConnectionEventStream {
6392        ConnectionEventStream { event_receiver: self.client.take_event_receiver() }
6393    }
6394
6395    /// Retrieve the range of controller delay for the codec specified with the provided stream
6396    /// attributes.
6397    ///
6398    /// On success, returns the minimum and maximum allowed delay.
6399    ///
6400    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
6401    /// Returns ZX_ERR_INTERNAL for all other failures.
6402    pub fn r#get_codec_local_delay_range(
6403        &self,
6404        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
6405    ) -> fidl::client::QueryResponseFut<
6406        CodecDelayGetCodecLocalDelayRangeResult,
6407        fidl::encoding::DefaultFuchsiaResourceDialect,
6408    > {
6409        ConnectionProxyInterface::r#get_codec_local_delay_range(self, payload)
6410    }
6411
6412    /// The following epitaphs may be sent by the server on error:
6413    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
6414    ///                           protocol. The existing Client should be used.
6415    pub fn r#request_gatt_client(
6416        &self,
6417        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6418    ) -> Result<(), fidl::Error> {
6419        ConnectionProxyInterface::r#request_gatt_client(self, client)
6420    }
6421
6422    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
6423    /// CIS requests that have not explicitly been allowed will be rejected.
6424    ///
6425    /// The provided IsochronousStream will be used for future notification of established
6426    /// connections.
6427    ///
6428    /// The host may wait for multiple incoming connections simultaneously, although each
6429    /// must have a combination of CIG/CIS values that is unique to this connection.
6430    ///
6431    /// If we are not operating in the peripheral role in this connection, connection_stream
6432    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
6433    ///
6434    /// If we are already waiting for another connection with the same combination of CIG/CIS
6435    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
6436    pub fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
6437        ConnectionProxyInterface::r#accept_cis(self, payload)
6438    }
6439
6440    /// Connect to an L2CAP LE connection-oriented channel.
6441    pub fn r#connect_l2cap(
6442        &self,
6443        mut payload: ConnectionConnectL2capRequest,
6444    ) -> Result<(), fidl::Error> {
6445        ConnectionProxyInterface::r#connect_l2cap(self, payload)
6446    }
6447
6448    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
6449    /// the connected peer.
6450    pub fn r#transfer_periodic_advertising_sync(
6451        &self,
6452        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
6453    ) -> fidl::client::QueryResponseFut<
6454        ConnectionTransferPeriodicAdvertisingSyncResult,
6455        fidl::encoding::DefaultFuchsiaResourceDialect,
6456    > {
6457        ConnectionProxyInterface::r#transfer_periodic_advertising_sync(self, payload)
6458    }
6459
6460    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
6461    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
6462    pub fn r#accept_periodic_advertising_sync_transfer(
6463        &self,
6464        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6465    ) -> fidl::client::QueryResponseFut<
6466        ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
6467        fidl::encoding::DefaultFuchsiaResourceDialect,
6468    > {
6469        ConnectionProxyInterface::r#accept_periodic_advertising_sync_transfer(self, payload)
6470    }
6471}
6472
6473impl ConnectionProxyInterface for ConnectionProxy {
6474    type GetCodecLocalDelayRangeResponseFut = fidl::client::QueryResponseFut<
6475        CodecDelayGetCodecLocalDelayRangeResult,
6476        fidl::encoding::DefaultFuchsiaResourceDialect,
6477    >;
6478    fn r#get_codec_local_delay_range(
6479        &self,
6480        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
6481    ) -> Self::GetCodecLocalDelayRangeResponseFut {
6482        fn _decode(
6483            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6484        ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
6485            let _response = fidl::client::decode_transaction_body::<
6486                fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
6487                fidl::encoding::DefaultFuchsiaResourceDialect,
6488                0x1cf34fdeed80b4d,
6489            >(_buf?)?;
6490            Ok(_response.map(|x| x))
6491        }
6492        self.client.send_query_and_decode::<
6493            CodecDelayGetCodecLocalDelayRangeRequest,
6494            CodecDelayGetCodecLocalDelayRangeResult,
6495        >(
6496            payload,
6497            0x1cf34fdeed80b4d,
6498            fidl::encoding::DynamicFlags::empty(),
6499            _decode,
6500        )
6501    }
6502
6503    fn r#request_gatt_client(
6504        &self,
6505        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6506    ) -> Result<(), fidl::Error> {
6507        self.client.send::<ConnectionRequestGattClientRequest>(
6508            (client,),
6509            0x2a670e0fec6ccc6b,
6510            fidl::encoding::DynamicFlags::empty(),
6511        )
6512    }
6513
6514    fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
6515        self.client.send::<ConnectionAcceptCisRequest>(
6516            &mut payload,
6517            0x7e6338c237088144,
6518            fidl::encoding::DynamicFlags::empty(),
6519        )
6520    }
6521
6522    fn r#connect_l2cap(
6523        &self,
6524        mut payload: ConnectionConnectL2capRequest,
6525    ) -> Result<(), fidl::Error> {
6526        self.client.send::<ConnectionConnectL2capRequest>(
6527            &mut payload,
6528            0x12351316feaebce9,
6529            fidl::encoding::DynamicFlags::empty(),
6530        )
6531    }
6532
6533    type TransferPeriodicAdvertisingSyncResponseFut = fidl::client::QueryResponseFut<
6534        ConnectionTransferPeriodicAdvertisingSyncResult,
6535        fidl::encoding::DefaultFuchsiaResourceDialect,
6536    >;
6537    fn r#transfer_periodic_advertising_sync(
6538        &self,
6539        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
6540    ) -> Self::TransferPeriodicAdvertisingSyncResponseFut {
6541        fn _decode(
6542            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6543        ) -> Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error> {
6544            let _response = fidl::client::decode_transaction_body::<
6545                fidl::encoding::ResultType<
6546                    fidl::encoding::EmptyStruct,
6547                    PeriodicAdvertisingSyncTransferError,
6548                >,
6549                fidl::encoding::DefaultFuchsiaResourceDialect,
6550                0x1117a10b5ba1e219,
6551            >(_buf?)?;
6552            Ok(_response.map(|x| x))
6553        }
6554        self.client.send_query_and_decode::<
6555            ConnectionTransferPeriodicAdvertisingSyncRequest,
6556            ConnectionTransferPeriodicAdvertisingSyncResult,
6557        >(
6558            payload,
6559            0x1117a10b5ba1e219,
6560            fidl::encoding::DynamicFlags::empty(),
6561            _decode,
6562        )
6563    }
6564
6565    type AcceptPeriodicAdvertisingSyncTransferResponseFut = fidl::client::QueryResponseFut<
6566        ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
6567        fidl::encoding::DefaultFuchsiaResourceDialect,
6568    >;
6569    fn r#accept_periodic_advertising_sync_transfer(
6570        &self,
6571        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6572    ) -> Self::AcceptPeriodicAdvertisingSyncTransferResponseFut {
6573        fn _decode(
6574            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6575        ) -> Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error> {
6576            let _response = fidl::client::decode_transaction_body::<
6577                fidl::encoding::ResultType<
6578                    fidl::encoding::EmptyStruct,
6579                    PeriodicAdvertisingSyncTransferError,
6580                >,
6581                fidl::encoding::DefaultFuchsiaResourceDialect,
6582                0x441a31a7effa7e2b,
6583            >(_buf?)?;
6584            Ok(_response.map(|x| x))
6585        }
6586        self.client.send_query_and_decode::<
6587            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6588            ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
6589        >(
6590            &mut payload,
6591            0x441a31a7effa7e2b,
6592            fidl::encoding::DynamicFlags::empty(),
6593            _decode,
6594        )
6595    }
6596}
6597
6598pub struct ConnectionEventStream {
6599    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6600}
6601
6602impl std::marker::Unpin for ConnectionEventStream {}
6603
6604impl futures::stream::FusedStream for ConnectionEventStream {
6605    fn is_terminated(&self) -> bool {
6606        self.event_receiver.is_terminated()
6607    }
6608}
6609
6610impl futures::Stream for ConnectionEventStream {
6611    type Item = Result<ConnectionEvent, fidl::Error>;
6612
6613    fn poll_next(
6614        mut self: std::pin::Pin<&mut Self>,
6615        cx: &mut std::task::Context<'_>,
6616    ) -> std::task::Poll<Option<Self::Item>> {
6617        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6618            &mut self.event_receiver,
6619            cx
6620        )?) {
6621            Some(buf) => std::task::Poll::Ready(Some(ConnectionEvent::decode(buf))),
6622            None => std::task::Poll::Ready(None),
6623        }
6624    }
6625}
6626
6627#[derive(Debug)]
6628pub enum ConnectionEvent {}
6629
6630impl ConnectionEvent {
6631    /// Decodes a message buffer as a [`ConnectionEvent`].
6632    fn decode(
6633        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6634    ) -> Result<ConnectionEvent, fidl::Error> {
6635        let (bytes, _handles) = buf.split_mut();
6636        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6637        debug_assert_eq!(tx_header.tx_id, 0);
6638        match tx_header.ordinal {
6639            _ => Err(fidl::Error::UnknownOrdinal {
6640                ordinal: tx_header.ordinal,
6641                protocol_name: <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6642            }),
6643        }
6644    }
6645}
6646
6647/// A Stream of incoming requests for fuchsia.bluetooth.le/Connection.
6648pub struct ConnectionRequestStream {
6649    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6650    is_terminated: bool,
6651}
6652
6653impl std::marker::Unpin for ConnectionRequestStream {}
6654
6655impl futures::stream::FusedStream for ConnectionRequestStream {
6656    fn is_terminated(&self) -> bool {
6657        self.is_terminated
6658    }
6659}
6660
6661impl fidl::endpoints::RequestStream for ConnectionRequestStream {
6662    type Protocol = ConnectionMarker;
6663    type ControlHandle = ConnectionControlHandle;
6664
6665    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6666        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6667    }
6668
6669    fn control_handle(&self) -> Self::ControlHandle {
6670        ConnectionControlHandle { inner: self.inner.clone() }
6671    }
6672
6673    fn into_inner(
6674        self,
6675    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6676    {
6677        (self.inner, self.is_terminated)
6678    }
6679
6680    fn from_inner(
6681        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6682        is_terminated: bool,
6683    ) -> Self {
6684        Self { inner, is_terminated }
6685    }
6686}
6687
6688impl futures::Stream for ConnectionRequestStream {
6689    type Item = Result<ConnectionRequest, fidl::Error>;
6690
6691    fn poll_next(
6692        mut self: std::pin::Pin<&mut Self>,
6693        cx: &mut std::task::Context<'_>,
6694    ) -> std::task::Poll<Option<Self::Item>> {
6695        let this = &mut *self;
6696        if this.inner.check_shutdown(cx) {
6697            this.is_terminated = true;
6698            return std::task::Poll::Ready(None);
6699        }
6700        if this.is_terminated {
6701            panic!("polled ConnectionRequestStream after completion");
6702        }
6703        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6704            |bytes, handles| {
6705                match this.inner.channel().read_etc(cx, bytes, handles) {
6706                    std::task::Poll::Ready(Ok(())) => {}
6707                    std::task::Poll::Pending => return std::task::Poll::Pending,
6708                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6709                        this.is_terminated = true;
6710                        return std::task::Poll::Ready(None);
6711                    }
6712                    std::task::Poll::Ready(Err(e)) => {
6713                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6714                            e.into(),
6715                        ))));
6716                    }
6717                }
6718
6719                // A message has been received from the channel
6720                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6721
6722                std::task::Poll::Ready(Some(match header.ordinal {
6723                    0x1cf34fdeed80b4d => {
6724                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6725                        let mut req = fidl::new_empty!(
6726                            CodecDelayGetCodecLocalDelayRangeRequest,
6727                            fidl::encoding::DefaultFuchsiaResourceDialect
6728                        );
6729                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecDelayGetCodecLocalDelayRangeRequest>(&header, _body_bytes, handles, &mut req)?;
6730                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6731                        Ok(ConnectionRequest::GetCodecLocalDelayRange {
6732                            payload: req,
6733                            responder: ConnectionGetCodecLocalDelayRangeResponder {
6734                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6735                                tx_id: header.tx_id,
6736                            },
6737                        })
6738                    }
6739                    0x2a670e0fec6ccc6b => {
6740                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6741                        let mut req = fidl::new_empty!(
6742                            ConnectionRequestGattClientRequest,
6743                            fidl::encoding::DefaultFuchsiaResourceDialect
6744                        );
6745                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionRequestGattClientRequest>(&header, _body_bytes, handles, &mut req)?;
6746                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6747                        Ok(ConnectionRequest::RequestGattClient {
6748                            client: req.client,
6749
6750                            control_handle,
6751                        })
6752                    }
6753                    0x7e6338c237088144 => {
6754                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6755                        let mut req = fidl::new_empty!(
6756                            ConnectionAcceptCisRequest,
6757                            fidl::encoding::DefaultFuchsiaResourceDialect
6758                        );
6759                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionAcceptCisRequest>(&header, _body_bytes, handles, &mut req)?;
6760                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6761                        Ok(ConnectionRequest::AcceptCis { payload: req, control_handle })
6762                    }
6763                    0x12351316feaebce9 => {
6764                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6765                        let mut req = fidl::new_empty!(
6766                            ConnectionConnectL2capRequest,
6767                            fidl::encoding::DefaultFuchsiaResourceDialect
6768                        );
6769                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionConnectL2capRequest>(&header, _body_bytes, handles, &mut req)?;
6770                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6771                        Ok(ConnectionRequest::ConnectL2cap { payload: req, control_handle })
6772                    }
6773                    0x1117a10b5ba1e219 => {
6774                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6775                        let mut req = fidl::new_empty!(
6776                            ConnectionTransferPeriodicAdvertisingSyncRequest,
6777                            fidl::encoding::DefaultFuchsiaResourceDialect
6778                        );
6779                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionTransferPeriodicAdvertisingSyncRequest>(&header, _body_bytes, handles, &mut req)?;
6780                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6781                        Ok(ConnectionRequest::TransferPeriodicAdvertisingSync {
6782                            payload: req,
6783                            responder: ConnectionTransferPeriodicAdvertisingSyncResponder {
6784                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6785                                tx_id: header.tx_id,
6786                            },
6787                        })
6788                    }
6789                    0x441a31a7effa7e2b => {
6790                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6791                        let mut req = fidl::new_empty!(
6792                            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6793                            fidl::encoding::DefaultFuchsiaResourceDialect
6794                        );
6795                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionAcceptPeriodicAdvertisingSyncTransferRequest>(&header, _body_bytes, handles, &mut req)?;
6796                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6797                        Ok(ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer {
6798                            payload: req,
6799                            responder: ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
6800                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6801                                tx_id: header.tx_id,
6802                            },
6803                        })
6804                    }
6805                    _ => Err(fidl::Error::UnknownOrdinal {
6806                        ordinal: header.ordinal,
6807                        protocol_name:
6808                            <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6809                    }),
6810                }))
6811            },
6812        )
6813    }
6814}
6815
6816/// Protocol that represents the connection to a peer. This can be used to interact with GATT
6817/// services and establish L2CAP channels.
6818///
6819/// This lifetime of this capability is tied to that of the LE connection it represents. Closing the
6820/// channel results in a disconnection if no other clients hold a Connection to the same peer.
6821#[derive(Debug)]
6822pub enum ConnectionRequest {
6823    /// Retrieve the range of controller delay for the codec specified with the provided stream
6824    /// attributes.
6825    ///
6826    /// On success, returns the minimum and maximum allowed delay.
6827    ///
6828    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
6829    /// Returns ZX_ERR_INTERNAL for all other failures.
6830    GetCodecLocalDelayRange {
6831        payload: CodecDelayGetCodecLocalDelayRangeRequest,
6832        responder: ConnectionGetCodecLocalDelayRangeResponder,
6833    },
6834    /// The following epitaphs may be sent by the server on error:
6835    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
6836    ///                           protocol. The existing Client should be used.
6837    RequestGattClient {
6838        client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6839        control_handle: ConnectionControlHandle,
6840    },
6841    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
6842    /// CIS requests that have not explicitly been allowed will be rejected.
6843    ///
6844    /// The provided IsochronousStream will be used for future notification of established
6845    /// connections.
6846    ///
6847    /// The host may wait for multiple incoming connections simultaneously, although each
6848    /// must have a combination of CIG/CIS values that is unique to this connection.
6849    ///
6850    /// If we are not operating in the peripheral role in this connection, connection_stream
6851    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
6852    ///
6853    /// If we are already waiting for another connection with the same combination of CIG/CIS
6854    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
6855    AcceptCis { payload: ConnectionAcceptCisRequest, control_handle: ConnectionControlHandle },
6856    /// Connect to an L2CAP LE connection-oriented channel.
6857    ConnectL2cap { payload: ConnectionConnectL2capRequest, control_handle: ConnectionControlHandle },
6858    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
6859    /// the connected peer.
6860    TransferPeriodicAdvertisingSync {
6861        payload: ConnectionTransferPeriodicAdvertisingSyncRequest,
6862        responder: ConnectionTransferPeriodicAdvertisingSyncResponder,
6863    },
6864    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
6865    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
6866    AcceptPeriodicAdvertisingSyncTransfer {
6867        payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6868        responder: ConnectionAcceptPeriodicAdvertisingSyncTransferResponder,
6869    },
6870}
6871
6872impl ConnectionRequest {
6873    #[allow(irrefutable_let_patterns)]
6874    pub fn into_get_codec_local_delay_range(
6875        self,
6876    ) -> Option<(
6877        CodecDelayGetCodecLocalDelayRangeRequest,
6878        ConnectionGetCodecLocalDelayRangeResponder,
6879    )> {
6880        if let ConnectionRequest::GetCodecLocalDelayRange { payload, responder } = self {
6881            Some((payload, responder))
6882        } else {
6883            None
6884        }
6885    }
6886
6887    #[allow(irrefutable_let_patterns)]
6888    pub fn into_request_gatt_client(
6889        self,
6890    ) -> Option<(
6891        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6892        ConnectionControlHandle,
6893    )> {
6894        if let ConnectionRequest::RequestGattClient { client, control_handle } = self {
6895            Some((client, control_handle))
6896        } else {
6897            None
6898        }
6899    }
6900
6901    #[allow(irrefutable_let_patterns)]
6902    pub fn into_accept_cis(self) -> Option<(ConnectionAcceptCisRequest, ConnectionControlHandle)> {
6903        if let ConnectionRequest::AcceptCis { payload, control_handle } = self {
6904            Some((payload, control_handle))
6905        } else {
6906            None
6907        }
6908    }
6909
6910    #[allow(irrefutable_let_patterns)]
6911    pub fn into_connect_l2cap(
6912        self,
6913    ) -> Option<(ConnectionConnectL2capRequest, ConnectionControlHandle)> {
6914        if let ConnectionRequest::ConnectL2cap { payload, control_handle } = self {
6915            Some((payload, control_handle))
6916        } else {
6917            None
6918        }
6919    }
6920
6921    #[allow(irrefutable_let_patterns)]
6922    pub fn into_transfer_periodic_advertising_sync(
6923        self,
6924    ) -> Option<(
6925        ConnectionTransferPeriodicAdvertisingSyncRequest,
6926        ConnectionTransferPeriodicAdvertisingSyncResponder,
6927    )> {
6928        if let ConnectionRequest::TransferPeriodicAdvertisingSync { payload, responder } = self {
6929            Some((payload, responder))
6930        } else {
6931            None
6932        }
6933    }
6934
6935    #[allow(irrefutable_let_patterns)]
6936    pub fn into_accept_periodic_advertising_sync_transfer(
6937        self,
6938    ) -> Option<(
6939        ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6940        ConnectionAcceptPeriodicAdvertisingSyncTransferResponder,
6941    )> {
6942        if let ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer { payload, responder } =
6943            self
6944        {
6945            Some((payload, responder))
6946        } else {
6947            None
6948        }
6949    }
6950
6951    /// Name of the method defined in FIDL
6952    pub fn method_name(&self) -> &'static str {
6953        match *self {
6954            ConnectionRequest::GetCodecLocalDelayRange { .. } => "get_codec_local_delay_range",
6955            ConnectionRequest::RequestGattClient { .. } => "request_gatt_client",
6956            ConnectionRequest::AcceptCis { .. } => "accept_cis",
6957            ConnectionRequest::ConnectL2cap { .. } => "connect_l2cap",
6958            ConnectionRequest::TransferPeriodicAdvertisingSync { .. } => {
6959                "transfer_periodic_advertising_sync"
6960            }
6961            ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer { .. } => {
6962                "accept_periodic_advertising_sync_transfer"
6963            }
6964        }
6965    }
6966}
6967
6968#[derive(Debug, Clone)]
6969pub struct ConnectionControlHandle {
6970    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6971}
6972
6973impl ConnectionControlHandle {
6974    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6975        self.inner.shutdown_with_epitaph(status.into())
6976    }
6977}
6978
6979impl fidl::endpoints::ControlHandle for ConnectionControlHandle {
6980    fn shutdown(&self) {
6981        self.inner.shutdown()
6982    }
6983
6984    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6985        self.inner.shutdown_with_epitaph(status)
6986    }
6987
6988    fn is_closed(&self) -> bool {
6989        self.inner.channel().is_closed()
6990    }
6991    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6992        self.inner.channel().on_closed()
6993    }
6994
6995    #[cfg(target_os = "fuchsia")]
6996    fn signal_peer(
6997        &self,
6998        clear_mask: zx::Signals,
6999        set_mask: zx::Signals,
7000    ) -> Result<(), zx_status::Status> {
7001        use fidl::Peered;
7002        self.inner.channel().signal_peer(clear_mask, set_mask)
7003    }
7004}
7005
7006impl ConnectionControlHandle {}
7007
7008#[must_use = "FIDL methods require a response to be sent"]
7009#[derive(Debug)]
7010pub struct ConnectionGetCodecLocalDelayRangeResponder {
7011    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
7012    tx_id: u32,
7013}
7014
7015/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
7016/// if the responder is dropped without sending a response, so that the client
7017/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7018impl std::ops::Drop for ConnectionGetCodecLocalDelayRangeResponder {
7019    fn drop(&mut self) {
7020        self.control_handle.shutdown();
7021        // Safety: drops once, never accessed again
7022        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7023    }
7024}
7025
7026impl fidl::endpoints::Responder for ConnectionGetCodecLocalDelayRangeResponder {
7027    type ControlHandle = ConnectionControlHandle;
7028
7029    fn control_handle(&self) -> &ConnectionControlHandle {
7030        &self.control_handle
7031    }
7032
7033    fn drop_without_shutdown(mut self) {
7034        // Safety: drops once, never accessed again due to mem::forget
7035        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7036        // Prevent Drop from running (which would shut down the channel)
7037        std::mem::forget(self);
7038    }
7039}
7040
7041impl ConnectionGetCodecLocalDelayRangeResponder {
7042    /// Sends a response to the FIDL transaction.
7043    ///
7044    /// Sets the channel to shutdown if an error occurs.
7045    pub fn send(
7046        self,
7047        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
7048    ) -> Result<(), fidl::Error> {
7049        let _result = self.send_raw(result);
7050        if _result.is_err() {
7051            self.control_handle.shutdown();
7052        }
7053        self.drop_without_shutdown();
7054        _result
7055    }
7056
7057    /// Similar to "send" but does not shutdown the channel if an error occurs.
7058    pub fn send_no_shutdown_on_err(
7059        self,
7060        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
7061    ) -> Result<(), fidl::Error> {
7062        let _result = self.send_raw(result);
7063        self.drop_without_shutdown();
7064        _result
7065    }
7066
7067    fn send_raw(
7068        &self,
7069        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
7070    ) -> Result<(), fidl::Error> {
7071        self.control_handle.inner.send::<fidl::encoding::ResultType<
7072            CodecDelayGetCodecLocalDelayRangeResponse,
7073            i32,
7074        >>(
7075            result,
7076            self.tx_id,
7077            0x1cf34fdeed80b4d,
7078            fidl::encoding::DynamicFlags::empty(),
7079        )
7080    }
7081}
7082
7083#[must_use = "FIDL methods require a response to be sent"]
7084#[derive(Debug)]
7085pub struct ConnectionTransferPeriodicAdvertisingSyncResponder {
7086    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
7087    tx_id: u32,
7088}
7089
7090/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
7091/// if the responder is dropped without sending a response, so that the client
7092/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7093impl std::ops::Drop for ConnectionTransferPeriodicAdvertisingSyncResponder {
7094    fn drop(&mut self) {
7095        self.control_handle.shutdown();
7096        // Safety: drops once, never accessed again
7097        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7098    }
7099}
7100
7101impl fidl::endpoints::Responder for ConnectionTransferPeriodicAdvertisingSyncResponder {
7102    type ControlHandle = ConnectionControlHandle;
7103
7104    fn control_handle(&self) -> &ConnectionControlHandle {
7105        &self.control_handle
7106    }
7107
7108    fn drop_without_shutdown(mut self) {
7109        // Safety: drops once, never accessed again due to mem::forget
7110        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7111        // Prevent Drop from running (which would shut down the channel)
7112        std::mem::forget(self);
7113    }
7114}
7115
7116impl ConnectionTransferPeriodicAdvertisingSyncResponder {
7117    /// Sends a response to the FIDL transaction.
7118    ///
7119    /// Sets the channel to shutdown if an error occurs.
7120    pub fn send(
7121        self,
7122        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7123    ) -> Result<(), fidl::Error> {
7124        let _result = self.send_raw(result);
7125        if _result.is_err() {
7126            self.control_handle.shutdown();
7127        }
7128        self.drop_without_shutdown();
7129        _result
7130    }
7131
7132    /// Similar to "send" but does not shutdown the channel if an error occurs.
7133    pub fn send_no_shutdown_on_err(
7134        self,
7135        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7136    ) -> Result<(), fidl::Error> {
7137        let _result = self.send_raw(result);
7138        self.drop_without_shutdown();
7139        _result
7140    }
7141
7142    fn send_raw(
7143        &self,
7144        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7145    ) -> Result<(), fidl::Error> {
7146        self.control_handle.inner.send::<fidl::encoding::ResultType<
7147            fidl::encoding::EmptyStruct,
7148            PeriodicAdvertisingSyncTransferError,
7149        >>(
7150            result,
7151            self.tx_id,
7152            0x1117a10b5ba1e219,
7153            fidl::encoding::DynamicFlags::empty(),
7154        )
7155    }
7156}
7157
7158#[must_use = "FIDL methods require a response to be sent"]
7159#[derive(Debug)]
7160pub struct ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
7161    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
7162    tx_id: u32,
7163}
7164
7165/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
7166/// if the responder is dropped without sending a response, so that the client
7167/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7168impl std::ops::Drop for ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
7169    fn drop(&mut self) {
7170        self.control_handle.shutdown();
7171        // Safety: drops once, never accessed again
7172        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7173    }
7174}
7175
7176impl fidl::endpoints::Responder for ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
7177    type ControlHandle = ConnectionControlHandle;
7178
7179    fn control_handle(&self) -> &ConnectionControlHandle {
7180        &self.control_handle
7181    }
7182
7183    fn drop_without_shutdown(mut self) {
7184        // Safety: drops once, never accessed again due to mem::forget
7185        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7186        // Prevent Drop from running (which would shut down the channel)
7187        std::mem::forget(self);
7188    }
7189}
7190
7191impl ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
7192    /// Sends a response to the FIDL transaction.
7193    ///
7194    /// Sets the channel to shutdown if an error occurs.
7195    pub fn send(
7196        self,
7197        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7198    ) -> Result<(), fidl::Error> {
7199        let _result = self.send_raw(result);
7200        if _result.is_err() {
7201            self.control_handle.shutdown();
7202        }
7203        self.drop_without_shutdown();
7204        _result
7205    }
7206
7207    /// Similar to "send" but does not shutdown the channel if an error occurs.
7208    pub fn send_no_shutdown_on_err(
7209        self,
7210        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7211    ) -> Result<(), fidl::Error> {
7212        let _result = self.send_raw(result);
7213        self.drop_without_shutdown();
7214        _result
7215    }
7216
7217    fn send_raw(
7218        &self,
7219        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7220    ) -> Result<(), fidl::Error> {
7221        self.control_handle.inner.send::<fidl::encoding::ResultType<
7222            fidl::encoding::EmptyStruct,
7223            PeriodicAdvertisingSyncTransferError,
7224        >>(
7225            result,
7226            self.tx_id,
7227            0x441a31a7effa7e2b,
7228            fidl::encoding::DynamicFlags::empty(),
7229        )
7230    }
7231}
7232
7233#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7234pub struct IsochronousStreamMarker;
7235
7236impl fidl::endpoints::ProtocolMarker for IsochronousStreamMarker {
7237    type Proxy = IsochronousStreamProxy;
7238    type RequestStream = IsochronousStreamRequestStream;
7239    #[cfg(target_os = "fuchsia")]
7240    type SynchronousProxy = IsochronousStreamSynchronousProxy;
7241
7242    const DEBUG_NAME: &'static str = "(anonymous) IsochronousStream";
7243}
7244pub type IsochronousStreamSetupDataPathResult = Result<(), i32>;
7245pub type IsochronousStreamWriteResult = Result<(), i32>;
7246
7247pub trait IsochronousStreamProxyInterface: Send + Sync {
7248    type SetupDataPathResponseFut: std::future::Future<Output = Result<IsochronousStreamSetupDataPathResult, fidl::Error>>
7249        + Send;
7250    fn r#setup_data_path(
7251        &self,
7252        payload: &IsochronousStreamSetupDataPathRequest,
7253    ) -> Self::SetupDataPathResponseFut;
7254    type ReadResponseFut: std::future::Future<Output = Result<IsochronousStreamReadResponse, fidl::Error>>
7255        + Send;
7256    fn r#read(&self) -> Self::ReadResponseFut;
7257    type WriteResponseFut: std::future::Future<Output = Result<IsochronousStreamWriteResult, fidl::Error>>
7258        + Send;
7259    fn r#write(&self, payload: &IsochronousStreamWriteRequest) -> Self::WriteResponseFut;
7260}
7261#[derive(Debug)]
7262#[cfg(target_os = "fuchsia")]
7263pub struct IsochronousStreamSynchronousProxy {
7264    client: fidl::client::sync::Client,
7265}
7266
7267#[cfg(target_os = "fuchsia")]
7268impl fidl::endpoints::SynchronousProxy for IsochronousStreamSynchronousProxy {
7269    type Proxy = IsochronousStreamProxy;
7270    type Protocol = IsochronousStreamMarker;
7271
7272    fn from_channel(inner: fidl::Channel) -> Self {
7273        Self::new(inner)
7274    }
7275
7276    fn into_channel(self) -> fidl::Channel {
7277        self.client.into_channel()
7278    }
7279
7280    fn as_channel(&self) -> &fidl::Channel {
7281        self.client.as_channel()
7282    }
7283}
7284
7285#[cfg(target_os = "fuchsia")]
7286impl IsochronousStreamSynchronousProxy {
7287    pub fn new(channel: fidl::Channel) -> Self {
7288        Self { client: fidl::client::sync::Client::new(channel) }
7289    }
7290
7291    pub fn into_channel(self) -> fidl::Channel {
7292        self.client.into_channel()
7293    }
7294
7295    /// Waits until an event arrives and returns it. It is safe for other
7296    /// threads to make concurrent requests while waiting for an event.
7297    pub fn wait_for_event(
7298        &self,
7299        deadline: zx::MonotonicInstant,
7300    ) -> Result<IsochronousStreamEvent, fidl::Error> {
7301        IsochronousStreamEvent::decode(
7302            self.client.wait_for_event::<IsochronousStreamMarker>(deadline)?,
7303        )
7304    }
7305
7306    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
7307    /// transport is currently supported.
7308    ///
7309    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
7310    /// direction.
7311    ///
7312    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
7313    /// accepted.
7314    ///
7315    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
7316    /// controller's supported range.
7317    pub fn r#setup_data_path(
7318        &self,
7319        mut payload: &IsochronousStreamSetupDataPathRequest,
7320        ___deadline: zx::MonotonicInstant,
7321    ) -> Result<IsochronousStreamSetupDataPathResult, fidl::Error> {
7322        let _response = self.client.send_query::<
7323            IsochronousStreamSetupDataPathRequest,
7324            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7325            IsochronousStreamMarker,
7326        >(
7327            payload,
7328            0x7ec1e2b9cc6d2fbe,
7329            fidl::encoding::DynamicFlags::FLEXIBLE,
7330            ___deadline,
7331        )?
7332        .into_result::<IsochronousStreamMarker>("setup_data_path")?;
7333        Ok(_response.map(|x| x))
7334    }
7335
7336    /// Receive data from an output (controller => host) ISO stream that has been established and
7337    /// set up. Designed to be used with a hanging get pattern.
7338    ///
7339    /// Can be invoked before the ISO data stream has been established and set up, but will not
7340    /// return until after it has been set up and data has been received.
7341    pub fn r#read(
7342        &self,
7343        ___deadline: zx::MonotonicInstant,
7344    ) -> Result<IsochronousStreamReadResponse, fidl::Error> {
7345        let _response = self.client.send_query::<
7346            fidl::encoding::EmptyPayload,
7347            fidl::encoding::FlexibleType<IsochronousStreamReadResponse>,
7348            IsochronousStreamMarker,
7349        >(
7350            (),
7351            0x6d7d8b4950ed3a32,
7352            fidl::encoding::DynamicFlags::FLEXIBLE,
7353            ___deadline,
7354        )?
7355        .into_result::<IsochronousStreamMarker>("read")?;
7356        Ok(_response)
7357    }
7358
7359    /// Send data to an established ISO stream (host => controller).
7360    ///
7361    /// Returns ZX_ERR_INTERNAL for any errors encountered.
7362    pub fn r#write(
7363        &self,
7364        mut payload: &IsochronousStreamWriteRequest,
7365        ___deadline: zx::MonotonicInstant,
7366    ) -> Result<IsochronousStreamWriteResult, fidl::Error> {
7367        let _response = self.client.send_query::<
7368            IsochronousStreamWriteRequest,
7369            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7370            IsochronousStreamMarker,
7371        >(
7372            payload,
7373            0x5282e90b667d0d43,
7374            fidl::encoding::DynamicFlags::FLEXIBLE,
7375            ___deadline,
7376        )?
7377        .into_result::<IsochronousStreamMarker>("write")?;
7378        Ok(_response.map(|x| x))
7379    }
7380}
7381
7382#[cfg(target_os = "fuchsia")]
7383impl From<IsochronousStreamSynchronousProxy> for zx::NullableHandle {
7384    fn from(value: IsochronousStreamSynchronousProxy) -> Self {
7385        value.into_channel().into()
7386    }
7387}
7388
7389#[cfg(target_os = "fuchsia")]
7390impl From<fidl::Channel> for IsochronousStreamSynchronousProxy {
7391    fn from(value: fidl::Channel) -> Self {
7392        Self::new(value)
7393    }
7394}
7395
7396#[cfg(target_os = "fuchsia")]
7397impl fidl::endpoints::FromClient for IsochronousStreamSynchronousProxy {
7398    type Protocol = IsochronousStreamMarker;
7399
7400    fn from_client(value: fidl::endpoints::ClientEnd<IsochronousStreamMarker>) -> Self {
7401        Self::new(value.into_channel())
7402    }
7403}
7404
7405#[derive(Debug, Clone)]
7406pub struct IsochronousStreamProxy {
7407    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7408}
7409
7410impl fidl::endpoints::Proxy for IsochronousStreamProxy {
7411    type Protocol = IsochronousStreamMarker;
7412
7413    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7414        Self::new(inner)
7415    }
7416
7417    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7418        self.client.into_channel().map_err(|client| Self { client })
7419    }
7420
7421    fn as_channel(&self) -> &::fidl::AsyncChannel {
7422        self.client.as_channel()
7423    }
7424}
7425
7426impl IsochronousStreamProxy {
7427    /// Create a new Proxy for fuchsia.bluetooth.le/IsochronousStream.
7428    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7429        let protocol_name =
7430            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7431        Self { client: fidl::client::Client::new(channel, protocol_name) }
7432    }
7433
7434    /// Get a Stream of events from the remote end of the protocol.
7435    ///
7436    /// # Panics
7437    ///
7438    /// Panics if the event stream was already taken.
7439    pub fn take_event_stream(&self) -> IsochronousStreamEventStream {
7440        IsochronousStreamEventStream { event_receiver: self.client.take_event_receiver() }
7441    }
7442
7443    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
7444    /// transport is currently supported.
7445    ///
7446    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
7447    /// direction.
7448    ///
7449    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
7450    /// accepted.
7451    ///
7452    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
7453    /// controller's supported range.
7454    pub fn r#setup_data_path(
7455        &self,
7456        mut payload: &IsochronousStreamSetupDataPathRequest,
7457    ) -> fidl::client::QueryResponseFut<
7458        IsochronousStreamSetupDataPathResult,
7459        fidl::encoding::DefaultFuchsiaResourceDialect,
7460    > {
7461        IsochronousStreamProxyInterface::r#setup_data_path(self, payload)
7462    }
7463
7464    /// Receive data from an output (controller => host) ISO stream that has been established and
7465    /// set up. Designed to be used with a hanging get pattern.
7466    ///
7467    /// Can be invoked before the ISO data stream has been established and set up, but will not
7468    /// return until after it has been set up and data has been received.
7469    pub fn r#read(
7470        &self,
7471    ) -> fidl::client::QueryResponseFut<
7472        IsochronousStreamReadResponse,
7473        fidl::encoding::DefaultFuchsiaResourceDialect,
7474    > {
7475        IsochronousStreamProxyInterface::r#read(self)
7476    }
7477
7478    /// Send data to an established ISO stream (host => controller).
7479    ///
7480    /// Returns ZX_ERR_INTERNAL for any errors encountered.
7481    pub fn r#write(
7482        &self,
7483        mut payload: &IsochronousStreamWriteRequest,
7484    ) -> fidl::client::QueryResponseFut<
7485        IsochronousStreamWriteResult,
7486        fidl::encoding::DefaultFuchsiaResourceDialect,
7487    > {
7488        IsochronousStreamProxyInterface::r#write(self, payload)
7489    }
7490}
7491
7492impl IsochronousStreamProxyInterface for IsochronousStreamProxy {
7493    type SetupDataPathResponseFut = fidl::client::QueryResponseFut<
7494        IsochronousStreamSetupDataPathResult,
7495        fidl::encoding::DefaultFuchsiaResourceDialect,
7496    >;
7497    fn r#setup_data_path(
7498        &self,
7499        mut payload: &IsochronousStreamSetupDataPathRequest,
7500    ) -> Self::SetupDataPathResponseFut {
7501        fn _decode(
7502            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7503        ) -> Result<IsochronousStreamSetupDataPathResult, fidl::Error> {
7504            let _response = fidl::client::decode_transaction_body::<
7505                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7506                fidl::encoding::DefaultFuchsiaResourceDialect,
7507                0x7ec1e2b9cc6d2fbe,
7508            >(_buf?)?
7509            .into_result::<IsochronousStreamMarker>("setup_data_path")?;
7510            Ok(_response.map(|x| x))
7511        }
7512        self.client.send_query_and_decode::<
7513            IsochronousStreamSetupDataPathRequest,
7514            IsochronousStreamSetupDataPathResult,
7515        >(
7516            payload,
7517            0x7ec1e2b9cc6d2fbe,
7518            fidl::encoding::DynamicFlags::FLEXIBLE,
7519            _decode,
7520        )
7521    }
7522
7523    type ReadResponseFut = fidl::client::QueryResponseFut<
7524        IsochronousStreamReadResponse,
7525        fidl::encoding::DefaultFuchsiaResourceDialect,
7526    >;
7527    fn r#read(&self) -> Self::ReadResponseFut {
7528        fn _decode(
7529            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7530        ) -> Result<IsochronousStreamReadResponse, fidl::Error> {
7531            let _response = fidl::client::decode_transaction_body::<
7532                fidl::encoding::FlexibleType<IsochronousStreamReadResponse>,
7533                fidl::encoding::DefaultFuchsiaResourceDialect,
7534                0x6d7d8b4950ed3a32,
7535            >(_buf?)?
7536            .into_result::<IsochronousStreamMarker>("read")?;
7537            Ok(_response)
7538        }
7539        self.client
7540            .send_query_and_decode::<fidl::encoding::EmptyPayload, IsochronousStreamReadResponse>(
7541                (),
7542                0x6d7d8b4950ed3a32,
7543                fidl::encoding::DynamicFlags::FLEXIBLE,
7544                _decode,
7545            )
7546    }
7547
7548    type WriteResponseFut = fidl::client::QueryResponseFut<
7549        IsochronousStreamWriteResult,
7550        fidl::encoding::DefaultFuchsiaResourceDialect,
7551    >;
7552    fn r#write(&self, mut payload: &IsochronousStreamWriteRequest) -> Self::WriteResponseFut {
7553        fn _decode(
7554            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7555        ) -> Result<IsochronousStreamWriteResult, fidl::Error> {
7556            let _response = fidl::client::decode_transaction_body::<
7557                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7558                fidl::encoding::DefaultFuchsiaResourceDialect,
7559                0x5282e90b667d0d43,
7560            >(_buf?)?
7561            .into_result::<IsochronousStreamMarker>("write")?;
7562            Ok(_response.map(|x| x))
7563        }
7564        self.client
7565            .send_query_and_decode::<IsochronousStreamWriteRequest, IsochronousStreamWriteResult>(
7566                payload,
7567                0x5282e90b667d0d43,
7568                fidl::encoding::DynamicFlags::FLEXIBLE,
7569                _decode,
7570            )
7571    }
7572}
7573
7574pub struct IsochronousStreamEventStream {
7575    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7576}
7577
7578impl std::marker::Unpin for IsochronousStreamEventStream {}
7579
7580impl futures::stream::FusedStream for IsochronousStreamEventStream {
7581    fn is_terminated(&self) -> bool {
7582        self.event_receiver.is_terminated()
7583    }
7584}
7585
7586impl futures::Stream for IsochronousStreamEventStream {
7587    type Item = Result<IsochronousStreamEvent, fidl::Error>;
7588
7589    fn poll_next(
7590        mut self: std::pin::Pin<&mut Self>,
7591        cx: &mut std::task::Context<'_>,
7592    ) -> std::task::Poll<Option<Self::Item>> {
7593        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7594            &mut self.event_receiver,
7595            cx
7596        )?) {
7597            Some(buf) => std::task::Poll::Ready(Some(IsochronousStreamEvent::decode(buf))),
7598            None => std::task::Poll::Ready(None),
7599        }
7600    }
7601}
7602
7603#[derive(Debug)]
7604pub enum IsochronousStreamEvent {
7605    OnEstablished {
7606        payload: IsochronousStreamOnEstablishedRequest,
7607    },
7608    #[non_exhaustive]
7609    _UnknownEvent {
7610        /// Ordinal of the event that was sent.
7611        ordinal: u64,
7612    },
7613}
7614
7615impl IsochronousStreamEvent {
7616    #[allow(irrefutable_let_patterns)]
7617    pub fn into_on_established(self) -> Option<IsochronousStreamOnEstablishedRequest> {
7618        if let IsochronousStreamEvent::OnEstablished { payload } = self {
7619            Some((payload))
7620        } else {
7621            None
7622        }
7623    }
7624
7625    /// Decodes a message buffer as a [`IsochronousStreamEvent`].
7626    fn decode(
7627        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7628    ) -> Result<IsochronousStreamEvent, fidl::Error> {
7629        let (bytes, _handles) = buf.split_mut();
7630        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7631        debug_assert_eq!(tx_header.tx_id, 0);
7632        match tx_header.ordinal {
7633            0x341c50e9d10f3421 => {
7634                let mut out = fidl::new_empty!(
7635                    IsochronousStreamOnEstablishedRequest,
7636                    fidl::encoding::DefaultFuchsiaResourceDialect
7637                );
7638                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamOnEstablishedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7639                Ok((IsochronousStreamEvent::OnEstablished { payload: out }))
7640            }
7641            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7642                Ok(IsochronousStreamEvent::_UnknownEvent { ordinal: tx_header.ordinal })
7643            }
7644            _ => Err(fidl::Error::UnknownOrdinal {
7645                ordinal: tx_header.ordinal,
7646                protocol_name:
7647                    <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7648            }),
7649        }
7650    }
7651}
7652
7653/// A Stream of incoming requests for fuchsia.bluetooth.le/IsochronousStream.
7654pub struct IsochronousStreamRequestStream {
7655    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7656    is_terminated: bool,
7657}
7658
7659impl std::marker::Unpin for IsochronousStreamRequestStream {}
7660
7661impl futures::stream::FusedStream for IsochronousStreamRequestStream {
7662    fn is_terminated(&self) -> bool {
7663        self.is_terminated
7664    }
7665}
7666
7667impl fidl::endpoints::RequestStream for IsochronousStreamRequestStream {
7668    type Protocol = IsochronousStreamMarker;
7669    type ControlHandle = IsochronousStreamControlHandle;
7670
7671    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7672        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7673    }
7674
7675    fn control_handle(&self) -> Self::ControlHandle {
7676        IsochronousStreamControlHandle { inner: self.inner.clone() }
7677    }
7678
7679    fn into_inner(
7680        self,
7681    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7682    {
7683        (self.inner, self.is_terminated)
7684    }
7685
7686    fn from_inner(
7687        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7688        is_terminated: bool,
7689    ) -> Self {
7690        Self { inner, is_terminated }
7691    }
7692}
7693
7694impl futures::Stream for IsochronousStreamRequestStream {
7695    type Item = Result<IsochronousStreamRequest, fidl::Error>;
7696
7697    fn poll_next(
7698        mut self: std::pin::Pin<&mut Self>,
7699        cx: &mut std::task::Context<'_>,
7700    ) -> std::task::Poll<Option<Self::Item>> {
7701        let this = &mut *self;
7702        if this.inner.check_shutdown(cx) {
7703            this.is_terminated = true;
7704            return std::task::Poll::Ready(None);
7705        }
7706        if this.is_terminated {
7707            panic!("polled IsochronousStreamRequestStream after completion");
7708        }
7709        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7710            |bytes, handles| {
7711                match this.inner.channel().read_etc(cx, bytes, handles) {
7712                    std::task::Poll::Ready(Ok(())) => {}
7713                    std::task::Poll::Pending => return std::task::Poll::Pending,
7714                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7715                        this.is_terminated = true;
7716                        return std::task::Poll::Ready(None);
7717                    }
7718                    std::task::Poll::Ready(Err(e)) => {
7719                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7720                            e.into(),
7721                        ))));
7722                    }
7723                }
7724
7725                // A message has been received from the channel
7726                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7727
7728                std::task::Poll::Ready(Some(match header.ordinal {
7729                    0x7ec1e2b9cc6d2fbe => {
7730                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7731                        let mut req = fidl::new_empty!(
7732                            IsochronousStreamSetupDataPathRequest,
7733                            fidl::encoding::DefaultFuchsiaResourceDialect
7734                        );
7735                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamSetupDataPathRequest>(&header, _body_bytes, handles, &mut req)?;
7736                        let control_handle =
7737                            IsochronousStreamControlHandle { inner: this.inner.clone() };
7738                        Ok(IsochronousStreamRequest::SetupDataPath {
7739                            payload: req,
7740                            responder: IsochronousStreamSetupDataPathResponder {
7741                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7742                                tx_id: header.tx_id,
7743                            },
7744                        })
7745                    }
7746                    0x6d7d8b4950ed3a32 => {
7747                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7748                        let mut req = fidl::new_empty!(
7749                            fidl::encoding::EmptyPayload,
7750                            fidl::encoding::DefaultFuchsiaResourceDialect
7751                        );
7752                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7753                        let control_handle =
7754                            IsochronousStreamControlHandle { inner: this.inner.clone() };
7755                        Ok(IsochronousStreamRequest::Read {
7756                            responder: IsochronousStreamReadResponder {
7757                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7758                                tx_id: header.tx_id,
7759                            },
7760                        })
7761                    }
7762                    0x5282e90b667d0d43 => {
7763                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7764                        let mut req = fidl::new_empty!(
7765                            IsochronousStreamWriteRequest,
7766                            fidl::encoding::DefaultFuchsiaResourceDialect
7767                        );
7768                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamWriteRequest>(&header, _body_bytes, handles, &mut req)?;
7769                        let control_handle =
7770                            IsochronousStreamControlHandle { inner: this.inner.clone() };
7771                        Ok(IsochronousStreamRequest::Write {
7772                            payload: req,
7773                            responder: IsochronousStreamWriteResponder {
7774                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7775                                tx_id: header.tx_id,
7776                            },
7777                        })
7778                    }
7779                    _ if header.tx_id == 0
7780                        && header
7781                            .dynamic_flags()
7782                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7783                    {
7784                        Ok(IsochronousStreamRequest::_UnknownMethod {
7785                            ordinal: header.ordinal,
7786                            control_handle: IsochronousStreamControlHandle {
7787                                inner: this.inner.clone(),
7788                            },
7789                            method_type: fidl::MethodType::OneWay,
7790                        })
7791                    }
7792                    _ if header
7793                        .dynamic_flags()
7794                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7795                    {
7796                        this.inner.send_framework_err(
7797                            fidl::encoding::FrameworkErr::UnknownMethod,
7798                            header.tx_id,
7799                            header.ordinal,
7800                            header.dynamic_flags(),
7801                            (bytes, handles),
7802                        )?;
7803                        Ok(IsochronousStreamRequest::_UnknownMethod {
7804                            ordinal: header.ordinal,
7805                            control_handle: IsochronousStreamControlHandle {
7806                                inner: this.inner.clone(),
7807                            },
7808                            method_type: fidl::MethodType::TwoWay,
7809                        })
7810                    }
7811                    _ => Err(fidl::Error::UnknownOrdinal {
7812                        ordinal: header.ordinal,
7813                        protocol_name:
7814                            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7815                    }),
7816                }))
7817            },
7818        )
7819    }
7820}
7821
7822#[derive(Debug)]
7823pub enum IsochronousStreamRequest {
7824    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
7825    /// transport is currently supported.
7826    ///
7827    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
7828    /// direction.
7829    ///
7830    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
7831    /// accepted.
7832    ///
7833    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
7834    /// controller's supported range.
7835    SetupDataPath {
7836        payload: IsochronousStreamSetupDataPathRequest,
7837        responder: IsochronousStreamSetupDataPathResponder,
7838    },
7839    /// Receive data from an output (controller => host) ISO stream that has been established and
7840    /// set up. Designed to be used with a hanging get pattern.
7841    ///
7842    /// Can be invoked before the ISO data stream has been established and set up, but will not
7843    /// return until after it has been set up and data has been received.
7844    Read { responder: IsochronousStreamReadResponder },
7845    /// Send data to an established ISO stream (host => controller).
7846    ///
7847    /// Returns ZX_ERR_INTERNAL for any errors encountered.
7848    Write { payload: IsochronousStreamWriteRequest, responder: IsochronousStreamWriteResponder },
7849    /// An interaction was received which does not match any known method.
7850    #[non_exhaustive]
7851    _UnknownMethod {
7852        /// Ordinal of the method that was called.
7853        ordinal: u64,
7854        control_handle: IsochronousStreamControlHandle,
7855        method_type: fidl::MethodType,
7856    },
7857}
7858
7859impl IsochronousStreamRequest {
7860    #[allow(irrefutable_let_patterns)]
7861    pub fn into_setup_data_path(
7862        self,
7863    ) -> Option<(IsochronousStreamSetupDataPathRequest, IsochronousStreamSetupDataPathResponder)>
7864    {
7865        if let IsochronousStreamRequest::SetupDataPath { payload, responder } = self {
7866            Some((payload, responder))
7867        } else {
7868            None
7869        }
7870    }
7871
7872    #[allow(irrefutable_let_patterns)]
7873    pub fn into_read(self) -> Option<(IsochronousStreamReadResponder)> {
7874        if let IsochronousStreamRequest::Read { responder } = self {
7875            Some((responder))
7876        } else {
7877            None
7878        }
7879    }
7880
7881    #[allow(irrefutable_let_patterns)]
7882    pub fn into_write(
7883        self,
7884    ) -> Option<(IsochronousStreamWriteRequest, IsochronousStreamWriteResponder)> {
7885        if let IsochronousStreamRequest::Write { payload, responder } = self {
7886            Some((payload, responder))
7887        } else {
7888            None
7889        }
7890    }
7891
7892    /// Name of the method defined in FIDL
7893    pub fn method_name(&self) -> &'static str {
7894        match *self {
7895            IsochronousStreamRequest::SetupDataPath { .. } => "setup_data_path",
7896            IsochronousStreamRequest::Read { .. } => "read",
7897            IsochronousStreamRequest::Write { .. } => "write",
7898            IsochronousStreamRequest::_UnknownMethod {
7899                method_type: fidl::MethodType::OneWay,
7900                ..
7901            } => "unknown one-way method",
7902            IsochronousStreamRequest::_UnknownMethod {
7903                method_type: fidl::MethodType::TwoWay,
7904                ..
7905            } => "unknown two-way method",
7906        }
7907    }
7908}
7909
7910#[derive(Debug, Clone)]
7911pub struct IsochronousStreamControlHandle {
7912    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7913}
7914
7915impl IsochronousStreamControlHandle {
7916    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
7917        self.inner.shutdown_with_epitaph(status.into())
7918    }
7919}
7920
7921impl fidl::endpoints::ControlHandle for IsochronousStreamControlHandle {
7922    fn shutdown(&self) {
7923        self.inner.shutdown()
7924    }
7925
7926    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
7927        self.inner.shutdown_with_epitaph(status)
7928    }
7929
7930    fn is_closed(&self) -> bool {
7931        self.inner.channel().is_closed()
7932    }
7933    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7934        self.inner.channel().on_closed()
7935    }
7936
7937    #[cfg(target_os = "fuchsia")]
7938    fn signal_peer(
7939        &self,
7940        clear_mask: zx::Signals,
7941        set_mask: zx::Signals,
7942    ) -> Result<(), zx_status::Status> {
7943        use fidl::Peered;
7944        self.inner.channel().signal_peer(clear_mask, set_mask)
7945    }
7946}
7947
7948impl IsochronousStreamControlHandle {
7949    pub fn send_on_established(
7950        &self,
7951        mut payload: &IsochronousStreamOnEstablishedRequest,
7952    ) -> Result<(), fidl::Error> {
7953        self.inner.send::<IsochronousStreamOnEstablishedRequest>(
7954            payload,
7955            0,
7956            0x341c50e9d10f3421,
7957            fidl::encoding::DynamicFlags::FLEXIBLE,
7958        )
7959    }
7960}
7961
7962#[must_use = "FIDL methods require a response to be sent"]
7963#[derive(Debug)]
7964pub struct IsochronousStreamSetupDataPathResponder {
7965    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
7966    tx_id: u32,
7967}
7968
7969/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
7970/// if the responder is dropped without sending a response, so that the client
7971/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7972impl std::ops::Drop for IsochronousStreamSetupDataPathResponder {
7973    fn drop(&mut self) {
7974        self.control_handle.shutdown();
7975        // Safety: drops once, never accessed again
7976        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7977    }
7978}
7979
7980impl fidl::endpoints::Responder for IsochronousStreamSetupDataPathResponder {
7981    type ControlHandle = IsochronousStreamControlHandle;
7982
7983    fn control_handle(&self) -> &IsochronousStreamControlHandle {
7984        &self.control_handle
7985    }
7986
7987    fn drop_without_shutdown(mut self) {
7988        // Safety: drops once, never accessed again due to mem::forget
7989        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7990        // Prevent Drop from running (which would shut down the channel)
7991        std::mem::forget(self);
7992    }
7993}
7994
7995impl IsochronousStreamSetupDataPathResponder {
7996    /// Sends a response to the FIDL transaction.
7997    ///
7998    /// Sets the channel to shutdown if an error occurs.
7999    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8000        let _result = self.send_raw(result);
8001        if _result.is_err() {
8002            self.control_handle.shutdown();
8003        }
8004        self.drop_without_shutdown();
8005        _result
8006    }
8007
8008    /// Similar to "send" but does not shutdown the channel if an error occurs.
8009    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8010        let _result = self.send_raw(result);
8011        self.drop_without_shutdown();
8012        _result
8013    }
8014
8015    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8016        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8017            fidl::encoding::EmptyStruct,
8018            i32,
8019        >>(
8020            fidl::encoding::FlexibleResult::new(result),
8021            self.tx_id,
8022            0x7ec1e2b9cc6d2fbe,
8023            fidl::encoding::DynamicFlags::FLEXIBLE,
8024        )
8025    }
8026}
8027
8028#[must_use = "FIDL methods require a response to be sent"]
8029#[derive(Debug)]
8030pub struct IsochronousStreamReadResponder {
8031    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
8032    tx_id: u32,
8033}
8034
8035/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
8036/// if the responder is dropped without sending a response, so that the client
8037/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8038impl std::ops::Drop for IsochronousStreamReadResponder {
8039    fn drop(&mut self) {
8040        self.control_handle.shutdown();
8041        // Safety: drops once, never accessed again
8042        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8043    }
8044}
8045
8046impl fidl::endpoints::Responder for IsochronousStreamReadResponder {
8047    type ControlHandle = IsochronousStreamControlHandle;
8048
8049    fn control_handle(&self) -> &IsochronousStreamControlHandle {
8050        &self.control_handle
8051    }
8052
8053    fn drop_without_shutdown(mut self) {
8054        // Safety: drops once, never accessed again due to mem::forget
8055        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8056        // Prevent Drop from running (which would shut down the channel)
8057        std::mem::forget(self);
8058    }
8059}
8060
8061impl IsochronousStreamReadResponder {
8062    /// Sends a response to the FIDL transaction.
8063    ///
8064    /// Sets the channel to shutdown if an error occurs.
8065    pub fn send(self, mut payload: &IsochronousStreamReadResponse) -> Result<(), fidl::Error> {
8066        let _result = self.send_raw(payload);
8067        if _result.is_err() {
8068            self.control_handle.shutdown();
8069        }
8070        self.drop_without_shutdown();
8071        _result
8072    }
8073
8074    /// Similar to "send" but does not shutdown the channel if an error occurs.
8075    pub fn send_no_shutdown_on_err(
8076        self,
8077        mut payload: &IsochronousStreamReadResponse,
8078    ) -> Result<(), fidl::Error> {
8079        let _result = self.send_raw(payload);
8080        self.drop_without_shutdown();
8081        _result
8082    }
8083
8084    fn send_raw(&self, mut payload: &IsochronousStreamReadResponse) -> Result<(), fidl::Error> {
8085        self.control_handle
8086            .inner
8087            .send::<fidl::encoding::FlexibleType<IsochronousStreamReadResponse>>(
8088                fidl::encoding::Flexible::new(payload),
8089                self.tx_id,
8090                0x6d7d8b4950ed3a32,
8091                fidl::encoding::DynamicFlags::FLEXIBLE,
8092            )
8093    }
8094}
8095
8096#[must_use = "FIDL methods require a response to be sent"]
8097#[derive(Debug)]
8098pub struct IsochronousStreamWriteResponder {
8099    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
8100    tx_id: u32,
8101}
8102
8103/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
8104/// if the responder is dropped without sending a response, so that the client
8105/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8106impl std::ops::Drop for IsochronousStreamWriteResponder {
8107    fn drop(&mut self) {
8108        self.control_handle.shutdown();
8109        // Safety: drops once, never accessed again
8110        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8111    }
8112}
8113
8114impl fidl::endpoints::Responder for IsochronousStreamWriteResponder {
8115    type ControlHandle = IsochronousStreamControlHandle;
8116
8117    fn control_handle(&self) -> &IsochronousStreamControlHandle {
8118        &self.control_handle
8119    }
8120
8121    fn drop_without_shutdown(mut self) {
8122        // Safety: drops once, never accessed again due to mem::forget
8123        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8124        // Prevent Drop from running (which would shut down the channel)
8125        std::mem::forget(self);
8126    }
8127}
8128
8129impl IsochronousStreamWriteResponder {
8130    /// Sends a response to the FIDL transaction.
8131    ///
8132    /// Sets the channel to shutdown if an error occurs.
8133    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8134        let _result = self.send_raw(result);
8135        if _result.is_err() {
8136            self.control_handle.shutdown();
8137        }
8138        self.drop_without_shutdown();
8139        _result
8140    }
8141
8142    /// Similar to "send" but does not shutdown the channel if an error occurs.
8143    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8144        let _result = self.send_raw(result);
8145        self.drop_without_shutdown();
8146        _result
8147    }
8148
8149    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8150        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8151            fidl::encoding::EmptyStruct,
8152            i32,
8153        >>(
8154            fidl::encoding::FlexibleResult::new(result),
8155            self.tx_id,
8156            0x5282e90b667d0d43,
8157            fidl::encoding::DynamicFlags::FLEXIBLE,
8158        )
8159    }
8160}
8161
8162#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8163pub struct PeriodicAdvertisingSyncMarker;
8164
8165impl fidl::endpoints::ProtocolMarker for PeriodicAdvertisingSyncMarker {
8166    type Proxy = PeriodicAdvertisingSyncProxy;
8167    type RequestStream = PeriodicAdvertisingSyncRequestStream;
8168    #[cfg(target_os = "fuchsia")]
8169    type SynchronousProxy = PeriodicAdvertisingSyncSynchronousProxy;
8170
8171    const DEBUG_NAME: &'static str = "(anonymous) PeriodicAdvertisingSync";
8172}
8173pub type PeriodicAdvertisingSyncSyncToSubeventsResult = Result<(), i32>;
8174
8175pub trait PeriodicAdvertisingSyncProxyInterface: Send + Sync {
8176    type WatchAdvertisingReportResponseFut: std::future::Future<
8177            Output = Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error>,
8178        > + Send;
8179    fn r#watch_advertising_report(&self) -> Self::WatchAdvertisingReportResponseFut;
8180    type SyncToSubeventsResponseFut: std::future::Future<
8181            Output = Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error>,
8182        > + Send;
8183    fn r#sync_to_subevents(
8184        &self,
8185        payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
8186    ) -> Self::SyncToSubeventsResponseFut;
8187    fn r#cancel(&self) -> Result<(), fidl::Error>;
8188}
8189#[derive(Debug)]
8190#[cfg(target_os = "fuchsia")]
8191pub struct PeriodicAdvertisingSyncSynchronousProxy {
8192    client: fidl::client::sync::Client,
8193}
8194
8195#[cfg(target_os = "fuchsia")]
8196impl fidl::endpoints::SynchronousProxy for PeriodicAdvertisingSyncSynchronousProxy {
8197    type Proxy = PeriodicAdvertisingSyncProxy;
8198    type Protocol = PeriodicAdvertisingSyncMarker;
8199
8200    fn from_channel(inner: fidl::Channel) -> Self {
8201        Self::new(inner)
8202    }
8203
8204    fn into_channel(self) -> fidl::Channel {
8205        self.client.into_channel()
8206    }
8207
8208    fn as_channel(&self) -> &fidl::Channel {
8209        self.client.as_channel()
8210    }
8211}
8212
8213#[cfg(target_os = "fuchsia")]
8214impl PeriodicAdvertisingSyncSynchronousProxy {
8215    pub fn new(channel: fidl::Channel) -> Self {
8216        Self { client: fidl::client::sync::Client::new(channel) }
8217    }
8218
8219    pub fn into_channel(self) -> fidl::Channel {
8220        self.client.into_channel()
8221    }
8222
8223    /// Waits until an event arrives and returns it. It is safe for other
8224    /// threads to make concurrent requests while waiting for an event.
8225    pub fn wait_for_event(
8226        &self,
8227        deadline: zx::MonotonicInstant,
8228    ) -> Result<PeriodicAdvertisingSyncEvent, fidl::Error> {
8229        PeriodicAdvertisingSyncEvent::decode(
8230            self.client.wait_for_event::<PeriodicAdvertisingSyncMarker>(deadline)?,
8231        )
8232    }
8233
8234    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
8235    /// Only one call may be pending at a time.
8236    pub fn r#watch_advertising_report(
8237        &self,
8238        ___deadline: zx::MonotonicInstant,
8239    ) -> Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error> {
8240        let _response = self.client.send_query::<
8241            fidl::encoding::EmptyPayload,
8242            fidl::encoding::FlexibleType<PeriodicAdvertisingSyncWatchAdvertisingReportResponse>,
8243            PeriodicAdvertisingSyncMarker,
8244        >(
8245            (),
8246            0x2ea610fea0e7d337,
8247            fidl::encoding::DynamicFlags::FLEXIBLE,
8248            ___deadline,
8249        )?
8250        .into_result::<PeriodicAdvertisingSyncMarker>("watch_advertising_report")?;
8251        Ok(_response)
8252    }
8253
8254    /// Synchronize to subevents of this periodic advertisement.
8255    /// * error FAILED: The synchronization failed.
8256    pub fn r#sync_to_subevents(
8257        &self,
8258        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
8259        ___deadline: zx::MonotonicInstant,
8260    ) -> Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error> {
8261        let _response = self.client.send_query::<
8262            PeriodicAdvertisingSyncSyncToSubeventsRequest,
8263            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
8264            PeriodicAdvertisingSyncMarker,
8265        >(
8266            payload,
8267            0x653c5dab1f1d80ed,
8268            fidl::encoding::DynamicFlags::FLEXIBLE,
8269            ___deadline,
8270        )?
8271        .into_result::<PeriodicAdvertisingSyncMarker>("sync_to_subevents")?;
8272        Ok(_response.map(|x| x))
8273    }
8274
8275    /// The server will end the synchronization and then close the protocol.
8276    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
8277    /// Advertisement.
8278    /// Synchronization can also be cancelled by closing the protocol on the client end.
8279    pub fn r#cancel(&self) -> Result<(), fidl::Error> {
8280        self.client.send::<fidl::encoding::EmptyPayload>(
8281            (),
8282            0xd617c037eaf5d92,
8283            fidl::encoding::DynamicFlags::FLEXIBLE,
8284        )
8285    }
8286}
8287
8288#[cfg(target_os = "fuchsia")]
8289impl From<PeriodicAdvertisingSyncSynchronousProxy> for zx::NullableHandle {
8290    fn from(value: PeriodicAdvertisingSyncSynchronousProxy) -> Self {
8291        value.into_channel().into()
8292    }
8293}
8294
8295#[cfg(target_os = "fuchsia")]
8296impl From<fidl::Channel> for PeriodicAdvertisingSyncSynchronousProxy {
8297    fn from(value: fidl::Channel) -> Self {
8298        Self::new(value)
8299    }
8300}
8301
8302#[cfg(target_os = "fuchsia")]
8303impl fidl::endpoints::FromClient for PeriodicAdvertisingSyncSynchronousProxy {
8304    type Protocol = PeriodicAdvertisingSyncMarker;
8305
8306    fn from_client(value: fidl::endpoints::ClientEnd<PeriodicAdvertisingSyncMarker>) -> Self {
8307        Self::new(value.into_channel())
8308    }
8309}
8310
8311#[derive(Debug, Clone)]
8312pub struct PeriodicAdvertisingSyncProxy {
8313    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8314}
8315
8316impl fidl::endpoints::Proxy for PeriodicAdvertisingSyncProxy {
8317    type Protocol = PeriodicAdvertisingSyncMarker;
8318
8319    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8320        Self::new(inner)
8321    }
8322
8323    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8324        self.client.into_channel().map_err(|client| Self { client })
8325    }
8326
8327    fn as_channel(&self) -> &::fidl::AsyncChannel {
8328        self.client.as_channel()
8329    }
8330}
8331
8332impl PeriodicAdvertisingSyncProxy {
8333    /// Create a new Proxy for fuchsia.bluetooth.le/PeriodicAdvertisingSync.
8334    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8335        let protocol_name =
8336            <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8337        Self { client: fidl::client::Client::new(channel, protocol_name) }
8338    }
8339
8340    /// Get a Stream of events from the remote end of the protocol.
8341    ///
8342    /// # Panics
8343    ///
8344    /// Panics if the event stream was already taken.
8345    pub fn take_event_stream(&self) -> PeriodicAdvertisingSyncEventStream {
8346        PeriodicAdvertisingSyncEventStream { event_receiver: self.client.take_event_receiver() }
8347    }
8348
8349    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
8350    /// Only one call may be pending at a time.
8351    pub fn r#watch_advertising_report(
8352        &self,
8353    ) -> fidl::client::QueryResponseFut<
8354        PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8355        fidl::encoding::DefaultFuchsiaResourceDialect,
8356    > {
8357        PeriodicAdvertisingSyncProxyInterface::r#watch_advertising_report(self)
8358    }
8359
8360    /// Synchronize to subevents of this periodic advertisement.
8361    /// * error FAILED: The synchronization failed.
8362    pub fn r#sync_to_subevents(
8363        &self,
8364        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
8365    ) -> fidl::client::QueryResponseFut<
8366        PeriodicAdvertisingSyncSyncToSubeventsResult,
8367        fidl::encoding::DefaultFuchsiaResourceDialect,
8368    > {
8369        PeriodicAdvertisingSyncProxyInterface::r#sync_to_subevents(self, payload)
8370    }
8371
8372    /// The server will end the synchronization and then close the protocol.
8373    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
8374    /// Advertisement.
8375    /// Synchronization can also be cancelled by closing the protocol on the client end.
8376    pub fn r#cancel(&self) -> Result<(), fidl::Error> {
8377        PeriodicAdvertisingSyncProxyInterface::r#cancel(self)
8378    }
8379}
8380
8381impl PeriodicAdvertisingSyncProxyInterface for PeriodicAdvertisingSyncProxy {
8382    type WatchAdvertisingReportResponseFut = fidl::client::QueryResponseFut<
8383        PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8384        fidl::encoding::DefaultFuchsiaResourceDialect,
8385    >;
8386    fn r#watch_advertising_report(&self) -> Self::WatchAdvertisingReportResponseFut {
8387        fn _decode(
8388            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8389        ) -> Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error> {
8390            let _response = fidl::client::decode_transaction_body::<
8391                fidl::encoding::FlexibleType<PeriodicAdvertisingSyncWatchAdvertisingReportResponse>,
8392                fidl::encoding::DefaultFuchsiaResourceDialect,
8393                0x2ea610fea0e7d337,
8394            >(_buf?)?
8395            .into_result::<PeriodicAdvertisingSyncMarker>("watch_advertising_report")?;
8396            Ok(_response)
8397        }
8398        self.client.send_query_and_decode::<
8399            fidl::encoding::EmptyPayload,
8400            PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8401        >(
8402            (),
8403            0x2ea610fea0e7d337,
8404            fidl::encoding::DynamicFlags::FLEXIBLE,
8405            _decode,
8406        )
8407    }
8408
8409    type SyncToSubeventsResponseFut = fidl::client::QueryResponseFut<
8410        PeriodicAdvertisingSyncSyncToSubeventsResult,
8411        fidl::encoding::DefaultFuchsiaResourceDialect,
8412    >;
8413    fn r#sync_to_subevents(
8414        &self,
8415        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
8416    ) -> Self::SyncToSubeventsResponseFut {
8417        fn _decode(
8418            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8419        ) -> Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error> {
8420            let _response = fidl::client::decode_transaction_body::<
8421                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
8422                fidl::encoding::DefaultFuchsiaResourceDialect,
8423                0x653c5dab1f1d80ed,
8424            >(_buf?)?
8425            .into_result::<PeriodicAdvertisingSyncMarker>("sync_to_subevents")?;
8426            Ok(_response.map(|x| x))
8427        }
8428        self.client.send_query_and_decode::<
8429            PeriodicAdvertisingSyncSyncToSubeventsRequest,
8430            PeriodicAdvertisingSyncSyncToSubeventsResult,
8431        >(
8432            payload,
8433            0x653c5dab1f1d80ed,
8434            fidl::encoding::DynamicFlags::FLEXIBLE,
8435            _decode,
8436        )
8437    }
8438
8439    fn r#cancel(&self) -> Result<(), fidl::Error> {
8440        self.client.send::<fidl::encoding::EmptyPayload>(
8441            (),
8442            0xd617c037eaf5d92,
8443            fidl::encoding::DynamicFlags::FLEXIBLE,
8444        )
8445    }
8446}
8447
8448pub struct PeriodicAdvertisingSyncEventStream {
8449    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8450}
8451
8452impl std::marker::Unpin for PeriodicAdvertisingSyncEventStream {}
8453
8454impl futures::stream::FusedStream for PeriodicAdvertisingSyncEventStream {
8455    fn is_terminated(&self) -> bool {
8456        self.event_receiver.is_terminated()
8457    }
8458}
8459
8460impl futures::Stream for PeriodicAdvertisingSyncEventStream {
8461    type Item = Result<PeriodicAdvertisingSyncEvent, fidl::Error>;
8462
8463    fn poll_next(
8464        mut self: std::pin::Pin<&mut Self>,
8465        cx: &mut std::task::Context<'_>,
8466    ) -> std::task::Poll<Option<Self::Item>> {
8467        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8468            &mut self.event_receiver,
8469            cx
8470        )?) {
8471            Some(buf) => std::task::Poll::Ready(Some(PeriodicAdvertisingSyncEvent::decode(buf))),
8472            None => std::task::Poll::Ready(None),
8473        }
8474    }
8475}
8476
8477#[derive(Debug)]
8478pub enum PeriodicAdvertisingSyncEvent {
8479    OnEstablished {
8480        payload: PeriodicAdvertisingSyncOnEstablishedRequest,
8481    },
8482    OnError {
8483        error: PeriodicAdvertisingSyncError,
8484    },
8485    #[non_exhaustive]
8486    _UnknownEvent {
8487        /// Ordinal of the event that was sent.
8488        ordinal: u64,
8489    },
8490}
8491
8492impl PeriodicAdvertisingSyncEvent {
8493    #[allow(irrefutable_let_patterns)]
8494    pub fn into_on_established(self) -> Option<PeriodicAdvertisingSyncOnEstablishedRequest> {
8495        if let PeriodicAdvertisingSyncEvent::OnEstablished { payload } = self {
8496            Some((payload))
8497        } else {
8498            None
8499        }
8500    }
8501    #[allow(irrefutable_let_patterns)]
8502    pub fn into_on_error(self) -> Option<PeriodicAdvertisingSyncError> {
8503        if let PeriodicAdvertisingSyncEvent::OnError { error } = self {
8504            Some((error))
8505        } else {
8506            None
8507        }
8508    }
8509
8510    /// Decodes a message buffer as a [`PeriodicAdvertisingSyncEvent`].
8511    fn decode(
8512        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8513    ) -> Result<PeriodicAdvertisingSyncEvent, fidl::Error> {
8514        let (bytes, _handles) = buf.split_mut();
8515        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8516        debug_assert_eq!(tx_header.tx_id, 0);
8517        match tx_header.ordinal {
8518            0x4a5c307761c40fdc => {
8519                let mut out = fidl::new_empty!(
8520                    PeriodicAdvertisingSyncOnEstablishedRequest,
8521                    fidl::encoding::DefaultFuchsiaResourceDialect
8522                );
8523                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncOnEstablishedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
8524                Ok((PeriodicAdvertisingSyncEvent::OnEstablished { payload: out }))
8525            }
8526            0x1c051673126ce4a => {
8527                let mut out = fidl::new_empty!(
8528                    PeriodicAdvertisingSyncOnErrorRequest,
8529                    fidl::encoding::DefaultFuchsiaResourceDialect
8530                );
8531                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncOnErrorRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
8532                Ok((PeriodicAdvertisingSyncEvent::OnError { error: out.error }))
8533            }
8534            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8535                Ok(PeriodicAdvertisingSyncEvent::_UnknownEvent { ordinal: tx_header.ordinal })
8536            }
8537            _ => Err(fidl::Error::UnknownOrdinal {
8538                ordinal: tx_header.ordinal,
8539                protocol_name:
8540                    <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8541            }),
8542        }
8543    }
8544}
8545
8546/// A Stream of incoming requests for fuchsia.bluetooth.le/PeriodicAdvertisingSync.
8547pub struct PeriodicAdvertisingSyncRequestStream {
8548    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8549    is_terminated: bool,
8550}
8551
8552impl std::marker::Unpin for PeriodicAdvertisingSyncRequestStream {}
8553
8554impl futures::stream::FusedStream for PeriodicAdvertisingSyncRequestStream {
8555    fn is_terminated(&self) -> bool {
8556        self.is_terminated
8557    }
8558}
8559
8560impl fidl::endpoints::RequestStream for PeriodicAdvertisingSyncRequestStream {
8561    type Protocol = PeriodicAdvertisingSyncMarker;
8562    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
8563
8564    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8565        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8566    }
8567
8568    fn control_handle(&self) -> Self::ControlHandle {
8569        PeriodicAdvertisingSyncControlHandle { inner: self.inner.clone() }
8570    }
8571
8572    fn into_inner(
8573        self,
8574    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8575    {
8576        (self.inner, self.is_terminated)
8577    }
8578
8579    fn from_inner(
8580        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8581        is_terminated: bool,
8582    ) -> Self {
8583        Self { inner, is_terminated }
8584    }
8585}
8586
8587impl futures::Stream for PeriodicAdvertisingSyncRequestStream {
8588    type Item = Result<PeriodicAdvertisingSyncRequest, fidl::Error>;
8589
8590    fn poll_next(
8591        mut self: std::pin::Pin<&mut Self>,
8592        cx: &mut std::task::Context<'_>,
8593    ) -> std::task::Poll<Option<Self::Item>> {
8594        let this = &mut *self;
8595        if this.inner.check_shutdown(cx) {
8596            this.is_terminated = true;
8597            return std::task::Poll::Ready(None);
8598        }
8599        if this.is_terminated {
8600            panic!("polled PeriodicAdvertisingSyncRequestStream after completion");
8601        }
8602        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8603            |bytes, handles| {
8604                match this.inner.channel().read_etc(cx, bytes, handles) {
8605                    std::task::Poll::Ready(Ok(())) => {}
8606                    std::task::Poll::Pending => return std::task::Poll::Pending,
8607                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8608                        this.is_terminated = true;
8609                        return std::task::Poll::Ready(None);
8610                    }
8611                    std::task::Poll::Ready(Err(e)) => {
8612                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8613                            e.into(),
8614                        ))));
8615                    }
8616                }
8617
8618                // A message has been received from the channel
8619                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8620
8621                std::task::Poll::Ready(Some(match header.ordinal {
8622                0x2ea610fea0e7d337 => {
8623                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8624                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8625                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8626                    let control_handle = PeriodicAdvertisingSyncControlHandle {
8627                        inner: this.inner.clone(),
8628                    };
8629                    Ok(PeriodicAdvertisingSyncRequest::WatchAdvertisingReport {
8630                        responder: PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8631                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8632                            tx_id: header.tx_id,
8633                        },
8634                    })
8635                }
8636                0x653c5dab1f1d80ed => {
8637                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8638                    let mut req = fidl::new_empty!(PeriodicAdvertisingSyncSyncToSubeventsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8639                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncSyncToSubeventsRequest>(&header, _body_bytes, handles, &mut req)?;
8640                    let control_handle = PeriodicAdvertisingSyncControlHandle {
8641                        inner: this.inner.clone(),
8642                    };
8643                    Ok(PeriodicAdvertisingSyncRequest::SyncToSubevents {payload: req,
8644                        responder: PeriodicAdvertisingSyncSyncToSubeventsResponder {
8645                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8646                            tx_id: header.tx_id,
8647                        },
8648                    })
8649                }
8650                0xd617c037eaf5d92 => {
8651                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8652                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8653                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8654                    let control_handle = PeriodicAdvertisingSyncControlHandle {
8655                        inner: this.inner.clone(),
8656                    };
8657                    Ok(PeriodicAdvertisingSyncRequest::Cancel {
8658                        control_handle,
8659                    })
8660                }
8661                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8662                    Ok(PeriodicAdvertisingSyncRequest::_UnknownMethod {
8663                        ordinal: header.ordinal,
8664                        control_handle: PeriodicAdvertisingSyncControlHandle { inner: this.inner.clone() },
8665                        method_type: fidl::MethodType::OneWay,
8666                    })
8667                }
8668                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8669                    this.inner.send_framework_err(
8670                        fidl::encoding::FrameworkErr::UnknownMethod,
8671                        header.tx_id,
8672                        header.ordinal,
8673                        header.dynamic_flags(),
8674                        (bytes, handles),
8675                    )?;
8676                    Ok(PeriodicAdvertisingSyncRequest::_UnknownMethod {
8677                        ordinal: header.ordinal,
8678                        control_handle: PeriodicAdvertisingSyncControlHandle { inner: this.inner.clone() },
8679                        method_type: fidl::MethodType::TwoWay,
8680                    })
8681                }
8682                _ => Err(fidl::Error::UnknownOrdinal {
8683                    ordinal: header.ordinal,
8684                    protocol_name: <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8685                }),
8686            }))
8687            },
8688        )
8689    }
8690}
8691
8692/// Closed by the server when the sync fails to be established or is lost.
8693#[derive(Debug)]
8694pub enum PeriodicAdvertisingSyncRequest {
8695    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
8696    /// Only one call may be pending at a time.
8697    WatchAdvertisingReport { responder: PeriodicAdvertisingSyncWatchAdvertisingReportResponder },
8698    /// Synchronize to subevents of this periodic advertisement.
8699    /// * error FAILED: The synchronization failed.
8700    SyncToSubevents {
8701        payload: PeriodicAdvertisingSyncSyncToSubeventsRequest,
8702        responder: PeriodicAdvertisingSyncSyncToSubeventsResponder,
8703    },
8704    /// The server will end the synchronization and then close the protocol.
8705    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
8706    /// Advertisement.
8707    /// Synchronization can also be cancelled by closing the protocol on the client end.
8708    Cancel { control_handle: PeriodicAdvertisingSyncControlHandle },
8709    /// An interaction was received which does not match any known method.
8710    #[non_exhaustive]
8711    _UnknownMethod {
8712        /// Ordinal of the method that was called.
8713        ordinal: u64,
8714        control_handle: PeriodicAdvertisingSyncControlHandle,
8715        method_type: fidl::MethodType,
8716    },
8717}
8718
8719impl PeriodicAdvertisingSyncRequest {
8720    #[allow(irrefutable_let_patterns)]
8721    pub fn into_watch_advertising_report(
8722        self,
8723    ) -> Option<(PeriodicAdvertisingSyncWatchAdvertisingReportResponder)> {
8724        if let PeriodicAdvertisingSyncRequest::WatchAdvertisingReport { responder } = self {
8725            Some((responder))
8726        } else {
8727            None
8728        }
8729    }
8730
8731    #[allow(irrefutable_let_patterns)]
8732    pub fn into_sync_to_subevents(
8733        self,
8734    ) -> Option<(
8735        PeriodicAdvertisingSyncSyncToSubeventsRequest,
8736        PeriodicAdvertisingSyncSyncToSubeventsResponder,
8737    )> {
8738        if let PeriodicAdvertisingSyncRequest::SyncToSubevents { payload, responder } = self {
8739            Some((payload, responder))
8740        } else {
8741            None
8742        }
8743    }
8744
8745    #[allow(irrefutable_let_patterns)]
8746    pub fn into_cancel(self) -> Option<(PeriodicAdvertisingSyncControlHandle)> {
8747        if let PeriodicAdvertisingSyncRequest::Cancel { control_handle } = self {
8748            Some((control_handle))
8749        } else {
8750            None
8751        }
8752    }
8753
8754    /// Name of the method defined in FIDL
8755    pub fn method_name(&self) -> &'static str {
8756        match *self {
8757            PeriodicAdvertisingSyncRequest::WatchAdvertisingReport { .. } => {
8758                "watch_advertising_report"
8759            }
8760            PeriodicAdvertisingSyncRequest::SyncToSubevents { .. } => "sync_to_subevents",
8761            PeriodicAdvertisingSyncRequest::Cancel { .. } => "cancel",
8762            PeriodicAdvertisingSyncRequest::_UnknownMethod {
8763                method_type: fidl::MethodType::OneWay,
8764                ..
8765            } => "unknown one-way method",
8766            PeriodicAdvertisingSyncRequest::_UnknownMethod {
8767                method_type: fidl::MethodType::TwoWay,
8768                ..
8769            } => "unknown two-way method",
8770        }
8771    }
8772}
8773
8774#[derive(Debug, Clone)]
8775pub struct PeriodicAdvertisingSyncControlHandle {
8776    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8777}
8778
8779impl PeriodicAdvertisingSyncControlHandle {
8780    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
8781        self.inner.shutdown_with_epitaph(status.into())
8782    }
8783}
8784
8785impl fidl::endpoints::ControlHandle for PeriodicAdvertisingSyncControlHandle {
8786    fn shutdown(&self) {
8787        self.inner.shutdown()
8788    }
8789
8790    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
8791        self.inner.shutdown_with_epitaph(status)
8792    }
8793
8794    fn is_closed(&self) -> bool {
8795        self.inner.channel().is_closed()
8796    }
8797    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8798        self.inner.channel().on_closed()
8799    }
8800
8801    #[cfg(target_os = "fuchsia")]
8802    fn signal_peer(
8803        &self,
8804        clear_mask: zx::Signals,
8805        set_mask: zx::Signals,
8806    ) -> Result<(), zx_status::Status> {
8807        use fidl::Peered;
8808        self.inner.channel().signal_peer(clear_mask, set_mask)
8809    }
8810}
8811
8812impl PeriodicAdvertisingSyncControlHandle {
8813    pub fn send_on_established(
8814        &self,
8815        mut payload: &PeriodicAdvertisingSyncOnEstablishedRequest,
8816    ) -> Result<(), fidl::Error> {
8817        self.inner.send::<PeriodicAdvertisingSyncOnEstablishedRequest>(
8818            payload,
8819            0,
8820            0x4a5c307761c40fdc,
8821            fidl::encoding::DynamicFlags::FLEXIBLE,
8822        )
8823    }
8824
8825    pub fn send_on_error(
8826        &self,
8827        mut error: PeriodicAdvertisingSyncError,
8828    ) -> Result<(), fidl::Error> {
8829        self.inner.send::<PeriodicAdvertisingSyncOnErrorRequest>(
8830            (error,),
8831            0,
8832            0x1c051673126ce4a,
8833            fidl::encoding::DynamicFlags::FLEXIBLE,
8834        )
8835    }
8836}
8837
8838#[must_use = "FIDL methods require a response to be sent"]
8839#[derive(Debug)]
8840pub struct PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8841    control_handle: std::mem::ManuallyDrop<PeriodicAdvertisingSyncControlHandle>,
8842    tx_id: u32,
8843}
8844
8845/// Set the the channel to be shutdown (see [`PeriodicAdvertisingSyncControlHandle::shutdown`])
8846/// if the responder is dropped without sending a response, so that the client
8847/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8848impl std::ops::Drop for PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8849    fn drop(&mut self) {
8850        self.control_handle.shutdown();
8851        // Safety: drops once, never accessed again
8852        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8853    }
8854}
8855
8856impl fidl::endpoints::Responder for PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8857    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
8858
8859    fn control_handle(&self) -> &PeriodicAdvertisingSyncControlHandle {
8860        &self.control_handle
8861    }
8862
8863    fn drop_without_shutdown(mut self) {
8864        // Safety: drops once, never accessed again due to mem::forget
8865        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8866        // Prevent Drop from running (which would shut down the channel)
8867        std::mem::forget(self);
8868    }
8869}
8870
8871impl PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8872    /// Sends a response to the FIDL transaction.
8873    ///
8874    /// Sets the channel to shutdown if an error occurs.
8875    pub fn send(
8876        self,
8877        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8878    ) -> Result<(), fidl::Error> {
8879        let _result = self.send_raw(payload);
8880        if _result.is_err() {
8881            self.control_handle.shutdown();
8882        }
8883        self.drop_without_shutdown();
8884        _result
8885    }
8886
8887    /// Similar to "send" but does not shutdown the channel if an error occurs.
8888    pub fn send_no_shutdown_on_err(
8889        self,
8890        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8891    ) -> Result<(), fidl::Error> {
8892        let _result = self.send_raw(payload);
8893        self.drop_without_shutdown();
8894        _result
8895    }
8896
8897    fn send_raw(
8898        &self,
8899        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8900    ) -> Result<(), fidl::Error> {
8901        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
8902            PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8903        >>(
8904            fidl::encoding::Flexible::new(payload),
8905            self.tx_id,
8906            0x2ea610fea0e7d337,
8907            fidl::encoding::DynamicFlags::FLEXIBLE,
8908        )
8909    }
8910}
8911
8912#[must_use = "FIDL methods require a response to be sent"]
8913#[derive(Debug)]
8914pub struct PeriodicAdvertisingSyncSyncToSubeventsResponder {
8915    control_handle: std::mem::ManuallyDrop<PeriodicAdvertisingSyncControlHandle>,
8916    tx_id: u32,
8917}
8918
8919/// Set the the channel to be shutdown (see [`PeriodicAdvertisingSyncControlHandle::shutdown`])
8920/// if the responder is dropped without sending a response, so that the client
8921/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8922impl std::ops::Drop for PeriodicAdvertisingSyncSyncToSubeventsResponder {
8923    fn drop(&mut self) {
8924        self.control_handle.shutdown();
8925        // Safety: drops once, never accessed again
8926        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8927    }
8928}
8929
8930impl fidl::endpoints::Responder for PeriodicAdvertisingSyncSyncToSubeventsResponder {
8931    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
8932
8933    fn control_handle(&self) -> &PeriodicAdvertisingSyncControlHandle {
8934        &self.control_handle
8935    }
8936
8937    fn drop_without_shutdown(mut self) {
8938        // Safety: drops once, never accessed again due to mem::forget
8939        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8940        // Prevent Drop from running (which would shut down the channel)
8941        std::mem::forget(self);
8942    }
8943}
8944
8945impl PeriodicAdvertisingSyncSyncToSubeventsResponder {
8946    /// Sends a response to the FIDL transaction.
8947    ///
8948    /// Sets the channel to shutdown if an error occurs.
8949    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8950        let _result = self.send_raw(result);
8951        if _result.is_err() {
8952            self.control_handle.shutdown();
8953        }
8954        self.drop_without_shutdown();
8955        _result
8956    }
8957
8958    /// Similar to "send" but does not shutdown the channel if an error occurs.
8959    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8960        let _result = self.send_raw(result);
8961        self.drop_without_shutdown();
8962        _result
8963    }
8964
8965    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8966        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8967            fidl::encoding::EmptyStruct,
8968            i32,
8969        >>(
8970            fidl::encoding::FlexibleResult::new(result),
8971            self.tx_id,
8972            0x653c5dab1f1d80ed,
8973            fidl::encoding::DynamicFlags::FLEXIBLE,
8974        )
8975    }
8976}
8977
8978#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8979pub struct PeripheralMarker;
8980
8981impl fidl::endpoints::ProtocolMarker for PeripheralMarker {
8982    type Proxy = PeripheralProxy;
8983    type RequestStream = PeripheralRequestStream;
8984    #[cfg(target_os = "fuchsia")]
8985    type SynchronousProxy = PeripheralSynchronousProxy;
8986
8987    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.Peripheral";
8988}
8989impl fidl::endpoints::DiscoverableProtocolMarker for PeripheralMarker {}
8990pub type PeripheralAdvertiseResult = Result<(), PeripheralError>;
8991pub type PeripheralStartAdvertisingResult = Result<(), PeripheralError>;
8992
8993pub trait PeripheralProxyInterface: Send + Sync {
8994    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
8995        + Send;
8996    fn r#listen_l2cap(
8997        &self,
8998        payload: ChannelListenerRegistryListenL2capRequest,
8999    ) -> Self::ListenL2capResponseFut;
9000    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralAdvertiseResult, fidl::Error>>
9001        + Send;
9002    fn r#advertise(
9003        &self,
9004        parameters: &AdvertisingParameters,
9005        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9006    ) -> Self::AdvertiseResponseFut;
9007    type StartAdvertisingResponseFut: std::future::Future<Output = Result<PeripheralStartAdvertisingResult, fidl::Error>>
9008        + Send;
9009    fn r#start_advertising(
9010        &self,
9011        parameters: &AdvertisingParameters,
9012        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9013    ) -> Self::StartAdvertisingResponseFut;
9014}
9015#[derive(Debug)]
9016#[cfg(target_os = "fuchsia")]
9017pub struct PeripheralSynchronousProxy {
9018    client: fidl::client::sync::Client,
9019}
9020
9021#[cfg(target_os = "fuchsia")]
9022impl fidl::endpoints::SynchronousProxy for PeripheralSynchronousProxy {
9023    type Proxy = PeripheralProxy;
9024    type Protocol = PeripheralMarker;
9025
9026    fn from_channel(inner: fidl::Channel) -> Self {
9027        Self::new(inner)
9028    }
9029
9030    fn into_channel(self) -> fidl::Channel {
9031        self.client.into_channel()
9032    }
9033
9034    fn as_channel(&self) -> &fidl::Channel {
9035        self.client.as_channel()
9036    }
9037}
9038
9039#[cfg(target_os = "fuchsia")]
9040impl PeripheralSynchronousProxy {
9041    pub fn new(channel: fidl::Channel) -> Self {
9042        Self { client: fidl::client::sync::Client::new(channel) }
9043    }
9044
9045    pub fn into_channel(self) -> fidl::Channel {
9046        self.client.into_channel()
9047    }
9048
9049    /// Waits until an event arrives and returns it. It is safe for other
9050    /// threads to make concurrent requests while waiting for an event.
9051    pub fn wait_for_event(
9052        &self,
9053        deadline: zx::MonotonicInstant,
9054    ) -> Result<PeripheralEvent, fidl::Error> {
9055        PeripheralEvent::decode(self.client.wait_for_event::<PeripheralMarker>(deadline)?)
9056    }
9057
9058    /// Register a listener for incoming channels. The registry will assign a
9059    /// PSM value that is unique for the local device, as well as open a
9060    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
9061    /// event that all PSMs have been assigned, this call will fail with
9062    /// `ZX_ERR_NO_RESOURCES`.
9063    ///
9064    /// Note that the method of service discovery or advertising is defined by
9065    /// the service or protocol, so it is the responsibility of the caller to
9066    /// communicate the assigned PSM to any clients.
9067    pub fn r#listen_l2cap(
9068        &self,
9069        mut payload: ChannelListenerRegistryListenL2capRequest,
9070        ___deadline: zx::MonotonicInstant,
9071    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
9072        let _response = self.client.send_query::<
9073            ChannelListenerRegistryListenL2capRequest,
9074            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
9075            PeripheralMarker,
9076        >(
9077            &mut payload,
9078            0x39c6e9001d102338,
9079            fidl::encoding::DynamicFlags::empty(),
9080            ___deadline,
9081        )?;
9082        Ok(_response.map(|x| x))
9083    }
9084
9085    /// Start advertising continuously as a LE peripheral. If advertising cannot
9086    /// be initiated then `advertised_peripheral` will be closed and an error
9087    /// will be returned.
9088    ///
9089    /// This method may be called any number of times. To reconfigure an
9090    /// advertisement, first close the original advertisement and then initiate
9091    /// a new advertisement after an empty response is returned.
9092    ///
9093    /// If the client closes its end of the
9094    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9095    /// advertising will be stopped. If the handle is closed before the request
9096    /// is fulfilled, advertising may be briefly enabled before it is
9097    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9098    /// the Peripheral protocol, but this may be changed in the future
9099    /// (https://fxbug.dev/42157682).
9100    ///
9101    /// + request `parameters` Parameters used while configuring the advertising
9102    ///   instance.
9103    /// + request `advertised_peripheral` Protocol that remains valid for the
9104    ///   duration of this advertising session.
9105    /// - response An empty response will be sent when the advertisement is
9106    ///   successfully stopped (due to release of the `advertised_peripheral`
9107    ///   protocol). To prevent overlapping similar advertisements and transient
9108    ///   errors with limited advertising resources, waiting for a response is
9109    ///   recommended before calling `Advertise` again.
9110    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9111    ///   `PeripheralError` will be returned.
9112    pub fn r#advertise(
9113        &self,
9114        mut parameters: &AdvertisingParameters,
9115        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9116        ___deadline: zx::MonotonicInstant,
9117    ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
9118        let _response = self.client.send_query::<
9119            PeripheralAdvertiseRequest,
9120            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9121            PeripheralMarker,
9122        >(
9123            (parameters, advertised_peripheral,),
9124            0x2d9ec9260c32c17f,
9125            fidl::encoding::DynamicFlags::empty(),
9126            ___deadline,
9127        )?;
9128        Ok(_response.map(|x| x))
9129    }
9130
9131    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9132    /// has successfully initiated. If advertising cannot be initiated, then the response will
9133    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9134    ///
9135    /// This method can get called any number of times and successive calls can be made to
9136    /// reconfigure the advertising parameters. However only the most recent
9137    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9138    ///
9139    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9140    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9141    /// advertisements.
9142    ///
9143    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9144    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9145    /// advertising will be briefly enabled before it is terminated.
9146    ///
9147    /// + request `parameters` Parameters used while configuring the advertising instance.
9148    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9149    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9150    ///         initiated. In this case the `handle` will be closed.
9151    pub fn r#start_advertising(
9152        &self,
9153        mut parameters: &AdvertisingParameters,
9154        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9155        ___deadline: zx::MonotonicInstant,
9156    ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
9157        let _response = self.client.send_query::<
9158            PeripheralStartAdvertisingRequest,
9159            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9160            PeripheralMarker,
9161        >(
9162            (parameters, handle,),
9163            0x5875c1c575f00f7d,
9164            fidl::encoding::DynamicFlags::empty(),
9165            ___deadline,
9166        )?;
9167        Ok(_response.map(|x| x))
9168    }
9169}
9170
9171#[cfg(target_os = "fuchsia")]
9172impl From<PeripheralSynchronousProxy> for zx::NullableHandle {
9173    fn from(value: PeripheralSynchronousProxy) -> Self {
9174        value.into_channel().into()
9175    }
9176}
9177
9178#[cfg(target_os = "fuchsia")]
9179impl From<fidl::Channel> for PeripheralSynchronousProxy {
9180    fn from(value: fidl::Channel) -> Self {
9181        Self::new(value)
9182    }
9183}
9184
9185#[cfg(target_os = "fuchsia")]
9186impl fidl::endpoints::FromClient for PeripheralSynchronousProxy {
9187    type Protocol = PeripheralMarker;
9188
9189    fn from_client(value: fidl::endpoints::ClientEnd<PeripheralMarker>) -> Self {
9190        Self::new(value.into_channel())
9191    }
9192}
9193
9194#[derive(Debug, Clone)]
9195pub struct PeripheralProxy {
9196    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
9197}
9198
9199impl fidl::endpoints::Proxy for PeripheralProxy {
9200    type Protocol = PeripheralMarker;
9201
9202    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
9203        Self::new(inner)
9204    }
9205
9206    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
9207        self.client.into_channel().map_err(|client| Self { client })
9208    }
9209
9210    fn as_channel(&self) -> &::fidl::AsyncChannel {
9211        self.client.as_channel()
9212    }
9213}
9214
9215impl PeripheralProxy {
9216    /// Create a new Proxy for fuchsia.bluetooth.le/Peripheral.
9217    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
9218        let protocol_name = <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9219        Self { client: fidl::client::Client::new(channel, protocol_name) }
9220    }
9221
9222    /// Get a Stream of events from the remote end of the protocol.
9223    ///
9224    /// # Panics
9225    ///
9226    /// Panics if the event stream was already taken.
9227    pub fn take_event_stream(&self) -> PeripheralEventStream {
9228        PeripheralEventStream { event_receiver: self.client.take_event_receiver() }
9229    }
9230
9231    /// Register a listener for incoming channels. The registry will assign a
9232    /// PSM value that is unique for the local device, as well as open a
9233    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
9234    /// event that all PSMs have been assigned, this call will fail with
9235    /// `ZX_ERR_NO_RESOURCES`.
9236    ///
9237    /// Note that the method of service discovery or advertising is defined by
9238    /// the service or protocol, so it is the responsibility of the caller to
9239    /// communicate the assigned PSM to any clients.
9240    pub fn r#listen_l2cap(
9241        &self,
9242        mut payload: ChannelListenerRegistryListenL2capRequest,
9243    ) -> fidl::client::QueryResponseFut<
9244        ChannelListenerRegistryListenL2capResult,
9245        fidl::encoding::DefaultFuchsiaResourceDialect,
9246    > {
9247        PeripheralProxyInterface::r#listen_l2cap(self, payload)
9248    }
9249
9250    /// Start advertising continuously as a LE peripheral. If advertising cannot
9251    /// be initiated then `advertised_peripheral` will be closed and an error
9252    /// will be returned.
9253    ///
9254    /// This method may be called any number of times. To reconfigure an
9255    /// advertisement, first close the original advertisement and then initiate
9256    /// a new advertisement after an empty response is returned.
9257    ///
9258    /// If the client closes its end of the
9259    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9260    /// advertising will be stopped. If the handle is closed before the request
9261    /// is fulfilled, advertising may be briefly enabled before it is
9262    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9263    /// the Peripheral protocol, but this may be changed in the future
9264    /// (https://fxbug.dev/42157682).
9265    ///
9266    /// + request `parameters` Parameters used while configuring the advertising
9267    ///   instance.
9268    /// + request `advertised_peripheral` Protocol that remains valid for the
9269    ///   duration of this advertising session.
9270    /// - response An empty response will be sent when the advertisement is
9271    ///   successfully stopped (due to release of the `advertised_peripheral`
9272    ///   protocol). To prevent overlapping similar advertisements and transient
9273    ///   errors with limited advertising resources, waiting for a response is
9274    ///   recommended before calling `Advertise` again.
9275    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9276    ///   `PeripheralError` will be returned.
9277    pub fn r#advertise(
9278        &self,
9279        mut parameters: &AdvertisingParameters,
9280        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9281    ) -> fidl::client::QueryResponseFut<
9282        PeripheralAdvertiseResult,
9283        fidl::encoding::DefaultFuchsiaResourceDialect,
9284    > {
9285        PeripheralProxyInterface::r#advertise(self, parameters, advertised_peripheral)
9286    }
9287
9288    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9289    /// has successfully initiated. If advertising cannot be initiated, then the response will
9290    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9291    ///
9292    /// This method can get called any number of times and successive calls can be made to
9293    /// reconfigure the advertising parameters. However only the most recent
9294    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9295    ///
9296    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9297    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9298    /// advertisements.
9299    ///
9300    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9301    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9302    /// advertising will be briefly enabled before it is terminated.
9303    ///
9304    /// + request `parameters` Parameters used while configuring the advertising instance.
9305    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9306    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9307    ///         initiated. In this case the `handle` will be closed.
9308    pub fn r#start_advertising(
9309        &self,
9310        mut parameters: &AdvertisingParameters,
9311        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9312    ) -> fidl::client::QueryResponseFut<
9313        PeripheralStartAdvertisingResult,
9314        fidl::encoding::DefaultFuchsiaResourceDialect,
9315    > {
9316        PeripheralProxyInterface::r#start_advertising(self, parameters, handle)
9317    }
9318}
9319
9320impl PeripheralProxyInterface for PeripheralProxy {
9321    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
9322        ChannelListenerRegistryListenL2capResult,
9323        fidl::encoding::DefaultFuchsiaResourceDialect,
9324    >;
9325    fn r#listen_l2cap(
9326        &self,
9327        mut payload: ChannelListenerRegistryListenL2capRequest,
9328    ) -> Self::ListenL2capResponseFut {
9329        fn _decode(
9330            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9331        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
9332            let _response = fidl::client::decode_transaction_body::<
9333                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
9334                fidl::encoding::DefaultFuchsiaResourceDialect,
9335                0x39c6e9001d102338,
9336            >(_buf?)?;
9337            Ok(_response.map(|x| x))
9338        }
9339        self.client.send_query_and_decode::<
9340            ChannelListenerRegistryListenL2capRequest,
9341            ChannelListenerRegistryListenL2capResult,
9342        >(
9343            &mut payload,
9344            0x39c6e9001d102338,
9345            fidl::encoding::DynamicFlags::empty(),
9346            _decode,
9347        )
9348    }
9349
9350    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
9351        PeripheralAdvertiseResult,
9352        fidl::encoding::DefaultFuchsiaResourceDialect,
9353    >;
9354    fn r#advertise(
9355        &self,
9356        mut parameters: &AdvertisingParameters,
9357        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9358    ) -> Self::AdvertiseResponseFut {
9359        fn _decode(
9360            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9361        ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
9362            let _response = fidl::client::decode_transaction_body::<
9363                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9364                fidl::encoding::DefaultFuchsiaResourceDialect,
9365                0x2d9ec9260c32c17f,
9366            >(_buf?)?;
9367            Ok(_response.map(|x| x))
9368        }
9369        self.client.send_query_and_decode::<PeripheralAdvertiseRequest, PeripheralAdvertiseResult>(
9370            (parameters, advertised_peripheral),
9371            0x2d9ec9260c32c17f,
9372            fidl::encoding::DynamicFlags::empty(),
9373            _decode,
9374        )
9375    }
9376
9377    type StartAdvertisingResponseFut = fidl::client::QueryResponseFut<
9378        PeripheralStartAdvertisingResult,
9379        fidl::encoding::DefaultFuchsiaResourceDialect,
9380    >;
9381    fn r#start_advertising(
9382        &self,
9383        mut parameters: &AdvertisingParameters,
9384        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9385    ) -> Self::StartAdvertisingResponseFut {
9386        fn _decode(
9387            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9388        ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
9389            let _response = fidl::client::decode_transaction_body::<
9390                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9391                fidl::encoding::DefaultFuchsiaResourceDialect,
9392                0x5875c1c575f00f7d,
9393            >(_buf?)?;
9394            Ok(_response.map(|x| x))
9395        }
9396        self.client.send_query_and_decode::<
9397            PeripheralStartAdvertisingRequest,
9398            PeripheralStartAdvertisingResult,
9399        >(
9400            (parameters, handle,),
9401            0x5875c1c575f00f7d,
9402            fidl::encoding::DynamicFlags::empty(),
9403            _decode,
9404        )
9405    }
9406}
9407
9408pub struct PeripheralEventStream {
9409    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9410}
9411
9412impl std::marker::Unpin for PeripheralEventStream {}
9413
9414impl futures::stream::FusedStream for PeripheralEventStream {
9415    fn is_terminated(&self) -> bool {
9416        self.event_receiver.is_terminated()
9417    }
9418}
9419
9420impl futures::Stream for PeripheralEventStream {
9421    type Item = Result<PeripheralEvent, fidl::Error>;
9422
9423    fn poll_next(
9424        mut self: std::pin::Pin<&mut Self>,
9425        cx: &mut std::task::Context<'_>,
9426    ) -> std::task::Poll<Option<Self::Item>> {
9427        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9428            &mut self.event_receiver,
9429            cx
9430        )?) {
9431            Some(buf) => std::task::Poll::Ready(Some(PeripheralEvent::decode(buf))),
9432            None => std::task::Poll::Ready(None),
9433        }
9434    }
9435}
9436
9437#[derive(Debug)]
9438pub enum PeripheralEvent {
9439    OnPeerConnected { peer: Peer, connection: fidl::endpoints::ClientEnd<ConnectionMarker> },
9440}
9441
9442impl PeripheralEvent {
9443    #[allow(irrefutable_let_patterns)]
9444    pub fn into_on_peer_connected(
9445        self,
9446    ) -> Option<(Peer, fidl::endpoints::ClientEnd<ConnectionMarker>)> {
9447        if let PeripheralEvent::OnPeerConnected { peer, connection } = self {
9448            Some((peer, connection))
9449        } else {
9450            None
9451        }
9452    }
9453
9454    /// Decodes a message buffer as a [`PeripheralEvent`].
9455    fn decode(
9456        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9457    ) -> Result<PeripheralEvent, fidl::Error> {
9458        let (bytes, _handles) = buf.split_mut();
9459        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9460        debug_assert_eq!(tx_header.tx_id, 0);
9461        match tx_header.ordinal {
9462            0x16135d464299e356 => {
9463                let mut out = fidl::new_empty!(
9464                    PeripheralOnPeerConnectedRequest,
9465                    fidl::encoding::DefaultFuchsiaResourceDialect
9466                );
9467                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralOnPeerConnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
9468                Ok((PeripheralEvent::OnPeerConnected {
9469                    peer: out.peer,
9470                    connection: out.connection,
9471                }))
9472            }
9473            _ => Err(fidl::Error::UnknownOrdinal {
9474                ordinal: tx_header.ordinal,
9475                protocol_name: <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9476            }),
9477        }
9478    }
9479}
9480
9481/// A Stream of incoming requests for fuchsia.bluetooth.le/Peripheral.
9482pub struct PeripheralRequestStream {
9483    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9484    is_terminated: bool,
9485}
9486
9487impl std::marker::Unpin for PeripheralRequestStream {}
9488
9489impl futures::stream::FusedStream for PeripheralRequestStream {
9490    fn is_terminated(&self) -> bool {
9491        self.is_terminated
9492    }
9493}
9494
9495impl fidl::endpoints::RequestStream for PeripheralRequestStream {
9496    type Protocol = PeripheralMarker;
9497    type ControlHandle = PeripheralControlHandle;
9498
9499    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9500        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9501    }
9502
9503    fn control_handle(&self) -> Self::ControlHandle {
9504        PeripheralControlHandle { inner: self.inner.clone() }
9505    }
9506
9507    fn into_inner(
9508        self,
9509    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9510    {
9511        (self.inner, self.is_terminated)
9512    }
9513
9514    fn from_inner(
9515        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9516        is_terminated: bool,
9517    ) -> Self {
9518        Self { inner, is_terminated }
9519    }
9520}
9521
9522impl futures::Stream for PeripheralRequestStream {
9523    type Item = Result<PeripheralRequest, fidl::Error>;
9524
9525    fn poll_next(
9526        mut self: std::pin::Pin<&mut Self>,
9527        cx: &mut std::task::Context<'_>,
9528    ) -> std::task::Poll<Option<Self::Item>> {
9529        let this = &mut *self;
9530        if this.inner.check_shutdown(cx) {
9531            this.is_terminated = true;
9532            return std::task::Poll::Ready(None);
9533        }
9534        if this.is_terminated {
9535            panic!("polled PeripheralRequestStream after completion");
9536        }
9537        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9538            |bytes, handles| {
9539                match this.inner.channel().read_etc(cx, bytes, handles) {
9540                    std::task::Poll::Ready(Ok(())) => {}
9541                    std::task::Poll::Pending => return std::task::Poll::Pending,
9542                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9543                        this.is_terminated = true;
9544                        return std::task::Poll::Ready(None);
9545                    }
9546                    std::task::Poll::Ready(Err(e)) => {
9547                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9548                            e.into(),
9549                        ))));
9550                    }
9551                }
9552
9553                // A message has been received from the channel
9554                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9555
9556                std::task::Poll::Ready(Some(match header.ordinal {
9557                    0x39c6e9001d102338 => {
9558                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9559                        let mut req = fidl::new_empty!(
9560                            ChannelListenerRegistryListenL2capRequest,
9561                            fidl::encoding::DefaultFuchsiaResourceDialect
9562                        );
9563                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
9564                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
9565                        Ok(PeripheralRequest::ListenL2cap {
9566                            payload: req,
9567                            responder: PeripheralListenL2capResponder {
9568                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9569                                tx_id: header.tx_id,
9570                            },
9571                        })
9572                    }
9573                    0x2d9ec9260c32c17f => {
9574                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9575                        let mut req = fidl::new_empty!(
9576                            PeripheralAdvertiseRequest,
9577                            fidl::encoding::DefaultFuchsiaResourceDialect
9578                        );
9579                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
9580                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
9581                        Ok(PeripheralRequest::Advertise {
9582                            parameters: req.parameters,
9583                            advertised_peripheral: req.advertised_peripheral,
9584
9585                            responder: PeripheralAdvertiseResponder {
9586                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9587                                tx_id: header.tx_id,
9588                            },
9589                        })
9590                    }
9591                    0x5875c1c575f00f7d => {
9592                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9593                        let mut req = fidl::new_empty!(
9594                            PeripheralStartAdvertisingRequest,
9595                            fidl::encoding::DefaultFuchsiaResourceDialect
9596                        );
9597                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralStartAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
9598                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
9599                        Ok(PeripheralRequest::StartAdvertising {
9600                            parameters: req.parameters,
9601                            handle: req.handle,
9602
9603                            responder: PeripheralStartAdvertisingResponder {
9604                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9605                                tx_id: header.tx_id,
9606                            },
9607                        })
9608                    }
9609                    _ => Err(fidl::Error::UnknownOrdinal {
9610                        ordinal: header.ordinal,
9611                        protocol_name:
9612                            <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9613                    }),
9614                }))
9615            },
9616        )
9617    }
9618}
9619
9620#[derive(Debug)]
9621pub enum PeripheralRequest {
9622    /// Register a listener for incoming channels. The registry will assign a
9623    /// PSM value that is unique for the local device, as well as open a
9624    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
9625    /// event that all PSMs have been assigned, this call will fail with
9626    /// `ZX_ERR_NO_RESOURCES`.
9627    ///
9628    /// Note that the method of service discovery or advertising is defined by
9629    /// the service or protocol, so it is the responsibility of the caller to
9630    /// communicate the assigned PSM to any clients.
9631    ListenL2cap {
9632        payload: ChannelListenerRegistryListenL2capRequest,
9633        responder: PeripheralListenL2capResponder,
9634    },
9635    /// Start advertising continuously as a LE peripheral. If advertising cannot
9636    /// be initiated then `advertised_peripheral` will be closed and an error
9637    /// will be returned.
9638    ///
9639    /// This method may be called any number of times. To reconfigure an
9640    /// advertisement, first close the original advertisement and then initiate
9641    /// a new advertisement after an empty response is returned.
9642    ///
9643    /// If the client closes its end of the
9644    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9645    /// advertising will be stopped. If the handle is closed before the request
9646    /// is fulfilled, advertising may be briefly enabled before it is
9647    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9648    /// the Peripheral protocol, but this may be changed in the future
9649    /// (https://fxbug.dev/42157682).
9650    ///
9651    /// + request `parameters` Parameters used while configuring the advertising
9652    ///   instance.
9653    /// + request `advertised_peripheral` Protocol that remains valid for the
9654    ///   duration of this advertising session.
9655    /// - response An empty response will be sent when the advertisement is
9656    ///   successfully stopped (due to release of the `advertised_peripheral`
9657    ///   protocol). To prevent overlapping similar advertisements and transient
9658    ///   errors with limited advertising resources, waiting for a response is
9659    ///   recommended before calling `Advertise` again.
9660    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9661    ///   `PeripheralError` will be returned.
9662    Advertise {
9663        parameters: AdvertisingParameters,
9664        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9665        responder: PeripheralAdvertiseResponder,
9666    },
9667    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9668    /// has successfully initiated. If advertising cannot be initiated, then the response will
9669    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9670    ///
9671    /// This method can get called any number of times and successive calls can be made to
9672    /// reconfigure the advertising parameters. However only the most recent
9673    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9674    ///
9675    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9676    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9677    /// advertisements.
9678    ///
9679    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9680    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9681    /// advertising will be briefly enabled before it is terminated.
9682    ///
9683    /// + request `parameters` Parameters used while configuring the advertising instance.
9684    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9685    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9686    ///         initiated. In this case the `handle` will be closed.
9687    StartAdvertising {
9688        parameters: AdvertisingParameters,
9689        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9690        responder: PeripheralStartAdvertisingResponder,
9691    },
9692}
9693
9694impl PeripheralRequest {
9695    #[allow(irrefutable_let_patterns)]
9696    pub fn into_listen_l2cap(
9697        self,
9698    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PeripheralListenL2capResponder)> {
9699        if let PeripheralRequest::ListenL2cap { payload, responder } = self {
9700            Some((payload, responder))
9701        } else {
9702            None
9703        }
9704    }
9705
9706    #[allow(irrefutable_let_patterns)]
9707    pub fn into_advertise(
9708        self,
9709    ) -> Option<(
9710        AdvertisingParameters,
9711        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9712        PeripheralAdvertiseResponder,
9713    )> {
9714        if let PeripheralRequest::Advertise { parameters, advertised_peripheral, responder } = self
9715        {
9716            Some((parameters, advertised_peripheral, responder))
9717        } else {
9718            None
9719        }
9720    }
9721
9722    #[allow(irrefutable_let_patterns)]
9723    pub fn into_start_advertising(
9724        self,
9725    ) -> Option<(
9726        AdvertisingParameters,
9727        fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9728        PeripheralStartAdvertisingResponder,
9729    )> {
9730        if let PeripheralRequest::StartAdvertising { parameters, handle, responder } = self {
9731            Some((parameters, handle, responder))
9732        } else {
9733            None
9734        }
9735    }
9736
9737    /// Name of the method defined in FIDL
9738    pub fn method_name(&self) -> &'static str {
9739        match *self {
9740            PeripheralRequest::ListenL2cap { .. } => "listen_l2cap",
9741            PeripheralRequest::Advertise { .. } => "advertise",
9742            PeripheralRequest::StartAdvertising { .. } => "start_advertising",
9743        }
9744    }
9745}
9746
9747#[derive(Debug, Clone)]
9748pub struct PeripheralControlHandle {
9749    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9750}
9751
9752impl PeripheralControlHandle {
9753    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
9754        self.inner.shutdown_with_epitaph(status.into())
9755    }
9756}
9757
9758impl fidl::endpoints::ControlHandle for PeripheralControlHandle {
9759    fn shutdown(&self) {
9760        self.inner.shutdown()
9761    }
9762
9763    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
9764        self.inner.shutdown_with_epitaph(status)
9765    }
9766
9767    fn is_closed(&self) -> bool {
9768        self.inner.channel().is_closed()
9769    }
9770    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
9771        self.inner.channel().on_closed()
9772    }
9773
9774    #[cfg(target_os = "fuchsia")]
9775    fn signal_peer(
9776        &self,
9777        clear_mask: zx::Signals,
9778        set_mask: zx::Signals,
9779    ) -> Result<(), zx_status::Status> {
9780        use fidl::Peered;
9781        self.inner.channel().signal_peer(clear_mask, set_mask)
9782    }
9783}
9784
9785impl PeripheralControlHandle {
9786    pub fn send_on_peer_connected(
9787        &self,
9788        mut peer: &Peer,
9789        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
9790    ) -> Result<(), fidl::Error> {
9791        self.inner.send::<PeripheralOnPeerConnectedRequest>(
9792            (peer, connection),
9793            0,
9794            0x16135d464299e356,
9795            fidl::encoding::DynamicFlags::empty(),
9796        )
9797    }
9798}
9799
9800#[must_use = "FIDL methods require a response to be sent"]
9801#[derive(Debug)]
9802pub struct PeripheralListenL2capResponder {
9803    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
9804    tx_id: u32,
9805}
9806
9807/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
9808/// if the responder is dropped without sending a response, so that the client
9809/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9810impl std::ops::Drop for PeripheralListenL2capResponder {
9811    fn drop(&mut self) {
9812        self.control_handle.shutdown();
9813        // Safety: drops once, never accessed again
9814        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9815    }
9816}
9817
9818impl fidl::endpoints::Responder for PeripheralListenL2capResponder {
9819    type ControlHandle = PeripheralControlHandle;
9820
9821    fn control_handle(&self) -> &PeripheralControlHandle {
9822        &self.control_handle
9823    }
9824
9825    fn drop_without_shutdown(mut self) {
9826        // Safety: drops once, never accessed again due to mem::forget
9827        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9828        // Prevent Drop from running (which would shut down the channel)
9829        std::mem::forget(self);
9830    }
9831}
9832
9833impl PeripheralListenL2capResponder {
9834    /// Sends a response to the FIDL transaction.
9835    ///
9836    /// Sets the channel to shutdown if an error occurs.
9837    pub fn send(
9838        self,
9839        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
9840    ) -> 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<&ChannelListenerRegistryListenL2capResponse, i32>,
9853    ) -> Result<(), fidl::Error> {
9854        let _result = self.send_raw(result);
9855        self.drop_without_shutdown();
9856        _result
9857    }
9858
9859    fn send_raw(
9860        &self,
9861        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
9862    ) -> Result<(), fidl::Error> {
9863        self.control_handle.inner.send::<fidl::encoding::ResultType<
9864            ChannelListenerRegistryListenL2capResponse,
9865            i32,
9866        >>(
9867            result,
9868            self.tx_id,
9869            0x39c6e9001d102338,
9870            fidl::encoding::DynamicFlags::empty(),
9871        )
9872    }
9873}
9874
9875#[must_use = "FIDL methods require a response to be sent"]
9876#[derive(Debug)]
9877pub struct PeripheralAdvertiseResponder {
9878    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
9879    tx_id: u32,
9880}
9881
9882/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
9883/// if the responder is dropped without sending a response, so that the client
9884/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9885impl std::ops::Drop for PeripheralAdvertiseResponder {
9886    fn drop(&mut self) {
9887        self.control_handle.shutdown();
9888        // Safety: drops once, never accessed again
9889        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9890    }
9891}
9892
9893impl fidl::endpoints::Responder for PeripheralAdvertiseResponder {
9894    type ControlHandle = PeripheralControlHandle;
9895
9896    fn control_handle(&self) -> &PeripheralControlHandle {
9897        &self.control_handle
9898    }
9899
9900    fn drop_without_shutdown(mut self) {
9901        // Safety: drops once, never accessed again due to mem::forget
9902        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9903        // Prevent Drop from running (which would shut down the channel)
9904        std::mem::forget(self);
9905    }
9906}
9907
9908impl PeripheralAdvertiseResponder {
9909    /// Sends a response to the FIDL transaction.
9910    ///
9911    /// Sets the channel to shutdown if an error occurs.
9912    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9913        let _result = self.send_raw(result);
9914        if _result.is_err() {
9915            self.control_handle.shutdown();
9916        }
9917        self.drop_without_shutdown();
9918        _result
9919    }
9920
9921    /// Similar to "send" but does not shutdown the channel if an error occurs.
9922    pub fn send_no_shutdown_on_err(
9923        self,
9924        mut result: Result<(), PeripheralError>,
9925    ) -> Result<(), fidl::Error> {
9926        let _result = self.send_raw(result);
9927        self.drop_without_shutdown();
9928        _result
9929    }
9930
9931    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9932        self.control_handle.inner.send::<fidl::encoding::ResultType<
9933            fidl::encoding::EmptyStruct,
9934            PeripheralError,
9935        >>(
9936            result,
9937            self.tx_id,
9938            0x2d9ec9260c32c17f,
9939            fidl::encoding::DynamicFlags::empty(),
9940        )
9941    }
9942}
9943
9944#[must_use = "FIDL methods require a response to be sent"]
9945#[derive(Debug)]
9946pub struct PeripheralStartAdvertisingResponder {
9947    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
9948    tx_id: u32,
9949}
9950
9951/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
9952/// if the responder is dropped without sending a response, so that the client
9953/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9954impl std::ops::Drop for PeripheralStartAdvertisingResponder {
9955    fn drop(&mut self) {
9956        self.control_handle.shutdown();
9957        // Safety: drops once, never accessed again
9958        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9959    }
9960}
9961
9962impl fidl::endpoints::Responder for PeripheralStartAdvertisingResponder {
9963    type ControlHandle = PeripheralControlHandle;
9964
9965    fn control_handle(&self) -> &PeripheralControlHandle {
9966        &self.control_handle
9967    }
9968
9969    fn drop_without_shutdown(mut self) {
9970        // Safety: drops once, never accessed again due to mem::forget
9971        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9972        // Prevent Drop from running (which would shut down the channel)
9973        std::mem::forget(self);
9974    }
9975}
9976
9977impl PeripheralStartAdvertisingResponder {
9978    /// Sends a response to the FIDL transaction.
9979    ///
9980    /// Sets the channel to shutdown if an error occurs.
9981    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9982        let _result = self.send_raw(result);
9983        if _result.is_err() {
9984            self.control_handle.shutdown();
9985        }
9986        self.drop_without_shutdown();
9987        _result
9988    }
9989
9990    /// Similar to "send" but does not shutdown the channel if an error occurs.
9991    pub fn send_no_shutdown_on_err(
9992        self,
9993        mut result: Result<(), PeripheralError>,
9994    ) -> Result<(), fidl::Error> {
9995        let _result = self.send_raw(result);
9996        self.drop_without_shutdown();
9997        _result
9998    }
9999
10000    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
10001        self.control_handle.inner.send::<fidl::encoding::ResultType<
10002            fidl::encoding::EmptyStruct,
10003            PeripheralError,
10004        >>(
10005            result,
10006            self.tx_id,
10007            0x5875c1c575f00f7d,
10008            fidl::encoding::DynamicFlags::empty(),
10009        )
10010    }
10011}
10012
10013#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10014pub struct PrivilegedCentralMarker;
10015
10016impl fidl::endpoints::ProtocolMarker for PrivilegedCentralMarker {
10017    type Proxy = PrivilegedCentralProxy;
10018    type RequestStream = PrivilegedCentralRequestStream;
10019    #[cfg(target_os = "fuchsia")]
10020    type SynchronousProxy = PrivilegedCentralSynchronousProxy;
10021
10022    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.PrivilegedCentral";
10023}
10024impl fidl::endpoints::DiscoverableProtocolMarker for PrivilegedCentralMarker {}
10025
10026pub trait PrivilegedCentralProxyInterface: Send + Sync {
10027    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
10028        + Send;
10029    fn r#listen_l2cap(
10030        &self,
10031        payload: ChannelListenerRegistryListenL2capRequest,
10032    ) -> Self::ListenL2capResponseFut;
10033    type ScanResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10034    fn r#scan(
10035        &self,
10036        options: &ScanOptions,
10037        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
10038    ) -> Self::ScanResponseFut;
10039    fn r#connect(
10040        &self,
10041        id: &fidl_fuchsia_bluetooth::PeerId,
10042        options: &ConnectionOptions,
10043        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
10044    ) -> Result<(), fidl::Error>;
10045    fn r#sync_to_periodic_advertising(
10046        &self,
10047        payload: CentralSyncToPeriodicAdvertisingRequest,
10048    ) -> Result<(), fidl::Error>;
10049    type CreateConnectedIsochronousGroupResponseFut: std::future::Future<
10050            Output = Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error>,
10051        > + Send;
10052    fn r#create_connected_isochronous_group(
10053        &self,
10054        payload: CentralCreateConnectedIsochronousGroupRequest,
10055    ) -> Self::CreateConnectedIsochronousGroupResponseFut;
10056    type GetPeripheralsResponseFut: std::future::Future<Output = Result<Vec<RemoteDevice>, fidl::Error>>
10057        + Send;
10058    fn r#get_peripherals(
10059        &self,
10060        service_uuids: Option<&[String]>,
10061    ) -> Self::GetPeripheralsResponseFut;
10062    type GetPeripheralResponseFut: std::future::Future<Output = Result<Option<Box<RemoteDevice>>, fidl::Error>>
10063        + Send;
10064    fn r#get_peripheral(&self, identifier: &str) -> Self::GetPeripheralResponseFut;
10065    type StartScanResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
10066        + Send;
10067    fn r#start_scan(&self, filter: Option<&ScanFilter>) -> Self::StartScanResponseFut;
10068    fn r#stop_scan(&self) -> Result<(), fidl::Error>;
10069    type ConnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
10070        + Send;
10071    fn r#connect_peripheral(
10072        &self,
10073        identifier: &str,
10074        options: &ConnectionOptions,
10075        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10076    ) -> Self::ConnectPeripheralResponseFut;
10077    type DisconnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
10078        + Send;
10079    fn r#disconnect_peripheral(&self, identifier: &str) -> Self::DisconnectPeripheralResponseFut;
10080}
10081#[derive(Debug)]
10082#[cfg(target_os = "fuchsia")]
10083pub struct PrivilegedCentralSynchronousProxy {
10084    client: fidl::client::sync::Client,
10085}
10086
10087#[cfg(target_os = "fuchsia")]
10088impl fidl::endpoints::SynchronousProxy for PrivilegedCentralSynchronousProxy {
10089    type Proxy = PrivilegedCentralProxy;
10090    type Protocol = PrivilegedCentralMarker;
10091
10092    fn from_channel(inner: fidl::Channel) -> Self {
10093        Self::new(inner)
10094    }
10095
10096    fn into_channel(self) -> fidl::Channel {
10097        self.client.into_channel()
10098    }
10099
10100    fn as_channel(&self) -> &fidl::Channel {
10101        self.client.as_channel()
10102    }
10103}
10104
10105#[cfg(target_os = "fuchsia")]
10106impl PrivilegedCentralSynchronousProxy {
10107    pub fn new(channel: fidl::Channel) -> Self {
10108        Self { client: fidl::client::sync::Client::new(channel) }
10109    }
10110
10111    pub fn into_channel(self) -> fidl::Channel {
10112        self.client.into_channel()
10113    }
10114
10115    /// Waits until an event arrives and returns it. It is safe for other
10116    /// threads to make concurrent requests while waiting for an event.
10117    pub fn wait_for_event(
10118        &self,
10119        deadline: zx::MonotonicInstant,
10120    ) -> Result<PrivilegedCentralEvent, fidl::Error> {
10121        PrivilegedCentralEvent::decode(
10122            self.client.wait_for_event::<PrivilegedCentralMarker>(deadline)?,
10123        )
10124    }
10125
10126    /// Register a listener for incoming channels. The registry will assign a
10127    /// PSM value that is unique for the local device, as well as open a
10128    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
10129    /// event that all PSMs have been assigned, this call will fail with
10130    /// `ZX_ERR_NO_RESOURCES`.
10131    ///
10132    /// Note that the method of service discovery or advertising is defined by
10133    /// the service or protocol, so it is the responsibility of the caller to
10134    /// communicate the assigned PSM to any clients.
10135    pub fn r#listen_l2cap(
10136        &self,
10137        mut payload: ChannelListenerRegistryListenL2capRequest,
10138        ___deadline: zx::MonotonicInstant,
10139    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
10140        let _response = self.client.send_query::<
10141            ChannelListenerRegistryListenL2capRequest,
10142            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
10143            PrivilegedCentralMarker,
10144        >(
10145            &mut payload,
10146            0x39c6e9001d102338,
10147            fidl::encoding::DynamicFlags::empty(),
10148            ___deadline,
10149        )?;
10150        Ok(_response.map(|x| x))
10151    }
10152
10153    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
10154    /// initiated, then `result_watcher` will be closed with an epitaph.
10155    ///
10156    /// A Central client is allowed to have only one active scan at a time.
10157    /// Accordingly, only one Scan request can be outstanding at a time.
10158    /// Additional calls to Scan will fail.
10159    ///
10160    /// The lifetime of the scan session is tied to the `result_watcher`
10161    /// protocol provided. The scan will be stopped if the channel is closed.
10162    ///
10163    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
10164    /// can be used to watch for scan results.
10165    ///
10166    /// + request `options` Options used to configure the scan session.
10167    /// + request `result_watcher` Protocol that remains valid for the duration
10168    ///   of this scan session.
10169    /// - response An empty response will be sent to acknowledge the scan has
10170    ///   stopped.
10171    ///
10172    /// The following epitaphs may be sent by the server on error:
10173    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
10174    ///   protocol is only allowed 1 active scan.
10175    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
10176    ///   `ScanOptions` documentation.
10177    /// * error `INTERNAL`: An internal error occurred and a scan could not be
10178    ///   started.
10179    pub fn r#scan(
10180        &self,
10181        mut options: &ScanOptions,
10182        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
10183        ___deadline: zx::MonotonicInstant,
10184    ) -> Result<(), fidl::Error> {
10185        let _response = self.client.send_query::<
10186            CentralScanRequest,
10187            fidl::encoding::EmptyPayload,
10188            PrivilegedCentralMarker,
10189        >(
10190            (options, result_watcher,),
10191            0x41f7121798dfe15f,
10192            fidl::encoding::DynamicFlags::empty(),
10193            ___deadline,
10194        )?;
10195        Ok(_response)
10196    }
10197
10198    /// Connect to the peer with the given identifier.
10199    ///
10200    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
10201    /// client's interest on the LE connection to the peer. Closing the channel
10202    /// removes interest, but may not result in disconnection if another client
10203    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
10204    ///
10205    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
10206    /// system if the connection to the peer is lost or an error occurs.
10207    ///
10208    /// The following epitaphs may be sent by the server on error:
10209    /// + `INVALID_ARGS`: Some of the parameters are invalid.
10210    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
10211    ///                    Connection should be used.
10212    /// + `NOT_CONNECTED`: A connection could not be established.
10213    /// + `CONNECTION_RESET`: The peer disconnected.
10214    ///
10215    /// + request `id` Identifier of the peer to initiate a connection to.
10216    /// + request `options` Options used to configure the connection.
10217    /// + request `handle` Handle that remains valid for the duration of this
10218    ///   connection.
10219    pub fn r#connect(
10220        &self,
10221        mut id: &fidl_fuchsia_bluetooth::PeerId,
10222        mut options: &ConnectionOptions,
10223        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
10224    ) -> Result<(), fidl::Error> {
10225        self.client.send::<CentralConnectRequest>(
10226            (id, options, handle),
10227            0x31a3065f2a6913c4,
10228            fidl::encoding::DynamicFlags::empty(),
10229        )
10230    }
10231
10232    /// Synchronize to a periodic advertising train. Reports will be delivered via the
10233    /// `PeriodicAdvertisingSync` protocol.
10234    pub fn r#sync_to_periodic_advertising(
10235        &self,
10236        mut payload: CentralSyncToPeriodicAdvertisingRequest,
10237    ) -> Result<(), fidl::Error> {
10238        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
10239            &mut payload,
10240            0x1db6df126a00c5b9,
10241            fidl::encoding::DynamicFlags::empty(),
10242        )
10243    }
10244
10245    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
10246    /// operation is only valid when operating in the Central role for a connection.
10247    ///
10248    /// If the Central channel is closed before the CIG is explicitly removed, the group will
10249    /// be removed and disconnected.
10250    ///
10251    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
10252    /// id allocated by the host.
10253    pub fn r#create_connected_isochronous_group(
10254        &self,
10255        mut payload: CentralCreateConnectedIsochronousGroupRequest,
10256        ___deadline: zx::MonotonicInstant,
10257    ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
10258        let _response = self
10259            .client
10260            .send_query::<CentralCreateConnectedIsochronousGroupRequest, fidl::encoding::ResultType<
10261                CentralCreateConnectedIsochronousGroupResponse,
10262                CreateCigError,
10263            >, PrivilegedCentralMarker>(
10264                &mut payload,
10265                0x60323e70ae22e13,
10266                fidl::encoding::DynamicFlags::empty(),
10267                ___deadline,
10268            )?;
10269        Ok(_response.map(|x| x))
10270    }
10271
10272    /// Returns the list of peripherals that are known to the system from previous scan, connection,
10273    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
10274    /// be present on the peripheral.
10275    ///
10276    /// This method only returns peripherals (i.e. connectable devices).
10277    pub fn r#get_peripherals(
10278        &self,
10279        mut service_uuids: Option<&[String]>,
10280        ___deadline: zx::MonotonicInstant,
10281    ) -> Result<Vec<RemoteDevice>, fidl::Error> {
10282        let _response = self.client.send_query::<
10283            CentralGetPeripheralsRequest,
10284            CentralGetPeripheralsResponse,
10285            PrivilegedCentralMarker,
10286        >(
10287            (service_uuids,),
10288            0x37ba777499c683a8,
10289            fidl::encoding::DynamicFlags::empty(),
10290            ___deadline,
10291        )?;
10292        Ok(_response.peripherals)
10293    }
10294
10295    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
10296    ///
10297    /// Returns information about a single peripheral that is known to the system from previous scan,
10298    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
10299    /// `identifier` is not recognized.
10300    pub fn r#get_peripheral(
10301        &self,
10302        mut identifier: &str,
10303        ___deadline: zx::MonotonicInstant,
10304    ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
10305        let _response = self.client.send_query::<
10306            CentralGetPeripheralRequest,
10307            CentralGetPeripheralResponse,
10308            PrivilegedCentralMarker,
10309        >(
10310            (identifier,),
10311            0x97f5a2f2d9c13da,
10312            fidl::encoding::DynamicFlags::empty(),
10313            ___deadline,
10314        )?;
10315        Ok(_response.peripheral)
10316    }
10317
10318    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
10319    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
10320    /// `filter` will replace the existing session's filter.
10321    ///
10322    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
10323    /// will be notified for all discoverable devices that are found. This is not recommended; clients
10324    /// should generally filter results by at least one of `filter.service_uuids`,
10325    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
10326    pub fn r#start_scan(
10327        &self,
10328        mut filter: Option<&ScanFilter>,
10329        ___deadline: zx::MonotonicInstant,
10330    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10331        let _response = self.client.send_query::<
10332            CentralStartScanRequest,
10333            CentralStartScanResponse,
10334            PrivilegedCentralMarker,
10335        >(
10336            (filter,),
10337            0xeb4cf0cd0e1132b,
10338            fidl::encoding::DynamicFlags::empty(),
10339            ___deadline,
10340        )?;
10341        Ok(_response.status)
10342    }
10343
10344    /// Terminate a previously started scan session.
10345    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
10346        self.client.send::<fidl::encoding::EmptyPayload>(
10347            (),
10348            0x5f79ee6a0bb037a0,
10349            fidl::encoding::DynamicFlags::empty(),
10350        )
10351    }
10352
10353    /// Creates a connection to the peripheral device with the given identifier.
10354    /// Returns the status of the operation in `status`.
10355    ///
10356    /// On success, `gatt_client` will be bound and can be used for GATT client
10357    /// role procedures. On failure, `gatt_client` will be closed and `status` will
10358    /// indicate an error.
10359    pub fn r#connect_peripheral(
10360        &self,
10361        mut identifier: &str,
10362        mut options: &ConnectionOptions,
10363        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10364        ___deadline: zx::MonotonicInstant,
10365    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10366        let _response = self.client.send_query::<
10367            CentralConnectPeripheralRequest,
10368            CentralConnectPeripheralResponse,
10369            PrivilegedCentralMarker,
10370        >(
10371            (identifier, options, gatt_client,),
10372            0x714d6c32d066d75a,
10373            fidl::encoding::DynamicFlags::empty(),
10374            ___deadline,
10375        )?;
10376        Ok(_response.status)
10377    }
10378
10379    /// Disconnects this Central's connection to the peripheral with the given identifier.
10380    pub fn r#disconnect_peripheral(
10381        &self,
10382        mut identifier: &str,
10383        ___deadline: zx::MonotonicInstant,
10384    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10385        let _response = self.client.send_query::<
10386            CentralDisconnectPeripheralRequest,
10387            CentralDisconnectPeripheralResponse,
10388            PrivilegedCentralMarker,
10389        >(
10390            (identifier,),
10391            0xa9430da197362fd,
10392            fidl::encoding::DynamicFlags::empty(),
10393            ___deadline,
10394        )?;
10395        Ok(_response.status)
10396    }
10397}
10398
10399#[cfg(target_os = "fuchsia")]
10400impl From<PrivilegedCentralSynchronousProxy> for zx::NullableHandle {
10401    fn from(value: PrivilegedCentralSynchronousProxy) -> Self {
10402        value.into_channel().into()
10403    }
10404}
10405
10406#[cfg(target_os = "fuchsia")]
10407impl From<fidl::Channel> for PrivilegedCentralSynchronousProxy {
10408    fn from(value: fidl::Channel) -> Self {
10409        Self::new(value)
10410    }
10411}
10412
10413#[cfg(target_os = "fuchsia")]
10414impl fidl::endpoints::FromClient for PrivilegedCentralSynchronousProxy {
10415    type Protocol = PrivilegedCentralMarker;
10416
10417    fn from_client(value: fidl::endpoints::ClientEnd<PrivilegedCentralMarker>) -> Self {
10418        Self::new(value.into_channel())
10419    }
10420}
10421
10422#[derive(Debug, Clone)]
10423pub struct PrivilegedCentralProxy {
10424    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10425}
10426
10427impl fidl::endpoints::Proxy for PrivilegedCentralProxy {
10428    type Protocol = PrivilegedCentralMarker;
10429
10430    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10431        Self::new(inner)
10432    }
10433
10434    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10435        self.client.into_channel().map_err(|client| Self { client })
10436    }
10437
10438    fn as_channel(&self) -> &::fidl::AsyncChannel {
10439        self.client.as_channel()
10440    }
10441}
10442
10443impl PrivilegedCentralProxy {
10444    /// Create a new Proxy for fuchsia.bluetooth.le/PrivilegedCentral.
10445    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10446        let protocol_name =
10447            <PrivilegedCentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10448        Self { client: fidl::client::Client::new(channel, protocol_name) }
10449    }
10450
10451    /// Get a Stream of events from the remote end of the protocol.
10452    ///
10453    /// # Panics
10454    ///
10455    /// Panics if the event stream was already taken.
10456    pub fn take_event_stream(&self) -> PrivilegedCentralEventStream {
10457        PrivilegedCentralEventStream { event_receiver: self.client.take_event_receiver() }
10458    }
10459
10460    /// Register a listener for incoming channels. The registry will assign a
10461    /// PSM value that is unique for the local device, as well as open a
10462    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
10463    /// event that all PSMs have been assigned, this call will fail with
10464    /// `ZX_ERR_NO_RESOURCES`.
10465    ///
10466    /// Note that the method of service discovery or advertising is defined by
10467    /// the service or protocol, so it is the responsibility of the caller to
10468    /// communicate the assigned PSM to any clients.
10469    pub fn r#listen_l2cap(
10470        &self,
10471        mut payload: ChannelListenerRegistryListenL2capRequest,
10472    ) -> fidl::client::QueryResponseFut<
10473        ChannelListenerRegistryListenL2capResult,
10474        fidl::encoding::DefaultFuchsiaResourceDialect,
10475    > {
10476        PrivilegedCentralProxyInterface::r#listen_l2cap(self, payload)
10477    }
10478
10479    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
10480    /// initiated, then `result_watcher` will be closed with an epitaph.
10481    ///
10482    /// A Central client is allowed to have only one active scan at a time.
10483    /// Accordingly, only one Scan request can be outstanding at a time.
10484    /// Additional calls to Scan will fail.
10485    ///
10486    /// The lifetime of the scan session is tied to the `result_watcher`
10487    /// protocol provided. The scan will be stopped if the channel is closed.
10488    ///
10489    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
10490    /// can be used to watch for scan results.
10491    ///
10492    /// + request `options` Options used to configure the scan session.
10493    /// + request `result_watcher` Protocol that remains valid for the duration
10494    ///   of this scan session.
10495    /// - response An empty response will be sent to acknowledge the scan has
10496    ///   stopped.
10497    ///
10498    /// The following epitaphs may be sent by the server on error:
10499    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
10500    ///   protocol is only allowed 1 active scan.
10501    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
10502    ///   `ScanOptions` documentation.
10503    /// * error `INTERNAL`: An internal error occurred and a scan could not be
10504    ///   started.
10505    pub fn r#scan(
10506        &self,
10507        mut options: &ScanOptions,
10508        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
10509    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10510        PrivilegedCentralProxyInterface::r#scan(self, options, result_watcher)
10511    }
10512
10513    /// Connect to the peer with the given identifier.
10514    ///
10515    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
10516    /// client's interest on the LE connection to the peer. Closing the channel
10517    /// removes interest, but may not result in disconnection if another client
10518    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
10519    ///
10520    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
10521    /// system if the connection to the peer is lost or an error occurs.
10522    ///
10523    /// The following epitaphs may be sent by the server on error:
10524    /// + `INVALID_ARGS`: Some of the parameters are invalid.
10525    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
10526    ///                    Connection should be used.
10527    /// + `NOT_CONNECTED`: A connection could not be established.
10528    /// + `CONNECTION_RESET`: The peer disconnected.
10529    ///
10530    /// + request `id` Identifier of the peer to initiate a connection to.
10531    /// + request `options` Options used to configure the connection.
10532    /// + request `handle` Handle that remains valid for the duration of this
10533    ///   connection.
10534    pub fn r#connect(
10535        &self,
10536        mut id: &fidl_fuchsia_bluetooth::PeerId,
10537        mut options: &ConnectionOptions,
10538        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
10539    ) -> Result<(), fidl::Error> {
10540        PrivilegedCentralProxyInterface::r#connect(self, id, options, handle)
10541    }
10542
10543    /// Synchronize to a periodic advertising train. Reports will be delivered via the
10544    /// `PeriodicAdvertisingSync` protocol.
10545    pub fn r#sync_to_periodic_advertising(
10546        &self,
10547        mut payload: CentralSyncToPeriodicAdvertisingRequest,
10548    ) -> Result<(), fidl::Error> {
10549        PrivilegedCentralProxyInterface::r#sync_to_periodic_advertising(self, payload)
10550    }
10551
10552    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
10553    /// operation is only valid when operating in the Central role for a connection.
10554    ///
10555    /// If the Central channel is closed before the CIG is explicitly removed, the group will
10556    /// be removed and disconnected.
10557    ///
10558    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
10559    /// id allocated by the host.
10560    pub fn r#create_connected_isochronous_group(
10561        &self,
10562        mut payload: CentralCreateConnectedIsochronousGroupRequest,
10563    ) -> fidl::client::QueryResponseFut<
10564        CentralCreateConnectedIsochronousGroupResult,
10565        fidl::encoding::DefaultFuchsiaResourceDialect,
10566    > {
10567        PrivilegedCentralProxyInterface::r#create_connected_isochronous_group(self, payload)
10568    }
10569
10570    /// Returns the list of peripherals that are known to the system from previous scan, connection,
10571    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
10572    /// be present on the peripheral.
10573    ///
10574    /// This method only returns peripherals (i.e. connectable devices).
10575    pub fn r#get_peripherals(
10576        &self,
10577        mut service_uuids: Option<&[String]>,
10578    ) -> fidl::client::QueryResponseFut<
10579        Vec<RemoteDevice>,
10580        fidl::encoding::DefaultFuchsiaResourceDialect,
10581    > {
10582        PrivilegedCentralProxyInterface::r#get_peripherals(self, service_uuids)
10583    }
10584
10585    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
10586    ///
10587    /// Returns information about a single peripheral that is known to the system from previous scan,
10588    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
10589    /// `identifier` is not recognized.
10590    pub fn r#get_peripheral(
10591        &self,
10592        mut identifier: &str,
10593    ) -> fidl::client::QueryResponseFut<
10594        Option<Box<RemoteDevice>>,
10595        fidl::encoding::DefaultFuchsiaResourceDialect,
10596    > {
10597        PrivilegedCentralProxyInterface::r#get_peripheral(self, identifier)
10598    }
10599
10600    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
10601    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
10602    /// `filter` will replace the existing session's filter.
10603    ///
10604    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
10605    /// will be notified for all discoverable devices that are found. This is not recommended; clients
10606    /// should generally filter results by at least one of `filter.service_uuids`,
10607    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
10608    pub fn r#start_scan(
10609        &self,
10610        mut filter: Option<&ScanFilter>,
10611    ) -> fidl::client::QueryResponseFut<
10612        fidl_fuchsia_bluetooth::Status,
10613        fidl::encoding::DefaultFuchsiaResourceDialect,
10614    > {
10615        PrivilegedCentralProxyInterface::r#start_scan(self, filter)
10616    }
10617
10618    /// Terminate a previously started scan session.
10619    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
10620        PrivilegedCentralProxyInterface::r#stop_scan(self)
10621    }
10622
10623    /// Creates a connection to the peripheral device with the given identifier.
10624    /// Returns the status of the operation in `status`.
10625    ///
10626    /// On success, `gatt_client` will be bound and can be used for GATT client
10627    /// role procedures. On failure, `gatt_client` will be closed and `status` will
10628    /// indicate an error.
10629    pub fn r#connect_peripheral(
10630        &self,
10631        mut identifier: &str,
10632        mut options: &ConnectionOptions,
10633        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10634    ) -> fidl::client::QueryResponseFut<
10635        fidl_fuchsia_bluetooth::Status,
10636        fidl::encoding::DefaultFuchsiaResourceDialect,
10637    > {
10638        PrivilegedCentralProxyInterface::r#connect_peripheral(
10639            self,
10640            identifier,
10641            options,
10642            gatt_client,
10643        )
10644    }
10645
10646    /// Disconnects this Central's connection to the peripheral with the given identifier.
10647    pub fn r#disconnect_peripheral(
10648        &self,
10649        mut identifier: &str,
10650    ) -> fidl::client::QueryResponseFut<
10651        fidl_fuchsia_bluetooth::Status,
10652        fidl::encoding::DefaultFuchsiaResourceDialect,
10653    > {
10654        PrivilegedCentralProxyInterface::r#disconnect_peripheral(self, identifier)
10655    }
10656}
10657
10658impl PrivilegedCentralProxyInterface for PrivilegedCentralProxy {
10659    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
10660        ChannelListenerRegistryListenL2capResult,
10661        fidl::encoding::DefaultFuchsiaResourceDialect,
10662    >;
10663    fn r#listen_l2cap(
10664        &self,
10665        mut payload: ChannelListenerRegistryListenL2capRequest,
10666    ) -> Self::ListenL2capResponseFut {
10667        fn _decode(
10668            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10669        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
10670            let _response = fidl::client::decode_transaction_body::<
10671                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
10672                fidl::encoding::DefaultFuchsiaResourceDialect,
10673                0x39c6e9001d102338,
10674            >(_buf?)?;
10675            Ok(_response.map(|x| x))
10676        }
10677        self.client.send_query_and_decode::<
10678            ChannelListenerRegistryListenL2capRequest,
10679            ChannelListenerRegistryListenL2capResult,
10680        >(
10681            &mut payload,
10682            0x39c6e9001d102338,
10683            fidl::encoding::DynamicFlags::empty(),
10684            _decode,
10685        )
10686    }
10687
10688    type ScanResponseFut =
10689        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
10690    fn r#scan(
10691        &self,
10692        mut options: &ScanOptions,
10693        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
10694    ) -> Self::ScanResponseFut {
10695        fn _decode(
10696            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10697        ) -> Result<(), fidl::Error> {
10698            let _response = fidl::client::decode_transaction_body::<
10699                fidl::encoding::EmptyPayload,
10700                fidl::encoding::DefaultFuchsiaResourceDialect,
10701                0x41f7121798dfe15f,
10702            >(_buf?)?;
10703            Ok(_response)
10704        }
10705        self.client.send_query_and_decode::<CentralScanRequest, ()>(
10706            (options, result_watcher),
10707            0x41f7121798dfe15f,
10708            fidl::encoding::DynamicFlags::empty(),
10709            _decode,
10710        )
10711    }
10712
10713    fn r#connect(
10714        &self,
10715        mut id: &fidl_fuchsia_bluetooth::PeerId,
10716        mut options: &ConnectionOptions,
10717        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
10718    ) -> Result<(), fidl::Error> {
10719        self.client.send::<CentralConnectRequest>(
10720            (id, options, handle),
10721            0x31a3065f2a6913c4,
10722            fidl::encoding::DynamicFlags::empty(),
10723        )
10724    }
10725
10726    fn r#sync_to_periodic_advertising(
10727        &self,
10728        mut payload: CentralSyncToPeriodicAdvertisingRequest,
10729    ) -> Result<(), fidl::Error> {
10730        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
10731            &mut payload,
10732            0x1db6df126a00c5b9,
10733            fidl::encoding::DynamicFlags::empty(),
10734        )
10735    }
10736
10737    type CreateConnectedIsochronousGroupResponseFut = fidl::client::QueryResponseFut<
10738        CentralCreateConnectedIsochronousGroupResult,
10739        fidl::encoding::DefaultFuchsiaResourceDialect,
10740    >;
10741    fn r#create_connected_isochronous_group(
10742        &self,
10743        mut payload: CentralCreateConnectedIsochronousGroupRequest,
10744    ) -> Self::CreateConnectedIsochronousGroupResponseFut {
10745        fn _decode(
10746            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10747        ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
10748            let _response = fidl::client::decode_transaction_body::<
10749                fidl::encoding::ResultType<
10750                    CentralCreateConnectedIsochronousGroupResponse,
10751                    CreateCigError,
10752                >,
10753                fidl::encoding::DefaultFuchsiaResourceDialect,
10754                0x60323e70ae22e13,
10755            >(_buf?)?;
10756            Ok(_response.map(|x| x))
10757        }
10758        self.client.send_query_and_decode::<
10759            CentralCreateConnectedIsochronousGroupRequest,
10760            CentralCreateConnectedIsochronousGroupResult,
10761        >(
10762            &mut payload,
10763            0x60323e70ae22e13,
10764            fidl::encoding::DynamicFlags::empty(),
10765            _decode,
10766        )
10767    }
10768
10769    type GetPeripheralsResponseFut = fidl::client::QueryResponseFut<
10770        Vec<RemoteDevice>,
10771        fidl::encoding::DefaultFuchsiaResourceDialect,
10772    >;
10773    fn r#get_peripherals(
10774        &self,
10775        mut service_uuids: Option<&[String]>,
10776    ) -> Self::GetPeripheralsResponseFut {
10777        fn _decode(
10778            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10779        ) -> Result<Vec<RemoteDevice>, fidl::Error> {
10780            let _response = fidl::client::decode_transaction_body::<
10781                CentralGetPeripheralsResponse,
10782                fidl::encoding::DefaultFuchsiaResourceDialect,
10783                0x37ba777499c683a8,
10784            >(_buf?)?;
10785            Ok(_response.peripherals)
10786        }
10787        self.client.send_query_and_decode::<CentralGetPeripheralsRequest, Vec<RemoteDevice>>(
10788            (service_uuids,),
10789            0x37ba777499c683a8,
10790            fidl::encoding::DynamicFlags::empty(),
10791            _decode,
10792        )
10793    }
10794
10795    type GetPeripheralResponseFut = fidl::client::QueryResponseFut<
10796        Option<Box<RemoteDevice>>,
10797        fidl::encoding::DefaultFuchsiaResourceDialect,
10798    >;
10799    fn r#get_peripheral(&self, mut identifier: &str) -> Self::GetPeripheralResponseFut {
10800        fn _decode(
10801            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10802        ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
10803            let _response = fidl::client::decode_transaction_body::<
10804                CentralGetPeripheralResponse,
10805                fidl::encoding::DefaultFuchsiaResourceDialect,
10806                0x97f5a2f2d9c13da,
10807            >(_buf?)?;
10808            Ok(_response.peripheral)
10809        }
10810        self.client.send_query_and_decode::<CentralGetPeripheralRequest, Option<Box<RemoteDevice>>>(
10811            (identifier,),
10812            0x97f5a2f2d9c13da,
10813            fidl::encoding::DynamicFlags::empty(),
10814            _decode,
10815        )
10816    }
10817
10818    type StartScanResponseFut = fidl::client::QueryResponseFut<
10819        fidl_fuchsia_bluetooth::Status,
10820        fidl::encoding::DefaultFuchsiaResourceDialect,
10821    >;
10822    fn r#start_scan(&self, mut filter: Option<&ScanFilter>) -> Self::StartScanResponseFut {
10823        fn _decode(
10824            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10825        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10826            let _response = fidl::client::decode_transaction_body::<
10827                CentralStartScanResponse,
10828                fidl::encoding::DefaultFuchsiaResourceDialect,
10829                0xeb4cf0cd0e1132b,
10830            >(_buf?)?;
10831            Ok(_response.status)
10832        }
10833        self.client
10834            .send_query_and_decode::<CentralStartScanRequest, fidl_fuchsia_bluetooth::Status>(
10835                (filter,),
10836                0xeb4cf0cd0e1132b,
10837                fidl::encoding::DynamicFlags::empty(),
10838                _decode,
10839            )
10840    }
10841
10842    fn r#stop_scan(&self) -> Result<(), fidl::Error> {
10843        self.client.send::<fidl::encoding::EmptyPayload>(
10844            (),
10845            0x5f79ee6a0bb037a0,
10846            fidl::encoding::DynamicFlags::empty(),
10847        )
10848    }
10849
10850    type ConnectPeripheralResponseFut = fidl::client::QueryResponseFut<
10851        fidl_fuchsia_bluetooth::Status,
10852        fidl::encoding::DefaultFuchsiaResourceDialect,
10853    >;
10854    fn r#connect_peripheral(
10855        &self,
10856        mut identifier: &str,
10857        mut options: &ConnectionOptions,
10858        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10859    ) -> Self::ConnectPeripheralResponseFut {
10860        fn _decode(
10861            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10862        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10863            let _response = fidl::client::decode_transaction_body::<
10864                CentralConnectPeripheralResponse,
10865                fidl::encoding::DefaultFuchsiaResourceDialect,
10866                0x714d6c32d066d75a,
10867            >(_buf?)?;
10868            Ok(_response.status)
10869        }
10870        self.client.send_query_and_decode::<
10871            CentralConnectPeripheralRequest,
10872            fidl_fuchsia_bluetooth::Status,
10873        >(
10874            (identifier, options, gatt_client,),
10875            0x714d6c32d066d75a,
10876            fidl::encoding::DynamicFlags::empty(),
10877            _decode,
10878        )
10879    }
10880
10881    type DisconnectPeripheralResponseFut = fidl::client::QueryResponseFut<
10882        fidl_fuchsia_bluetooth::Status,
10883        fidl::encoding::DefaultFuchsiaResourceDialect,
10884    >;
10885    fn r#disconnect_peripheral(
10886        &self,
10887        mut identifier: &str,
10888    ) -> Self::DisconnectPeripheralResponseFut {
10889        fn _decode(
10890            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10891        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10892            let _response = fidl::client::decode_transaction_body::<
10893                CentralDisconnectPeripheralResponse,
10894                fidl::encoding::DefaultFuchsiaResourceDialect,
10895                0xa9430da197362fd,
10896            >(_buf?)?;
10897            Ok(_response.status)
10898        }
10899        self.client.send_query_and_decode::<
10900            CentralDisconnectPeripheralRequest,
10901            fidl_fuchsia_bluetooth::Status,
10902        >(
10903            (identifier,),
10904            0xa9430da197362fd,
10905            fidl::encoding::DynamicFlags::empty(),
10906            _decode,
10907        )
10908    }
10909}
10910
10911pub struct PrivilegedCentralEventStream {
10912    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
10913}
10914
10915impl std::marker::Unpin for PrivilegedCentralEventStream {}
10916
10917impl futures::stream::FusedStream for PrivilegedCentralEventStream {
10918    fn is_terminated(&self) -> bool {
10919        self.event_receiver.is_terminated()
10920    }
10921}
10922
10923impl futures::Stream for PrivilegedCentralEventStream {
10924    type Item = Result<PrivilegedCentralEvent, fidl::Error>;
10925
10926    fn poll_next(
10927        mut self: std::pin::Pin<&mut Self>,
10928        cx: &mut std::task::Context<'_>,
10929    ) -> std::task::Poll<Option<Self::Item>> {
10930        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10931            &mut self.event_receiver,
10932            cx
10933        )?) {
10934            Some(buf) => std::task::Poll::Ready(Some(PrivilegedCentralEvent::decode(buf))),
10935            None => std::task::Poll::Ready(None),
10936        }
10937    }
10938}
10939
10940#[derive(Debug)]
10941pub enum PrivilegedCentralEvent {
10942    OnScanStateChanged { scanning: bool },
10943    OnDeviceDiscovered { device: RemoteDevice },
10944    OnPeripheralDisconnected { identifier: String },
10945}
10946
10947impl PrivilegedCentralEvent {
10948    #[allow(irrefutable_let_patterns)]
10949    pub fn into_on_scan_state_changed(self) -> Option<bool> {
10950        if let PrivilegedCentralEvent::OnScanStateChanged { scanning } = self {
10951            Some((scanning))
10952        } else {
10953            None
10954        }
10955    }
10956    #[allow(irrefutable_let_patterns)]
10957    pub fn into_on_device_discovered(self) -> Option<RemoteDevice> {
10958        if let PrivilegedCentralEvent::OnDeviceDiscovered { device } = self {
10959            Some((device))
10960        } else {
10961            None
10962        }
10963    }
10964    #[allow(irrefutable_let_patterns)]
10965    pub fn into_on_peripheral_disconnected(self) -> Option<String> {
10966        if let PrivilegedCentralEvent::OnPeripheralDisconnected { identifier } = self {
10967            Some((identifier))
10968        } else {
10969            None
10970        }
10971    }
10972
10973    /// Decodes a message buffer as a [`PrivilegedCentralEvent`].
10974    fn decode(
10975        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10976    ) -> Result<PrivilegedCentralEvent, fidl::Error> {
10977        let (bytes, _handles) = buf.split_mut();
10978        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10979        debug_assert_eq!(tx_header.tx_id, 0);
10980        match tx_header.ordinal {
10981            0x5f8edc23cad04d3f => {
10982                let mut out = fidl::new_empty!(
10983                    CentralOnScanStateChangedRequest,
10984                    fidl::encoding::DefaultFuchsiaResourceDialect
10985                );
10986                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnScanStateChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
10987                Ok((PrivilegedCentralEvent::OnScanStateChanged { scanning: out.scanning }))
10988            }
10989            0x708dadf20d66db6 => {
10990                let mut out = fidl::new_empty!(
10991                    CentralOnDeviceDiscoveredRequest,
10992                    fidl::encoding::DefaultFuchsiaResourceDialect
10993                );
10994                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnDeviceDiscoveredRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
10995                Ok((PrivilegedCentralEvent::OnDeviceDiscovered { device: out.device }))
10996            }
10997            0x4e4c6b979b2126df => {
10998                let mut out = fidl::new_empty!(
10999                    CentralOnPeripheralDisconnectedRequest,
11000                    fidl::encoding::DefaultFuchsiaResourceDialect
11001                );
11002                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnPeripheralDisconnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
11003                Ok((PrivilegedCentralEvent::OnPeripheralDisconnected {
11004                    identifier: out.identifier,
11005                }))
11006            }
11007            _ => Err(fidl::Error::UnknownOrdinal {
11008                ordinal: tx_header.ordinal,
11009                protocol_name:
11010                    <PrivilegedCentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11011            }),
11012        }
11013    }
11014}
11015
11016/// A Stream of incoming requests for fuchsia.bluetooth.le/PrivilegedCentral.
11017pub struct PrivilegedCentralRequestStream {
11018    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11019    is_terminated: bool,
11020}
11021
11022impl std::marker::Unpin for PrivilegedCentralRequestStream {}
11023
11024impl futures::stream::FusedStream for PrivilegedCentralRequestStream {
11025    fn is_terminated(&self) -> bool {
11026        self.is_terminated
11027    }
11028}
11029
11030impl fidl::endpoints::RequestStream for PrivilegedCentralRequestStream {
11031    type Protocol = PrivilegedCentralMarker;
11032    type ControlHandle = PrivilegedCentralControlHandle;
11033
11034    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11035        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11036    }
11037
11038    fn control_handle(&self) -> Self::ControlHandle {
11039        PrivilegedCentralControlHandle { inner: self.inner.clone() }
11040    }
11041
11042    fn into_inner(
11043        self,
11044    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11045    {
11046        (self.inner, self.is_terminated)
11047    }
11048
11049    fn from_inner(
11050        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11051        is_terminated: bool,
11052    ) -> Self {
11053        Self { inner, is_terminated }
11054    }
11055}
11056
11057impl futures::Stream for PrivilegedCentralRequestStream {
11058    type Item = Result<PrivilegedCentralRequest, fidl::Error>;
11059
11060    fn poll_next(
11061        mut self: std::pin::Pin<&mut Self>,
11062        cx: &mut std::task::Context<'_>,
11063    ) -> std::task::Poll<Option<Self::Item>> {
11064        let this = &mut *self;
11065        if this.inner.check_shutdown(cx) {
11066            this.is_terminated = true;
11067            return std::task::Poll::Ready(None);
11068        }
11069        if this.is_terminated {
11070            panic!("polled PrivilegedCentralRequestStream after completion");
11071        }
11072        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11073            |bytes, handles| {
11074                match this.inner.channel().read_etc(cx, bytes, handles) {
11075                    std::task::Poll::Ready(Ok(())) => {}
11076                    std::task::Poll::Pending => return std::task::Poll::Pending,
11077                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11078                        this.is_terminated = true;
11079                        return std::task::Poll::Ready(None);
11080                    }
11081                    std::task::Poll::Ready(Err(e)) => {
11082                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11083                            e.into(),
11084                        ))));
11085                    }
11086                }
11087
11088                // A message has been received from the channel
11089                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11090
11091                std::task::Poll::Ready(Some(match header.ordinal {
11092                    0x39c6e9001d102338 => {
11093                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11094                        let mut req = fidl::new_empty!(
11095                            ChannelListenerRegistryListenL2capRequest,
11096                            fidl::encoding::DefaultFuchsiaResourceDialect
11097                        );
11098                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
11099                        let control_handle =
11100                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11101                        Ok(PrivilegedCentralRequest::ListenL2cap {
11102                            payload: req,
11103                            responder: PrivilegedCentralListenL2capResponder {
11104                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11105                                tx_id: header.tx_id,
11106                            },
11107                        })
11108                    }
11109                    0x41f7121798dfe15f => {
11110                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11111                        let mut req = fidl::new_empty!(
11112                            CentralScanRequest,
11113                            fidl::encoding::DefaultFuchsiaResourceDialect
11114                        );
11115                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralScanRequest>(&header, _body_bytes, handles, &mut req)?;
11116                        let control_handle =
11117                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11118                        Ok(PrivilegedCentralRequest::Scan {
11119                            options: req.options,
11120                            result_watcher: req.result_watcher,
11121
11122                            responder: PrivilegedCentralScanResponder {
11123                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11124                                tx_id: header.tx_id,
11125                            },
11126                        })
11127                    }
11128                    0x31a3065f2a6913c4 => {
11129                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11130                        let mut req = fidl::new_empty!(
11131                            CentralConnectRequest,
11132                            fidl::encoding::DefaultFuchsiaResourceDialect
11133                        );
11134                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectRequest>(&header, _body_bytes, handles, &mut req)?;
11135                        let control_handle =
11136                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11137                        Ok(PrivilegedCentralRequest::Connect {
11138                            id: req.id,
11139                            options: req.options,
11140                            handle: req.handle,
11141
11142                            control_handle,
11143                        })
11144                    }
11145                    0x1db6df126a00c5b9 => {
11146                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11147                        let mut req = fidl::new_empty!(
11148                            CentralSyncToPeriodicAdvertisingRequest,
11149                            fidl::encoding::DefaultFuchsiaResourceDialect
11150                        );
11151                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralSyncToPeriodicAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
11152                        let control_handle =
11153                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11154                        Ok(PrivilegedCentralRequest::SyncToPeriodicAdvertising {
11155                            payload: req,
11156                            control_handle,
11157                        })
11158                    }
11159                    0x60323e70ae22e13 => {
11160                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11161                        let mut req = fidl::new_empty!(
11162                            CentralCreateConnectedIsochronousGroupRequest,
11163                            fidl::encoding::DefaultFuchsiaResourceDialect
11164                        );
11165                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralCreateConnectedIsochronousGroupRequest>(&header, _body_bytes, handles, &mut req)?;
11166                        let control_handle =
11167                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11168                        Ok(PrivilegedCentralRequest::CreateConnectedIsochronousGroup {
11169                            payload: req,
11170                            responder: PrivilegedCentralCreateConnectedIsochronousGroupResponder {
11171                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11172                                tx_id: header.tx_id,
11173                            },
11174                        })
11175                    }
11176                    0x37ba777499c683a8 => {
11177                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11178                        let mut req = fidl::new_empty!(
11179                            CentralGetPeripheralsRequest,
11180                            fidl::encoding::DefaultFuchsiaResourceDialect
11181                        );
11182                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralsRequest>(&header, _body_bytes, handles, &mut req)?;
11183                        let control_handle =
11184                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11185                        Ok(PrivilegedCentralRequest::GetPeripherals {
11186                            service_uuids: req.service_uuids,
11187
11188                            responder: PrivilegedCentralGetPeripheralsResponder {
11189                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11190                                tx_id: header.tx_id,
11191                            },
11192                        })
11193                    }
11194                    0x97f5a2f2d9c13da => {
11195                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11196                        let mut req = fidl::new_empty!(
11197                            CentralGetPeripheralRequest,
11198                            fidl::encoding::DefaultFuchsiaResourceDialect
11199                        );
11200                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
11201                        let control_handle =
11202                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11203                        Ok(PrivilegedCentralRequest::GetPeripheral {
11204                            identifier: req.identifier,
11205
11206                            responder: PrivilegedCentralGetPeripheralResponder {
11207                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11208                                tx_id: header.tx_id,
11209                            },
11210                        })
11211                    }
11212                    0xeb4cf0cd0e1132b => {
11213                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11214                        let mut req = fidl::new_empty!(
11215                            CentralStartScanRequest,
11216                            fidl::encoding::DefaultFuchsiaResourceDialect
11217                        );
11218                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralStartScanRequest>(&header, _body_bytes, handles, &mut req)?;
11219                        let control_handle =
11220                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11221                        Ok(PrivilegedCentralRequest::StartScan {
11222                            filter: req.filter,
11223
11224                            responder: PrivilegedCentralStartScanResponder {
11225                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11226                                tx_id: header.tx_id,
11227                            },
11228                        })
11229                    }
11230                    0x5f79ee6a0bb037a0 => {
11231                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11232                        let mut req = fidl::new_empty!(
11233                            fidl::encoding::EmptyPayload,
11234                            fidl::encoding::DefaultFuchsiaResourceDialect
11235                        );
11236                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
11237                        let control_handle =
11238                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11239                        Ok(PrivilegedCentralRequest::StopScan { control_handle })
11240                    }
11241                    0x714d6c32d066d75a => {
11242                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11243                        let mut req = fidl::new_empty!(
11244                            CentralConnectPeripheralRequest,
11245                            fidl::encoding::DefaultFuchsiaResourceDialect
11246                        );
11247                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
11248                        let control_handle =
11249                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11250                        Ok(PrivilegedCentralRequest::ConnectPeripheral {
11251                            identifier: req.identifier,
11252                            options: req.options,
11253                            gatt_client: req.gatt_client,
11254
11255                            responder: PrivilegedCentralConnectPeripheralResponder {
11256                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11257                                tx_id: header.tx_id,
11258                            },
11259                        })
11260                    }
11261                    0xa9430da197362fd => {
11262                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11263                        let mut req = fidl::new_empty!(
11264                            CentralDisconnectPeripheralRequest,
11265                            fidl::encoding::DefaultFuchsiaResourceDialect
11266                        );
11267                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralDisconnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
11268                        let control_handle =
11269                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11270                        Ok(PrivilegedCentralRequest::DisconnectPeripheral {
11271                            identifier: req.identifier,
11272
11273                            responder: PrivilegedCentralDisconnectPeripheralResponder {
11274                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11275                                tx_id: header.tx_id,
11276                            },
11277                        })
11278                    }
11279                    _ => Err(fidl::Error::UnknownOrdinal {
11280                        ordinal: header.ordinal,
11281                        protocol_name:
11282                            <PrivilegedCentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11283                    }),
11284                }))
11285            },
11286        )
11287    }
11288}
11289
11290/// Privileged version of the Central protocol, providing advanced features
11291/// like socket offload. This protocol should only be routed to trusted and
11292/// system components due to sensitive information and capabilities it composes.
11293#[derive(Debug)]
11294pub enum PrivilegedCentralRequest {
11295    /// Register a listener for incoming channels. The registry will assign a
11296    /// PSM value that is unique for the local device, as well as open a
11297    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
11298    /// event that all PSMs have been assigned, this call will fail with
11299    /// `ZX_ERR_NO_RESOURCES`.
11300    ///
11301    /// Note that the method of service discovery or advertising is defined by
11302    /// the service or protocol, so it is the responsibility of the caller to
11303    /// communicate the assigned PSM to any clients.
11304    ListenL2cap {
11305        payload: ChannelListenerRegistryListenL2capRequest,
11306        responder: PrivilegedCentralListenL2capResponder,
11307    },
11308    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
11309    /// initiated, then `result_watcher` will be closed with an epitaph.
11310    ///
11311    /// A Central client is allowed to have only one active scan at a time.
11312    /// Accordingly, only one Scan request can be outstanding at a time.
11313    /// Additional calls to Scan will fail.
11314    ///
11315    /// The lifetime of the scan session is tied to the `result_watcher`
11316    /// protocol provided. The scan will be stopped if the channel is closed.
11317    ///
11318    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
11319    /// can be used to watch for scan results.
11320    ///
11321    /// + request `options` Options used to configure the scan session.
11322    /// + request `result_watcher` Protocol that remains valid for the duration
11323    ///   of this scan session.
11324    /// - response An empty response will be sent to acknowledge the scan has
11325    ///   stopped.
11326    ///
11327    /// The following epitaphs may be sent by the server on error:
11328    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
11329    ///   protocol is only allowed 1 active scan.
11330    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
11331    ///   `ScanOptions` documentation.
11332    /// * error `INTERNAL`: An internal error occurred and a scan could not be
11333    ///   started.
11334    Scan {
11335        options: ScanOptions,
11336        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
11337        responder: PrivilegedCentralScanResponder,
11338    },
11339    /// Connect to the peer with the given identifier.
11340    ///
11341    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
11342    /// client's interest on the LE connection to the peer. Closing the channel
11343    /// removes interest, but may not result in disconnection if another client
11344    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
11345    ///
11346    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
11347    /// system if the connection to the peer is lost or an error occurs.
11348    ///
11349    /// The following epitaphs may be sent by the server on error:
11350    /// + `INVALID_ARGS`: Some of the parameters are invalid.
11351    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
11352    ///                    Connection should be used.
11353    /// + `NOT_CONNECTED`: A connection could not be established.
11354    /// + `CONNECTION_RESET`: The peer disconnected.
11355    ///
11356    /// + request `id` Identifier of the peer to initiate a connection to.
11357    /// + request `options` Options used to configure the connection.
11358    /// + request `handle` Handle that remains valid for the duration of this
11359    ///   connection.
11360    Connect {
11361        id: fidl_fuchsia_bluetooth::PeerId,
11362        options: ConnectionOptions,
11363        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
11364        control_handle: PrivilegedCentralControlHandle,
11365    },
11366    /// Synchronize to a periodic advertising train. Reports will be delivered via the
11367    /// `PeriodicAdvertisingSync` protocol.
11368    SyncToPeriodicAdvertising {
11369        payload: CentralSyncToPeriodicAdvertisingRequest,
11370        control_handle: PrivilegedCentralControlHandle,
11371    },
11372    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
11373    /// operation is only valid when operating in the Central role for a connection.
11374    ///
11375    /// If the Central channel is closed before the CIG is explicitly removed, the group will
11376    /// be removed and disconnected.
11377    ///
11378    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
11379    /// id allocated by the host.
11380    CreateConnectedIsochronousGroup {
11381        payload: CentralCreateConnectedIsochronousGroupRequest,
11382        responder: PrivilegedCentralCreateConnectedIsochronousGroupResponder,
11383    },
11384    /// Returns the list of peripherals that are known to the system from previous scan, connection,
11385    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
11386    /// be present on the peripheral.
11387    ///
11388    /// This method only returns peripherals (i.e. connectable devices).
11389    GetPeripherals {
11390        service_uuids: Option<Vec<String>>,
11391        responder: PrivilegedCentralGetPeripheralsResponder,
11392    },
11393    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
11394    ///
11395    /// Returns information about a single peripheral that is known to the system from previous scan,
11396    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
11397    /// `identifier` is not recognized.
11398    GetPeripheral { identifier: String, responder: PrivilegedCentralGetPeripheralResponder },
11399    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
11400    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
11401    /// `filter` will replace the existing session's filter.
11402    ///
11403    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
11404    /// will be notified for all discoverable devices that are found. This is not recommended; clients
11405    /// should generally filter results by at least one of `filter.service_uuids`,
11406    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
11407    StartScan { filter: Option<Box<ScanFilter>>, responder: PrivilegedCentralStartScanResponder },
11408    /// Terminate a previously started scan session.
11409    StopScan { control_handle: PrivilegedCentralControlHandle },
11410    /// Creates a connection to the peripheral device with the given identifier.
11411    /// Returns the status of the operation in `status`.
11412    ///
11413    /// On success, `gatt_client` will be bound and can be used for GATT client
11414    /// role procedures. On failure, `gatt_client` will be closed and `status` will
11415    /// indicate an error.
11416    ConnectPeripheral {
11417        identifier: String,
11418        options: ConnectionOptions,
11419        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
11420        responder: PrivilegedCentralConnectPeripheralResponder,
11421    },
11422    /// Disconnects this Central's connection to the peripheral with the given identifier.
11423    DisconnectPeripheral {
11424        identifier: String,
11425        responder: PrivilegedCentralDisconnectPeripheralResponder,
11426    },
11427}
11428
11429impl PrivilegedCentralRequest {
11430    #[allow(irrefutable_let_patterns)]
11431    pub fn into_listen_l2cap(
11432        self,
11433    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PrivilegedCentralListenL2capResponder)>
11434    {
11435        if let PrivilegedCentralRequest::ListenL2cap { payload, responder } = self {
11436            Some((payload, responder))
11437        } else {
11438            None
11439        }
11440    }
11441
11442    #[allow(irrefutable_let_patterns)]
11443    pub fn into_scan(
11444        self,
11445    ) -> Option<(
11446        ScanOptions,
11447        fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
11448        PrivilegedCentralScanResponder,
11449    )> {
11450        if let PrivilegedCentralRequest::Scan { options, result_watcher, responder } = self {
11451            Some((options, result_watcher, responder))
11452        } else {
11453            None
11454        }
11455    }
11456
11457    #[allow(irrefutable_let_patterns)]
11458    pub fn into_connect(
11459        self,
11460    ) -> Option<(
11461        fidl_fuchsia_bluetooth::PeerId,
11462        ConnectionOptions,
11463        fidl::endpoints::ServerEnd<ConnectionMarker>,
11464        PrivilegedCentralControlHandle,
11465    )> {
11466        if let PrivilegedCentralRequest::Connect { id, options, handle, control_handle } = self {
11467            Some((id, options, handle, control_handle))
11468        } else {
11469            None
11470        }
11471    }
11472
11473    #[allow(irrefutable_let_patterns)]
11474    pub fn into_sync_to_periodic_advertising(
11475        self,
11476    ) -> Option<(CentralSyncToPeriodicAdvertisingRequest, PrivilegedCentralControlHandle)> {
11477        if let PrivilegedCentralRequest::SyncToPeriodicAdvertising { payload, control_handle } =
11478            self
11479        {
11480            Some((payload, control_handle))
11481        } else {
11482            None
11483        }
11484    }
11485
11486    #[allow(irrefutable_let_patterns)]
11487    pub fn into_create_connected_isochronous_group(
11488        self,
11489    ) -> Option<(
11490        CentralCreateConnectedIsochronousGroupRequest,
11491        PrivilegedCentralCreateConnectedIsochronousGroupResponder,
11492    )> {
11493        if let PrivilegedCentralRequest::CreateConnectedIsochronousGroup { payload, responder } =
11494            self
11495        {
11496            Some((payload, responder))
11497        } else {
11498            None
11499        }
11500    }
11501
11502    #[allow(irrefutable_let_patterns)]
11503    pub fn into_get_peripherals(
11504        self,
11505    ) -> Option<(Option<Vec<String>>, PrivilegedCentralGetPeripheralsResponder)> {
11506        if let PrivilegedCentralRequest::GetPeripherals { service_uuids, responder } = self {
11507            Some((service_uuids, responder))
11508        } else {
11509            None
11510        }
11511    }
11512
11513    #[allow(irrefutable_let_patterns)]
11514    pub fn into_get_peripheral(self) -> Option<(String, PrivilegedCentralGetPeripheralResponder)> {
11515        if let PrivilegedCentralRequest::GetPeripheral { identifier, responder } = self {
11516            Some((identifier, responder))
11517        } else {
11518            None
11519        }
11520    }
11521
11522    #[allow(irrefutable_let_patterns)]
11523    pub fn into_start_scan(
11524        self,
11525    ) -> Option<(Option<Box<ScanFilter>>, PrivilegedCentralStartScanResponder)> {
11526        if let PrivilegedCentralRequest::StartScan { filter, responder } = self {
11527            Some((filter, responder))
11528        } else {
11529            None
11530        }
11531    }
11532
11533    #[allow(irrefutable_let_patterns)]
11534    pub fn into_stop_scan(self) -> Option<(PrivilegedCentralControlHandle)> {
11535        if let PrivilegedCentralRequest::StopScan { control_handle } = self {
11536            Some((control_handle))
11537        } else {
11538            None
11539        }
11540    }
11541
11542    #[allow(irrefutable_let_patterns)]
11543    pub fn into_connect_peripheral(
11544        self,
11545    ) -> Option<(
11546        String,
11547        ConnectionOptions,
11548        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
11549        PrivilegedCentralConnectPeripheralResponder,
11550    )> {
11551        if let PrivilegedCentralRequest::ConnectPeripheral {
11552            identifier,
11553            options,
11554            gatt_client,
11555            responder,
11556        } = self
11557        {
11558            Some((identifier, options, gatt_client, responder))
11559        } else {
11560            None
11561        }
11562    }
11563
11564    #[allow(irrefutable_let_patterns)]
11565    pub fn into_disconnect_peripheral(
11566        self,
11567    ) -> Option<(String, PrivilegedCentralDisconnectPeripheralResponder)> {
11568        if let PrivilegedCentralRequest::DisconnectPeripheral { identifier, responder } = self {
11569            Some((identifier, responder))
11570        } else {
11571            None
11572        }
11573    }
11574
11575    /// Name of the method defined in FIDL
11576    pub fn method_name(&self) -> &'static str {
11577        match *self {
11578            PrivilegedCentralRequest::ListenL2cap { .. } => "listen_l2cap",
11579            PrivilegedCentralRequest::Scan { .. } => "scan",
11580            PrivilegedCentralRequest::Connect { .. } => "connect",
11581            PrivilegedCentralRequest::SyncToPeriodicAdvertising { .. } => {
11582                "sync_to_periodic_advertising"
11583            }
11584            PrivilegedCentralRequest::CreateConnectedIsochronousGroup { .. } => {
11585                "create_connected_isochronous_group"
11586            }
11587            PrivilegedCentralRequest::GetPeripherals { .. } => "get_peripherals",
11588            PrivilegedCentralRequest::GetPeripheral { .. } => "get_peripheral",
11589            PrivilegedCentralRequest::StartScan { .. } => "start_scan",
11590            PrivilegedCentralRequest::StopScan { .. } => "stop_scan",
11591            PrivilegedCentralRequest::ConnectPeripheral { .. } => "connect_peripheral",
11592            PrivilegedCentralRequest::DisconnectPeripheral { .. } => "disconnect_peripheral",
11593        }
11594    }
11595}
11596
11597#[derive(Debug, Clone)]
11598pub struct PrivilegedCentralControlHandle {
11599    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11600}
11601
11602impl PrivilegedCentralControlHandle {
11603    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
11604        self.inner.shutdown_with_epitaph(status.into())
11605    }
11606}
11607
11608impl fidl::endpoints::ControlHandle for PrivilegedCentralControlHandle {
11609    fn shutdown(&self) {
11610        self.inner.shutdown()
11611    }
11612
11613    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
11614        self.inner.shutdown_with_epitaph(status)
11615    }
11616
11617    fn is_closed(&self) -> bool {
11618        self.inner.channel().is_closed()
11619    }
11620    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11621        self.inner.channel().on_closed()
11622    }
11623
11624    #[cfg(target_os = "fuchsia")]
11625    fn signal_peer(
11626        &self,
11627        clear_mask: zx::Signals,
11628        set_mask: zx::Signals,
11629    ) -> Result<(), zx_status::Status> {
11630        use fidl::Peered;
11631        self.inner.channel().signal_peer(clear_mask, set_mask)
11632    }
11633}
11634
11635impl PrivilegedCentralControlHandle {
11636    pub fn send_on_scan_state_changed(&self, mut scanning: bool) -> Result<(), fidl::Error> {
11637        self.inner.send::<CentralOnScanStateChangedRequest>(
11638            (scanning,),
11639            0,
11640            0x5f8edc23cad04d3f,
11641            fidl::encoding::DynamicFlags::empty(),
11642        )
11643    }
11644
11645    pub fn send_on_device_discovered(&self, mut device: &RemoteDevice) -> Result<(), fidl::Error> {
11646        self.inner.send::<CentralOnDeviceDiscoveredRequest>(
11647            (device,),
11648            0,
11649            0x708dadf20d66db6,
11650            fidl::encoding::DynamicFlags::empty(),
11651        )
11652    }
11653
11654    pub fn send_on_peripheral_disconnected(&self, mut identifier: &str) -> Result<(), fidl::Error> {
11655        self.inner.send::<CentralOnPeripheralDisconnectedRequest>(
11656            (identifier,),
11657            0,
11658            0x4e4c6b979b2126df,
11659            fidl::encoding::DynamicFlags::empty(),
11660        )
11661    }
11662}
11663
11664#[must_use = "FIDL methods require a response to be sent"]
11665#[derive(Debug)]
11666pub struct PrivilegedCentralListenL2capResponder {
11667    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
11668    tx_id: u32,
11669}
11670
11671/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
11672/// if the responder is dropped without sending a response, so that the client
11673/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11674impl std::ops::Drop for PrivilegedCentralListenL2capResponder {
11675    fn drop(&mut self) {
11676        self.control_handle.shutdown();
11677        // Safety: drops once, never accessed again
11678        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11679    }
11680}
11681
11682impl fidl::endpoints::Responder for PrivilegedCentralListenL2capResponder {
11683    type ControlHandle = PrivilegedCentralControlHandle;
11684
11685    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
11686        &self.control_handle
11687    }
11688
11689    fn drop_without_shutdown(mut self) {
11690        // Safety: drops once, never accessed again due to mem::forget
11691        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11692        // Prevent Drop from running (which would shut down the channel)
11693        std::mem::forget(self);
11694    }
11695}
11696
11697impl PrivilegedCentralListenL2capResponder {
11698    /// Sends a response to the FIDL transaction.
11699    ///
11700    /// Sets the channel to shutdown if an error occurs.
11701    pub fn send(
11702        self,
11703        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
11704    ) -> Result<(), fidl::Error> {
11705        let _result = self.send_raw(result);
11706        if _result.is_err() {
11707            self.control_handle.shutdown();
11708        }
11709        self.drop_without_shutdown();
11710        _result
11711    }
11712
11713    /// Similar to "send" but does not shutdown the channel if an error occurs.
11714    pub fn send_no_shutdown_on_err(
11715        self,
11716        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
11717    ) -> Result<(), fidl::Error> {
11718        let _result = self.send_raw(result);
11719        self.drop_without_shutdown();
11720        _result
11721    }
11722
11723    fn send_raw(
11724        &self,
11725        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
11726    ) -> Result<(), fidl::Error> {
11727        self.control_handle.inner.send::<fidl::encoding::ResultType<
11728            ChannelListenerRegistryListenL2capResponse,
11729            i32,
11730        >>(
11731            result,
11732            self.tx_id,
11733            0x39c6e9001d102338,
11734            fidl::encoding::DynamicFlags::empty(),
11735        )
11736    }
11737}
11738
11739#[must_use = "FIDL methods require a response to be sent"]
11740#[derive(Debug)]
11741pub struct PrivilegedCentralScanResponder {
11742    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
11743    tx_id: u32,
11744}
11745
11746/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
11747/// if the responder is dropped without sending a response, so that the client
11748/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11749impl std::ops::Drop for PrivilegedCentralScanResponder {
11750    fn drop(&mut self) {
11751        self.control_handle.shutdown();
11752        // Safety: drops once, never accessed again
11753        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11754    }
11755}
11756
11757impl fidl::endpoints::Responder for PrivilegedCentralScanResponder {
11758    type ControlHandle = PrivilegedCentralControlHandle;
11759
11760    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
11761        &self.control_handle
11762    }
11763
11764    fn drop_without_shutdown(mut self) {
11765        // Safety: drops once, never accessed again due to mem::forget
11766        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11767        // Prevent Drop from running (which would shut down the channel)
11768        std::mem::forget(self);
11769    }
11770}
11771
11772impl PrivilegedCentralScanResponder {
11773    /// Sends a response to the FIDL transaction.
11774    ///
11775    /// Sets the channel to shutdown if an error occurs.
11776    pub fn send(self) -> Result<(), fidl::Error> {
11777        let _result = self.send_raw();
11778        if _result.is_err() {
11779            self.control_handle.shutdown();
11780        }
11781        self.drop_without_shutdown();
11782        _result
11783    }
11784
11785    /// Similar to "send" but does not shutdown the channel if an error occurs.
11786    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11787        let _result = self.send_raw();
11788        self.drop_without_shutdown();
11789        _result
11790    }
11791
11792    fn send_raw(&self) -> Result<(), fidl::Error> {
11793        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11794            (),
11795            self.tx_id,
11796            0x41f7121798dfe15f,
11797            fidl::encoding::DynamicFlags::empty(),
11798        )
11799    }
11800}
11801
11802#[must_use = "FIDL methods require a response to be sent"]
11803#[derive(Debug)]
11804pub struct PrivilegedCentralCreateConnectedIsochronousGroupResponder {
11805    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
11806    tx_id: u32,
11807}
11808
11809/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
11810/// if the responder is dropped without sending a response, so that the client
11811/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11812impl std::ops::Drop for PrivilegedCentralCreateConnectedIsochronousGroupResponder {
11813    fn drop(&mut self) {
11814        self.control_handle.shutdown();
11815        // Safety: drops once, never accessed again
11816        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11817    }
11818}
11819
11820impl fidl::endpoints::Responder for PrivilegedCentralCreateConnectedIsochronousGroupResponder {
11821    type ControlHandle = PrivilegedCentralControlHandle;
11822
11823    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
11824        &self.control_handle
11825    }
11826
11827    fn drop_without_shutdown(mut self) {
11828        // Safety: drops once, never accessed again due to mem::forget
11829        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11830        // Prevent Drop from running (which would shut down the channel)
11831        std::mem::forget(self);
11832    }
11833}
11834
11835impl PrivilegedCentralCreateConnectedIsochronousGroupResponder {
11836    /// Sends a response to the FIDL transaction.
11837    ///
11838    /// Sets the channel to shutdown if an error occurs.
11839    pub fn send(
11840        self,
11841        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
11842    ) -> Result<(), fidl::Error> {
11843        let _result = self.send_raw(result);
11844        if _result.is_err() {
11845            self.control_handle.shutdown();
11846        }
11847        self.drop_without_shutdown();
11848        _result
11849    }
11850
11851    /// Similar to "send" but does not shutdown the channel if an error occurs.
11852    pub fn send_no_shutdown_on_err(
11853        self,
11854        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
11855    ) -> Result<(), fidl::Error> {
11856        let _result = self.send_raw(result);
11857        self.drop_without_shutdown();
11858        _result
11859    }
11860
11861    fn send_raw(
11862        &self,
11863        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
11864    ) -> Result<(), fidl::Error> {
11865        self.control_handle.inner.send::<fidl::encoding::ResultType<
11866            CentralCreateConnectedIsochronousGroupResponse,
11867            CreateCigError,
11868        >>(
11869            result,
11870            self.tx_id,
11871            0x60323e70ae22e13,
11872            fidl::encoding::DynamicFlags::empty(),
11873        )
11874    }
11875}
11876
11877#[must_use = "FIDL methods require a response to be sent"]
11878#[derive(Debug)]
11879pub struct PrivilegedCentralGetPeripheralsResponder {
11880    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
11881    tx_id: u32,
11882}
11883
11884/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
11885/// if the responder is dropped without sending a response, so that the client
11886/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11887impl std::ops::Drop for PrivilegedCentralGetPeripheralsResponder {
11888    fn drop(&mut self) {
11889        self.control_handle.shutdown();
11890        // Safety: drops once, never accessed again
11891        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11892    }
11893}
11894
11895impl fidl::endpoints::Responder for PrivilegedCentralGetPeripheralsResponder {
11896    type ControlHandle = PrivilegedCentralControlHandle;
11897
11898    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
11899        &self.control_handle
11900    }
11901
11902    fn drop_without_shutdown(mut self) {
11903        // Safety: drops once, never accessed again due to mem::forget
11904        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11905        // Prevent Drop from running (which would shut down the channel)
11906        std::mem::forget(self);
11907    }
11908}
11909
11910impl PrivilegedCentralGetPeripheralsResponder {
11911    /// Sends a response to the FIDL transaction.
11912    ///
11913    /// Sets the channel to shutdown if an error occurs.
11914    pub fn send(self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
11915        let _result = self.send_raw(peripherals);
11916        if _result.is_err() {
11917            self.control_handle.shutdown();
11918        }
11919        self.drop_without_shutdown();
11920        _result
11921    }
11922
11923    /// Similar to "send" but does not shutdown the channel if an error occurs.
11924    pub fn send_no_shutdown_on_err(
11925        self,
11926        mut peripherals: &[RemoteDevice],
11927    ) -> Result<(), fidl::Error> {
11928        let _result = self.send_raw(peripherals);
11929        self.drop_without_shutdown();
11930        _result
11931    }
11932
11933    fn send_raw(&self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
11934        self.control_handle.inner.send::<CentralGetPeripheralsResponse>(
11935            (peripherals,),
11936            self.tx_id,
11937            0x37ba777499c683a8,
11938            fidl::encoding::DynamicFlags::empty(),
11939        )
11940    }
11941}
11942
11943#[must_use = "FIDL methods require a response to be sent"]
11944#[derive(Debug)]
11945pub struct PrivilegedCentralGetPeripheralResponder {
11946    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
11947    tx_id: u32,
11948}
11949
11950/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
11951/// if the responder is dropped without sending a response, so that the client
11952/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11953impl std::ops::Drop for PrivilegedCentralGetPeripheralResponder {
11954    fn drop(&mut self) {
11955        self.control_handle.shutdown();
11956        // Safety: drops once, never accessed again
11957        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11958    }
11959}
11960
11961impl fidl::endpoints::Responder for PrivilegedCentralGetPeripheralResponder {
11962    type ControlHandle = PrivilegedCentralControlHandle;
11963
11964    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
11965        &self.control_handle
11966    }
11967
11968    fn drop_without_shutdown(mut self) {
11969        // Safety: drops once, never accessed again due to mem::forget
11970        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11971        // Prevent Drop from running (which would shut down the channel)
11972        std::mem::forget(self);
11973    }
11974}
11975
11976impl PrivilegedCentralGetPeripheralResponder {
11977    /// Sends a response to the FIDL transaction.
11978    ///
11979    /// Sets the channel to shutdown if an error occurs.
11980    pub fn send(self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
11981        let _result = self.send_raw(peripheral);
11982        if _result.is_err() {
11983            self.control_handle.shutdown();
11984        }
11985        self.drop_without_shutdown();
11986        _result
11987    }
11988
11989    /// Similar to "send" but does not shutdown the channel if an error occurs.
11990    pub fn send_no_shutdown_on_err(
11991        self,
11992        mut peripheral: Option<&RemoteDevice>,
11993    ) -> Result<(), fidl::Error> {
11994        let _result = self.send_raw(peripheral);
11995        self.drop_without_shutdown();
11996        _result
11997    }
11998
11999    fn send_raw(&self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
12000        self.control_handle.inner.send::<CentralGetPeripheralResponse>(
12001            (peripheral,),
12002            self.tx_id,
12003            0x97f5a2f2d9c13da,
12004            fidl::encoding::DynamicFlags::empty(),
12005        )
12006    }
12007}
12008
12009#[must_use = "FIDL methods require a response to be sent"]
12010#[derive(Debug)]
12011pub struct PrivilegedCentralStartScanResponder {
12012    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
12013    tx_id: u32,
12014}
12015
12016/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
12017/// if the responder is dropped without sending a response, so that the client
12018/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12019impl std::ops::Drop for PrivilegedCentralStartScanResponder {
12020    fn drop(&mut self) {
12021        self.control_handle.shutdown();
12022        // Safety: drops once, never accessed again
12023        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12024    }
12025}
12026
12027impl fidl::endpoints::Responder for PrivilegedCentralStartScanResponder {
12028    type ControlHandle = PrivilegedCentralControlHandle;
12029
12030    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
12031        &self.control_handle
12032    }
12033
12034    fn drop_without_shutdown(mut self) {
12035        // Safety: drops once, never accessed again due to mem::forget
12036        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12037        // Prevent Drop from running (which would shut down the channel)
12038        std::mem::forget(self);
12039    }
12040}
12041
12042impl PrivilegedCentralStartScanResponder {
12043    /// Sends a response to the FIDL transaction.
12044    ///
12045    /// Sets the channel to shutdown if an error occurs.
12046    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
12047        let _result = self.send_raw(status);
12048        if _result.is_err() {
12049            self.control_handle.shutdown();
12050        }
12051        self.drop_without_shutdown();
12052        _result
12053    }
12054
12055    /// Similar to "send" but does not shutdown the channel if an error occurs.
12056    pub fn send_no_shutdown_on_err(
12057        self,
12058        mut status: &fidl_fuchsia_bluetooth::Status,
12059    ) -> Result<(), fidl::Error> {
12060        let _result = self.send_raw(status);
12061        self.drop_without_shutdown();
12062        _result
12063    }
12064
12065    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
12066        self.control_handle.inner.send::<CentralStartScanResponse>(
12067            (status,),
12068            self.tx_id,
12069            0xeb4cf0cd0e1132b,
12070            fidl::encoding::DynamicFlags::empty(),
12071        )
12072    }
12073}
12074
12075#[must_use = "FIDL methods require a response to be sent"]
12076#[derive(Debug)]
12077pub struct PrivilegedCentralConnectPeripheralResponder {
12078    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
12079    tx_id: u32,
12080}
12081
12082/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
12083/// if the responder is dropped without sending a response, so that the client
12084/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12085impl std::ops::Drop for PrivilegedCentralConnectPeripheralResponder {
12086    fn drop(&mut self) {
12087        self.control_handle.shutdown();
12088        // Safety: drops once, never accessed again
12089        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12090    }
12091}
12092
12093impl fidl::endpoints::Responder for PrivilegedCentralConnectPeripheralResponder {
12094    type ControlHandle = PrivilegedCentralControlHandle;
12095
12096    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
12097        &self.control_handle
12098    }
12099
12100    fn drop_without_shutdown(mut self) {
12101        // Safety: drops once, never accessed again due to mem::forget
12102        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12103        // Prevent Drop from running (which would shut down the channel)
12104        std::mem::forget(self);
12105    }
12106}
12107
12108impl PrivilegedCentralConnectPeripheralResponder {
12109    /// Sends a response to the FIDL transaction.
12110    ///
12111    /// Sets the channel to shutdown if an error occurs.
12112    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
12113        let _result = self.send_raw(status);
12114        if _result.is_err() {
12115            self.control_handle.shutdown();
12116        }
12117        self.drop_without_shutdown();
12118        _result
12119    }
12120
12121    /// Similar to "send" but does not shutdown the channel if an error occurs.
12122    pub fn send_no_shutdown_on_err(
12123        self,
12124        mut status: &fidl_fuchsia_bluetooth::Status,
12125    ) -> Result<(), fidl::Error> {
12126        let _result = self.send_raw(status);
12127        self.drop_without_shutdown();
12128        _result
12129    }
12130
12131    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
12132        self.control_handle.inner.send::<CentralConnectPeripheralResponse>(
12133            (status,),
12134            self.tx_id,
12135            0x714d6c32d066d75a,
12136            fidl::encoding::DynamicFlags::empty(),
12137        )
12138    }
12139}
12140
12141#[must_use = "FIDL methods require a response to be sent"]
12142#[derive(Debug)]
12143pub struct PrivilegedCentralDisconnectPeripheralResponder {
12144    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
12145    tx_id: u32,
12146}
12147
12148/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
12149/// if the responder is dropped without sending a response, so that the client
12150/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12151impl std::ops::Drop for PrivilegedCentralDisconnectPeripheralResponder {
12152    fn drop(&mut self) {
12153        self.control_handle.shutdown();
12154        // Safety: drops once, never accessed again
12155        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12156    }
12157}
12158
12159impl fidl::endpoints::Responder for PrivilegedCentralDisconnectPeripheralResponder {
12160    type ControlHandle = PrivilegedCentralControlHandle;
12161
12162    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
12163        &self.control_handle
12164    }
12165
12166    fn drop_without_shutdown(mut self) {
12167        // Safety: drops once, never accessed again due to mem::forget
12168        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12169        // Prevent Drop from running (which would shut down the channel)
12170        std::mem::forget(self);
12171    }
12172}
12173
12174impl PrivilegedCentralDisconnectPeripheralResponder {
12175    /// Sends a response to the FIDL transaction.
12176    ///
12177    /// Sets the channel to shutdown if an error occurs.
12178    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
12179        let _result = self.send_raw(status);
12180        if _result.is_err() {
12181            self.control_handle.shutdown();
12182        }
12183        self.drop_without_shutdown();
12184        _result
12185    }
12186
12187    /// Similar to "send" but does not shutdown the channel if an error occurs.
12188    pub fn send_no_shutdown_on_err(
12189        self,
12190        mut status: &fidl_fuchsia_bluetooth::Status,
12191    ) -> Result<(), fidl::Error> {
12192        let _result = self.send_raw(status);
12193        self.drop_without_shutdown();
12194        _result
12195    }
12196
12197    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
12198        self.control_handle.inner.send::<CentralDisconnectPeripheralResponse>(
12199            (status,),
12200            self.tx_id,
12201            0xa9430da197362fd,
12202            fidl::encoding::DynamicFlags::empty(),
12203        )
12204    }
12205}
12206
12207#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12208pub struct PrivilegedPeripheralMarker;
12209
12210impl fidl::endpoints::ProtocolMarker for PrivilegedPeripheralMarker {
12211    type Proxy = PrivilegedPeripheralProxy;
12212    type RequestStream = PrivilegedPeripheralRequestStream;
12213    #[cfg(target_os = "fuchsia")]
12214    type SynchronousProxy = PrivilegedPeripheralSynchronousProxy;
12215
12216    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.PrivilegedPeripheral";
12217}
12218impl fidl::endpoints::DiscoverableProtocolMarker for PrivilegedPeripheralMarker {}
12219
12220pub trait PrivilegedPeripheralProxyInterface: Send + Sync {
12221    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
12222        + Send;
12223    fn r#listen_l2cap(
12224        &self,
12225        payload: ChannelListenerRegistryListenL2capRequest,
12226    ) -> Self::ListenL2capResponseFut;
12227    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralAdvertiseResult, fidl::Error>>
12228        + Send;
12229    fn r#advertise(
12230        &self,
12231        parameters: &AdvertisingParameters,
12232        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12233    ) -> Self::AdvertiseResponseFut;
12234    type StartAdvertisingResponseFut: std::future::Future<Output = Result<PeripheralStartAdvertisingResult, fidl::Error>>
12235        + Send;
12236    fn r#start_advertising(
12237        &self,
12238        parameters: &AdvertisingParameters,
12239        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12240    ) -> Self::StartAdvertisingResponseFut;
12241}
12242#[derive(Debug)]
12243#[cfg(target_os = "fuchsia")]
12244pub struct PrivilegedPeripheralSynchronousProxy {
12245    client: fidl::client::sync::Client,
12246}
12247
12248#[cfg(target_os = "fuchsia")]
12249impl fidl::endpoints::SynchronousProxy for PrivilegedPeripheralSynchronousProxy {
12250    type Proxy = PrivilegedPeripheralProxy;
12251    type Protocol = PrivilegedPeripheralMarker;
12252
12253    fn from_channel(inner: fidl::Channel) -> Self {
12254        Self::new(inner)
12255    }
12256
12257    fn into_channel(self) -> fidl::Channel {
12258        self.client.into_channel()
12259    }
12260
12261    fn as_channel(&self) -> &fidl::Channel {
12262        self.client.as_channel()
12263    }
12264}
12265
12266#[cfg(target_os = "fuchsia")]
12267impl PrivilegedPeripheralSynchronousProxy {
12268    pub fn new(channel: fidl::Channel) -> Self {
12269        Self { client: fidl::client::sync::Client::new(channel) }
12270    }
12271
12272    pub fn into_channel(self) -> fidl::Channel {
12273        self.client.into_channel()
12274    }
12275
12276    /// Waits until an event arrives and returns it. It is safe for other
12277    /// threads to make concurrent requests while waiting for an event.
12278    pub fn wait_for_event(
12279        &self,
12280        deadline: zx::MonotonicInstant,
12281    ) -> Result<PrivilegedPeripheralEvent, fidl::Error> {
12282        PrivilegedPeripheralEvent::decode(
12283            self.client.wait_for_event::<PrivilegedPeripheralMarker>(deadline)?,
12284        )
12285    }
12286
12287    /// Register a listener for incoming channels. The registry will assign a
12288    /// PSM value that is unique for the local device, as well as open a
12289    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
12290    /// event that all PSMs have been assigned, this call will fail with
12291    /// `ZX_ERR_NO_RESOURCES`.
12292    ///
12293    /// Note that the method of service discovery or advertising is defined by
12294    /// the service or protocol, so it is the responsibility of the caller to
12295    /// communicate the assigned PSM to any clients.
12296    pub fn r#listen_l2cap(
12297        &self,
12298        mut payload: ChannelListenerRegistryListenL2capRequest,
12299        ___deadline: zx::MonotonicInstant,
12300    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
12301        let _response = self.client.send_query::<
12302            ChannelListenerRegistryListenL2capRequest,
12303            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
12304            PrivilegedPeripheralMarker,
12305        >(
12306            &mut payload,
12307            0x39c6e9001d102338,
12308            fidl::encoding::DynamicFlags::empty(),
12309            ___deadline,
12310        )?;
12311        Ok(_response.map(|x| x))
12312    }
12313
12314    /// Start advertising continuously as a LE peripheral. If advertising cannot
12315    /// be initiated then `advertised_peripheral` will be closed and an error
12316    /// will be returned.
12317    ///
12318    /// This method may be called any number of times. To reconfigure an
12319    /// advertisement, first close the original advertisement and then initiate
12320    /// a new advertisement after an empty response is returned.
12321    ///
12322    /// If the client closes its end of the
12323    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
12324    /// advertising will be stopped. If the handle is closed before the request
12325    /// is fulfilled, advertising may be briefly enabled before it is
12326    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
12327    /// the Peripheral protocol, but this may be changed in the future
12328    /// (https://fxbug.dev/42157682).
12329    ///
12330    /// + request `parameters` Parameters used while configuring the advertising
12331    ///   instance.
12332    /// + request `advertised_peripheral` Protocol that remains valid for the
12333    ///   duration of this advertising session.
12334    /// - response An empty response will be sent when the advertisement is
12335    ///   successfully stopped (due to release of the `advertised_peripheral`
12336    ///   protocol). To prevent overlapping similar advertisements and transient
12337    ///   errors with limited advertising resources, waiting for a response is
12338    ///   recommended before calling `Advertise` again.
12339    /// * error If an error occurs, `advertised_peripheral` will be closed and a
12340    ///   `PeripheralError` will be returned.
12341    pub fn r#advertise(
12342        &self,
12343        mut parameters: &AdvertisingParameters,
12344        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12345        ___deadline: zx::MonotonicInstant,
12346    ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
12347        let _response = self.client.send_query::<
12348            PeripheralAdvertiseRequest,
12349            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
12350            PrivilegedPeripheralMarker,
12351        >(
12352            (parameters, advertised_peripheral,),
12353            0x2d9ec9260c32c17f,
12354            fidl::encoding::DynamicFlags::empty(),
12355            ___deadline,
12356        )?;
12357        Ok(_response.map(|x| x))
12358    }
12359
12360    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
12361    /// has successfully initiated. If advertising cannot be initiated, then the response will
12362    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
12363    ///
12364    /// This method can get called any number of times and successive calls can be made to
12365    /// reconfigure the advertising parameters. However only the most recent
12366    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
12367    ///
12368    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
12369    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
12370    /// advertisements.
12371    ///
12372    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
12373    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
12374    /// advertising will be briefly enabled before it is terminated.
12375    ///
12376    /// + request `parameters` Parameters used while configuring the advertising instance.
12377    /// + request `handle` Handle that remains valid for the duration of this advertising session.
12378    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
12379    ///         initiated. In this case the `handle` will be closed.
12380    pub fn r#start_advertising(
12381        &self,
12382        mut parameters: &AdvertisingParameters,
12383        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12384        ___deadline: zx::MonotonicInstant,
12385    ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
12386        let _response = self.client.send_query::<
12387            PeripheralStartAdvertisingRequest,
12388            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
12389            PrivilegedPeripheralMarker,
12390        >(
12391            (parameters, handle,),
12392            0x5875c1c575f00f7d,
12393            fidl::encoding::DynamicFlags::empty(),
12394            ___deadline,
12395        )?;
12396        Ok(_response.map(|x| x))
12397    }
12398}
12399
12400#[cfg(target_os = "fuchsia")]
12401impl From<PrivilegedPeripheralSynchronousProxy> for zx::NullableHandle {
12402    fn from(value: PrivilegedPeripheralSynchronousProxy) -> Self {
12403        value.into_channel().into()
12404    }
12405}
12406
12407#[cfg(target_os = "fuchsia")]
12408impl From<fidl::Channel> for PrivilegedPeripheralSynchronousProxy {
12409    fn from(value: fidl::Channel) -> Self {
12410        Self::new(value)
12411    }
12412}
12413
12414#[cfg(target_os = "fuchsia")]
12415impl fidl::endpoints::FromClient for PrivilegedPeripheralSynchronousProxy {
12416    type Protocol = PrivilegedPeripheralMarker;
12417
12418    fn from_client(value: fidl::endpoints::ClientEnd<PrivilegedPeripheralMarker>) -> Self {
12419        Self::new(value.into_channel())
12420    }
12421}
12422
12423#[derive(Debug, Clone)]
12424pub struct PrivilegedPeripheralProxy {
12425    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
12426}
12427
12428impl fidl::endpoints::Proxy for PrivilegedPeripheralProxy {
12429    type Protocol = PrivilegedPeripheralMarker;
12430
12431    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
12432        Self::new(inner)
12433    }
12434
12435    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
12436        self.client.into_channel().map_err(|client| Self { client })
12437    }
12438
12439    fn as_channel(&self) -> &::fidl::AsyncChannel {
12440        self.client.as_channel()
12441    }
12442}
12443
12444impl PrivilegedPeripheralProxy {
12445    /// Create a new Proxy for fuchsia.bluetooth.le/PrivilegedPeripheral.
12446    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
12447        let protocol_name =
12448            <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12449        Self { client: fidl::client::Client::new(channel, protocol_name) }
12450    }
12451
12452    /// Get a Stream of events from the remote end of the protocol.
12453    ///
12454    /// # Panics
12455    ///
12456    /// Panics if the event stream was already taken.
12457    pub fn take_event_stream(&self) -> PrivilegedPeripheralEventStream {
12458        PrivilegedPeripheralEventStream { event_receiver: self.client.take_event_receiver() }
12459    }
12460
12461    /// Register a listener for incoming channels. The registry will assign a
12462    /// PSM value that is unique for the local device, as well as open a
12463    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
12464    /// event that all PSMs have been assigned, this call will fail with
12465    /// `ZX_ERR_NO_RESOURCES`.
12466    ///
12467    /// Note that the method of service discovery or advertising is defined by
12468    /// the service or protocol, so it is the responsibility of the caller to
12469    /// communicate the assigned PSM to any clients.
12470    pub fn r#listen_l2cap(
12471        &self,
12472        mut payload: ChannelListenerRegistryListenL2capRequest,
12473    ) -> fidl::client::QueryResponseFut<
12474        ChannelListenerRegistryListenL2capResult,
12475        fidl::encoding::DefaultFuchsiaResourceDialect,
12476    > {
12477        PrivilegedPeripheralProxyInterface::r#listen_l2cap(self, payload)
12478    }
12479
12480    /// Start advertising continuously as a LE peripheral. If advertising cannot
12481    /// be initiated then `advertised_peripheral` will be closed and an error
12482    /// will be returned.
12483    ///
12484    /// This method may be called any number of times. To reconfigure an
12485    /// advertisement, first close the original advertisement and then initiate
12486    /// a new advertisement after an empty response is returned.
12487    ///
12488    /// If the client closes its end of the
12489    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
12490    /// advertising will be stopped. If the handle is closed before the request
12491    /// is fulfilled, advertising may be briefly enabled before it is
12492    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
12493    /// the Peripheral protocol, but this may be changed in the future
12494    /// (https://fxbug.dev/42157682).
12495    ///
12496    /// + request `parameters` Parameters used while configuring the advertising
12497    ///   instance.
12498    /// + request `advertised_peripheral` Protocol that remains valid for the
12499    ///   duration of this advertising session.
12500    /// - response An empty response will be sent when the advertisement is
12501    ///   successfully stopped (due to release of the `advertised_peripheral`
12502    ///   protocol). To prevent overlapping similar advertisements and transient
12503    ///   errors with limited advertising resources, waiting for a response is
12504    ///   recommended before calling `Advertise` again.
12505    /// * error If an error occurs, `advertised_peripheral` will be closed and a
12506    ///   `PeripheralError` will be returned.
12507    pub fn r#advertise(
12508        &self,
12509        mut parameters: &AdvertisingParameters,
12510        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12511    ) -> fidl::client::QueryResponseFut<
12512        PeripheralAdvertiseResult,
12513        fidl::encoding::DefaultFuchsiaResourceDialect,
12514    > {
12515        PrivilegedPeripheralProxyInterface::r#advertise(self, parameters, advertised_peripheral)
12516    }
12517
12518    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
12519    /// has successfully initiated. If advertising cannot be initiated, then the response will
12520    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
12521    ///
12522    /// This method can get called any number of times and successive calls can be made to
12523    /// reconfigure the advertising parameters. However only the most recent
12524    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
12525    ///
12526    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
12527    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
12528    /// advertisements.
12529    ///
12530    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
12531    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
12532    /// advertising will be briefly enabled before it is terminated.
12533    ///
12534    /// + request `parameters` Parameters used while configuring the advertising instance.
12535    /// + request `handle` Handle that remains valid for the duration of this advertising session.
12536    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
12537    ///         initiated. In this case the `handle` will be closed.
12538    pub fn r#start_advertising(
12539        &self,
12540        mut parameters: &AdvertisingParameters,
12541        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12542    ) -> fidl::client::QueryResponseFut<
12543        PeripheralStartAdvertisingResult,
12544        fidl::encoding::DefaultFuchsiaResourceDialect,
12545    > {
12546        PrivilegedPeripheralProxyInterface::r#start_advertising(self, parameters, handle)
12547    }
12548}
12549
12550impl PrivilegedPeripheralProxyInterface for PrivilegedPeripheralProxy {
12551    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
12552        ChannelListenerRegistryListenL2capResult,
12553        fidl::encoding::DefaultFuchsiaResourceDialect,
12554    >;
12555    fn r#listen_l2cap(
12556        &self,
12557        mut payload: ChannelListenerRegistryListenL2capRequest,
12558    ) -> Self::ListenL2capResponseFut {
12559        fn _decode(
12560            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12561        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
12562            let _response = fidl::client::decode_transaction_body::<
12563                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
12564                fidl::encoding::DefaultFuchsiaResourceDialect,
12565                0x39c6e9001d102338,
12566            >(_buf?)?;
12567            Ok(_response.map(|x| x))
12568        }
12569        self.client.send_query_and_decode::<
12570            ChannelListenerRegistryListenL2capRequest,
12571            ChannelListenerRegistryListenL2capResult,
12572        >(
12573            &mut payload,
12574            0x39c6e9001d102338,
12575            fidl::encoding::DynamicFlags::empty(),
12576            _decode,
12577        )
12578    }
12579
12580    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
12581        PeripheralAdvertiseResult,
12582        fidl::encoding::DefaultFuchsiaResourceDialect,
12583    >;
12584    fn r#advertise(
12585        &self,
12586        mut parameters: &AdvertisingParameters,
12587        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12588    ) -> Self::AdvertiseResponseFut {
12589        fn _decode(
12590            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12591        ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
12592            let _response = fidl::client::decode_transaction_body::<
12593                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
12594                fidl::encoding::DefaultFuchsiaResourceDialect,
12595                0x2d9ec9260c32c17f,
12596            >(_buf?)?;
12597            Ok(_response.map(|x| x))
12598        }
12599        self.client.send_query_and_decode::<PeripheralAdvertiseRequest, PeripheralAdvertiseResult>(
12600            (parameters, advertised_peripheral),
12601            0x2d9ec9260c32c17f,
12602            fidl::encoding::DynamicFlags::empty(),
12603            _decode,
12604        )
12605    }
12606
12607    type StartAdvertisingResponseFut = fidl::client::QueryResponseFut<
12608        PeripheralStartAdvertisingResult,
12609        fidl::encoding::DefaultFuchsiaResourceDialect,
12610    >;
12611    fn r#start_advertising(
12612        &self,
12613        mut parameters: &AdvertisingParameters,
12614        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12615    ) -> Self::StartAdvertisingResponseFut {
12616        fn _decode(
12617            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12618        ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
12619            let _response = fidl::client::decode_transaction_body::<
12620                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
12621                fidl::encoding::DefaultFuchsiaResourceDialect,
12622                0x5875c1c575f00f7d,
12623            >(_buf?)?;
12624            Ok(_response.map(|x| x))
12625        }
12626        self.client.send_query_and_decode::<
12627            PeripheralStartAdvertisingRequest,
12628            PeripheralStartAdvertisingResult,
12629        >(
12630            (parameters, handle,),
12631            0x5875c1c575f00f7d,
12632            fidl::encoding::DynamicFlags::empty(),
12633            _decode,
12634        )
12635    }
12636}
12637
12638pub struct PrivilegedPeripheralEventStream {
12639    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
12640}
12641
12642impl std::marker::Unpin for PrivilegedPeripheralEventStream {}
12643
12644impl futures::stream::FusedStream for PrivilegedPeripheralEventStream {
12645    fn is_terminated(&self) -> bool {
12646        self.event_receiver.is_terminated()
12647    }
12648}
12649
12650impl futures::Stream for PrivilegedPeripheralEventStream {
12651    type Item = Result<PrivilegedPeripheralEvent, fidl::Error>;
12652
12653    fn poll_next(
12654        mut self: std::pin::Pin<&mut Self>,
12655        cx: &mut std::task::Context<'_>,
12656    ) -> std::task::Poll<Option<Self::Item>> {
12657        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12658            &mut self.event_receiver,
12659            cx
12660        )?) {
12661            Some(buf) => std::task::Poll::Ready(Some(PrivilegedPeripheralEvent::decode(buf))),
12662            None => std::task::Poll::Ready(None),
12663        }
12664    }
12665}
12666
12667#[derive(Debug)]
12668pub enum PrivilegedPeripheralEvent {
12669    OnPeerConnected { peer: Peer, connection: fidl::endpoints::ClientEnd<ConnectionMarker> },
12670}
12671
12672impl PrivilegedPeripheralEvent {
12673    #[allow(irrefutable_let_patterns)]
12674    pub fn into_on_peer_connected(
12675        self,
12676    ) -> Option<(Peer, fidl::endpoints::ClientEnd<ConnectionMarker>)> {
12677        if let PrivilegedPeripheralEvent::OnPeerConnected { peer, connection } = self {
12678            Some((peer, connection))
12679        } else {
12680            None
12681        }
12682    }
12683
12684    /// Decodes a message buffer as a [`PrivilegedPeripheralEvent`].
12685    fn decode(
12686        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12687    ) -> Result<PrivilegedPeripheralEvent, fidl::Error> {
12688        let (bytes, _handles) = buf.split_mut();
12689        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12690        debug_assert_eq!(tx_header.tx_id, 0);
12691        match tx_header.ordinal {
12692            0x16135d464299e356 => {
12693                let mut out = fidl::new_empty!(
12694                    PeripheralOnPeerConnectedRequest,
12695                    fidl::encoding::DefaultFuchsiaResourceDialect
12696                );
12697                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralOnPeerConnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12698                Ok((PrivilegedPeripheralEvent::OnPeerConnected {
12699                    peer: out.peer,
12700                    connection: out.connection,
12701                }))
12702            }
12703            _ => Err(fidl::Error::UnknownOrdinal {
12704                ordinal: tx_header.ordinal,
12705                protocol_name:
12706                    <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12707            }),
12708        }
12709    }
12710}
12711
12712/// A Stream of incoming requests for fuchsia.bluetooth.le/PrivilegedPeripheral.
12713pub struct PrivilegedPeripheralRequestStream {
12714    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12715    is_terminated: bool,
12716}
12717
12718impl std::marker::Unpin for PrivilegedPeripheralRequestStream {}
12719
12720impl futures::stream::FusedStream for PrivilegedPeripheralRequestStream {
12721    fn is_terminated(&self) -> bool {
12722        self.is_terminated
12723    }
12724}
12725
12726impl fidl::endpoints::RequestStream for PrivilegedPeripheralRequestStream {
12727    type Protocol = PrivilegedPeripheralMarker;
12728    type ControlHandle = PrivilegedPeripheralControlHandle;
12729
12730    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12731        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12732    }
12733
12734    fn control_handle(&self) -> Self::ControlHandle {
12735        PrivilegedPeripheralControlHandle { inner: self.inner.clone() }
12736    }
12737
12738    fn into_inner(
12739        self,
12740    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12741    {
12742        (self.inner, self.is_terminated)
12743    }
12744
12745    fn from_inner(
12746        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12747        is_terminated: bool,
12748    ) -> Self {
12749        Self { inner, is_terminated }
12750    }
12751}
12752
12753impl futures::Stream for PrivilegedPeripheralRequestStream {
12754    type Item = Result<PrivilegedPeripheralRequest, fidl::Error>;
12755
12756    fn poll_next(
12757        mut self: std::pin::Pin<&mut Self>,
12758        cx: &mut std::task::Context<'_>,
12759    ) -> std::task::Poll<Option<Self::Item>> {
12760        let this = &mut *self;
12761        if this.inner.check_shutdown(cx) {
12762            this.is_terminated = true;
12763            return std::task::Poll::Ready(None);
12764        }
12765        if this.is_terminated {
12766            panic!("polled PrivilegedPeripheralRequestStream after completion");
12767        }
12768        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12769            |bytes, handles| {
12770                match this.inner.channel().read_etc(cx, bytes, handles) {
12771                    std::task::Poll::Ready(Ok(())) => {}
12772                    std::task::Poll::Pending => return std::task::Poll::Pending,
12773                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12774                        this.is_terminated = true;
12775                        return std::task::Poll::Ready(None);
12776                    }
12777                    std::task::Poll::Ready(Err(e)) => {
12778                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12779                            e.into(),
12780                        ))));
12781                    }
12782                }
12783
12784                // A message has been received from the channel
12785                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12786
12787                std::task::Poll::Ready(Some(match header.ordinal {
12788                0x39c6e9001d102338 => {
12789                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12790                    let mut req = fidl::new_empty!(ChannelListenerRegistryListenL2capRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12791                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
12792                    let control_handle = PrivilegedPeripheralControlHandle {
12793                        inner: this.inner.clone(),
12794                    };
12795                    Ok(PrivilegedPeripheralRequest::ListenL2cap {payload: req,
12796                        responder: PrivilegedPeripheralListenL2capResponder {
12797                            control_handle: std::mem::ManuallyDrop::new(control_handle),
12798                            tx_id: header.tx_id,
12799                        },
12800                    })
12801                }
12802                0x2d9ec9260c32c17f => {
12803                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12804                    let mut req = fidl::new_empty!(PeripheralAdvertiseRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12805                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
12806                    let control_handle = PrivilegedPeripheralControlHandle {
12807                        inner: this.inner.clone(),
12808                    };
12809                    Ok(PrivilegedPeripheralRequest::Advertise {parameters: req.parameters,
12810advertised_peripheral: req.advertised_peripheral,
12811
12812                        responder: PrivilegedPeripheralAdvertiseResponder {
12813                            control_handle: std::mem::ManuallyDrop::new(control_handle),
12814                            tx_id: header.tx_id,
12815                        },
12816                    })
12817                }
12818                0x5875c1c575f00f7d => {
12819                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12820                    let mut req = fidl::new_empty!(PeripheralStartAdvertisingRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12821                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralStartAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
12822                    let control_handle = PrivilegedPeripheralControlHandle {
12823                        inner: this.inner.clone(),
12824                    };
12825                    Ok(PrivilegedPeripheralRequest::StartAdvertising {parameters: req.parameters,
12826handle: req.handle,
12827
12828                        responder: PrivilegedPeripheralStartAdvertisingResponder {
12829                            control_handle: std::mem::ManuallyDrop::new(control_handle),
12830                            tx_id: header.tx_id,
12831                        },
12832                    })
12833                }
12834                _ => Err(fidl::Error::UnknownOrdinal {
12835                    ordinal: header.ordinal,
12836                    protocol_name: <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12837                }),
12838            }))
12839            },
12840        )
12841    }
12842}
12843
12844/// Privileged version of the Peripheral protocol.
12845/// This protocol should only be routed to trusted and system components. Using this protocol will
12846/// enable the client to break normal privacy restrictions which could leak information about the
12847/// location or owner of the device.
12848///
12849/// Use cases which reveal information are noted in documentation and marked as only available
12850/// through PrivilegedPeripheral, and are an error if used through Peripheral.
12851#[derive(Debug)]
12852pub enum PrivilegedPeripheralRequest {
12853    /// Register a listener for incoming channels. The registry will assign a
12854    /// PSM value that is unique for the local device, as well as open a
12855    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
12856    /// event that all PSMs have been assigned, this call will fail with
12857    /// `ZX_ERR_NO_RESOURCES`.
12858    ///
12859    /// Note that the method of service discovery or advertising is defined by
12860    /// the service or protocol, so it is the responsibility of the caller to
12861    /// communicate the assigned PSM to any clients.
12862    ListenL2cap {
12863        payload: ChannelListenerRegistryListenL2capRequest,
12864        responder: PrivilegedPeripheralListenL2capResponder,
12865    },
12866    /// Start advertising continuously as a LE peripheral. If advertising cannot
12867    /// be initiated then `advertised_peripheral` will be closed and an error
12868    /// will be returned.
12869    ///
12870    /// This method may be called any number of times. To reconfigure an
12871    /// advertisement, first close the original advertisement and then initiate
12872    /// a new advertisement after an empty response is returned.
12873    ///
12874    /// If the client closes its end of the
12875    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
12876    /// advertising will be stopped. If the handle is closed before the request
12877    /// is fulfilled, advertising may be briefly enabled before it is
12878    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
12879    /// the Peripheral protocol, but this may be changed in the future
12880    /// (https://fxbug.dev/42157682).
12881    ///
12882    /// + request `parameters` Parameters used while configuring the advertising
12883    ///   instance.
12884    /// + request `advertised_peripheral` Protocol that remains valid for the
12885    ///   duration of this advertising session.
12886    /// - response An empty response will be sent when the advertisement is
12887    ///   successfully stopped (due to release of the `advertised_peripheral`
12888    ///   protocol). To prevent overlapping similar advertisements and transient
12889    ///   errors with limited advertising resources, waiting for a response is
12890    ///   recommended before calling `Advertise` again.
12891    /// * error If an error occurs, `advertised_peripheral` will be closed and a
12892    ///   `PeripheralError` will be returned.
12893    Advertise {
12894        parameters: AdvertisingParameters,
12895        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12896        responder: PrivilegedPeripheralAdvertiseResponder,
12897    },
12898    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
12899    /// has successfully initiated. If advertising cannot be initiated, then the response will
12900    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
12901    ///
12902    /// This method can get called any number of times and successive calls can be made to
12903    /// reconfigure the advertising parameters. However only the most recent
12904    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
12905    ///
12906    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
12907    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
12908    /// advertisements.
12909    ///
12910    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
12911    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
12912    /// advertising will be briefly enabled before it is terminated.
12913    ///
12914    /// + request `parameters` Parameters used while configuring the advertising instance.
12915    /// + request `handle` Handle that remains valid for the duration of this advertising session.
12916    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
12917    ///         initiated. In this case the `handle` will be closed.
12918    StartAdvertising {
12919        parameters: AdvertisingParameters,
12920        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12921        responder: PrivilegedPeripheralStartAdvertisingResponder,
12922    },
12923}
12924
12925impl PrivilegedPeripheralRequest {
12926    #[allow(irrefutable_let_patterns)]
12927    pub fn into_listen_l2cap(
12928        self,
12929    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PrivilegedPeripheralListenL2capResponder)>
12930    {
12931        if let PrivilegedPeripheralRequest::ListenL2cap { payload, responder } = self {
12932            Some((payload, responder))
12933        } else {
12934            None
12935        }
12936    }
12937
12938    #[allow(irrefutable_let_patterns)]
12939    pub fn into_advertise(
12940        self,
12941    ) -> Option<(
12942        AdvertisingParameters,
12943        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12944        PrivilegedPeripheralAdvertiseResponder,
12945    )> {
12946        if let PrivilegedPeripheralRequest::Advertise {
12947            parameters,
12948            advertised_peripheral,
12949            responder,
12950        } = self
12951        {
12952            Some((parameters, advertised_peripheral, responder))
12953        } else {
12954            None
12955        }
12956    }
12957
12958    #[allow(irrefutable_let_patterns)]
12959    pub fn into_start_advertising(
12960        self,
12961    ) -> Option<(
12962        AdvertisingParameters,
12963        fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12964        PrivilegedPeripheralStartAdvertisingResponder,
12965    )> {
12966        if let PrivilegedPeripheralRequest::StartAdvertising { parameters, handle, responder } =
12967            self
12968        {
12969            Some((parameters, handle, responder))
12970        } else {
12971            None
12972        }
12973    }
12974
12975    /// Name of the method defined in FIDL
12976    pub fn method_name(&self) -> &'static str {
12977        match *self {
12978            PrivilegedPeripheralRequest::ListenL2cap { .. } => "listen_l2cap",
12979            PrivilegedPeripheralRequest::Advertise { .. } => "advertise",
12980            PrivilegedPeripheralRequest::StartAdvertising { .. } => "start_advertising",
12981        }
12982    }
12983}
12984
12985#[derive(Debug, Clone)]
12986pub struct PrivilegedPeripheralControlHandle {
12987    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12988}
12989
12990impl PrivilegedPeripheralControlHandle {
12991    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
12992        self.inner.shutdown_with_epitaph(status.into())
12993    }
12994}
12995
12996impl fidl::endpoints::ControlHandle for PrivilegedPeripheralControlHandle {
12997    fn shutdown(&self) {
12998        self.inner.shutdown()
12999    }
13000
13001    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
13002        self.inner.shutdown_with_epitaph(status)
13003    }
13004
13005    fn is_closed(&self) -> bool {
13006        self.inner.channel().is_closed()
13007    }
13008    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13009        self.inner.channel().on_closed()
13010    }
13011
13012    #[cfg(target_os = "fuchsia")]
13013    fn signal_peer(
13014        &self,
13015        clear_mask: zx::Signals,
13016        set_mask: zx::Signals,
13017    ) -> Result<(), zx_status::Status> {
13018        use fidl::Peered;
13019        self.inner.channel().signal_peer(clear_mask, set_mask)
13020    }
13021}
13022
13023impl PrivilegedPeripheralControlHandle {
13024    pub fn send_on_peer_connected(
13025        &self,
13026        mut peer: &Peer,
13027        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
13028    ) -> Result<(), fidl::Error> {
13029        self.inner.send::<PeripheralOnPeerConnectedRequest>(
13030            (peer, connection),
13031            0,
13032            0x16135d464299e356,
13033            fidl::encoding::DynamicFlags::empty(),
13034        )
13035    }
13036}
13037
13038#[must_use = "FIDL methods require a response to be sent"]
13039#[derive(Debug)]
13040pub struct PrivilegedPeripheralListenL2capResponder {
13041    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
13042    tx_id: u32,
13043}
13044
13045/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
13046/// if the responder is dropped without sending a response, so that the client
13047/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13048impl std::ops::Drop for PrivilegedPeripheralListenL2capResponder {
13049    fn drop(&mut self) {
13050        self.control_handle.shutdown();
13051        // Safety: drops once, never accessed again
13052        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13053    }
13054}
13055
13056impl fidl::endpoints::Responder for PrivilegedPeripheralListenL2capResponder {
13057    type ControlHandle = PrivilegedPeripheralControlHandle;
13058
13059    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
13060        &self.control_handle
13061    }
13062
13063    fn drop_without_shutdown(mut self) {
13064        // Safety: drops once, never accessed again due to mem::forget
13065        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13066        // Prevent Drop from running (which would shut down the channel)
13067        std::mem::forget(self);
13068    }
13069}
13070
13071impl PrivilegedPeripheralListenL2capResponder {
13072    /// Sends a response to the FIDL transaction.
13073    ///
13074    /// Sets the channel to shutdown if an error occurs.
13075    pub fn send(
13076        self,
13077        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
13078    ) -> Result<(), fidl::Error> {
13079        let _result = self.send_raw(result);
13080        if _result.is_err() {
13081            self.control_handle.shutdown();
13082        }
13083        self.drop_without_shutdown();
13084        _result
13085    }
13086
13087    /// Similar to "send" but does not shutdown the channel if an error occurs.
13088    pub fn send_no_shutdown_on_err(
13089        self,
13090        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
13091    ) -> Result<(), fidl::Error> {
13092        let _result = self.send_raw(result);
13093        self.drop_without_shutdown();
13094        _result
13095    }
13096
13097    fn send_raw(
13098        &self,
13099        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
13100    ) -> Result<(), fidl::Error> {
13101        self.control_handle.inner.send::<fidl::encoding::ResultType<
13102            ChannelListenerRegistryListenL2capResponse,
13103            i32,
13104        >>(
13105            result,
13106            self.tx_id,
13107            0x39c6e9001d102338,
13108            fidl::encoding::DynamicFlags::empty(),
13109        )
13110    }
13111}
13112
13113#[must_use = "FIDL methods require a response to be sent"]
13114#[derive(Debug)]
13115pub struct PrivilegedPeripheralAdvertiseResponder {
13116    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
13117    tx_id: u32,
13118}
13119
13120/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
13121/// if the responder is dropped without sending a response, so that the client
13122/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13123impl std::ops::Drop for PrivilegedPeripheralAdvertiseResponder {
13124    fn drop(&mut self) {
13125        self.control_handle.shutdown();
13126        // Safety: drops once, never accessed again
13127        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13128    }
13129}
13130
13131impl fidl::endpoints::Responder for PrivilegedPeripheralAdvertiseResponder {
13132    type ControlHandle = PrivilegedPeripheralControlHandle;
13133
13134    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
13135        &self.control_handle
13136    }
13137
13138    fn drop_without_shutdown(mut self) {
13139        // Safety: drops once, never accessed again due to mem::forget
13140        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13141        // Prevent Drop from running (which would shut down the channel)
13142        std::mem::forget(self);
13143    }
13144}
13145
13146impl PrivilegedPeripheralAdvertiseResponder {
13147    /// Sends a response to the FIDL transaction.
13148    ///
13149    /// Sets the channel to shutdown if an error occurs.
13150    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
13151        let _result = self.send_raw(result);
13152        if _result.is_err() {
13153            self.control_handle.shutdown();
13154        }
13155        self.drop_without_shutdown();
13156        _result
13157    }
13158
13159    /// Similar to "send" but does not shutdown the channel if an error occurs.
13160    pub fn send_no_shutdown_on_err(
13161        self,
13162        mut result: Result<(), PeripheralError>,
13163    ) -> Result<(), fidl::Error> {
13164        let _result = self.send_raw(result);
13165        self.drop_without_shutdown();
13166        _result
13167    }
13168
13169    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
13170        self.control_handle.inner.send::<fidl::encoding::ResultType<
13171            fidl::encoding::EmptyStruct,
13172            PeripheralError,
13173        >>(
13174            result,
13175            self.tx_id,
13176            0x2d9ec9260c32c17f,
13177            fidl::encoding::DynamicFlags::empty(),
13178        )
13179    }
13180}
13181
13182#[must_use = "FIDL methods require a response to be sent"]
13183#[derive(Debug)]
13184pub struct PrivilegedPeripheralStartAdvertisingResponder {
13185    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
13186    tx_id: u32,
13187}
13188
13189/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
13190/// if the responder is dropped without sending a response, so that the client
13191/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13192impl std::ops::Drop for PrivilegedPeripheralStartAdvertisingResponder {
13193    fn drop(&mut self) {
13194        self.control_handle.shutdown();
13195        // Safety: drops once, never accessed again
13196        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13197    }
13198}
13199
13200impl fidl::endpoints::Responder for PrivilegedPeripheralStartAdvertisingResponder {
13201    type ControlHandle = PrivilegedPeripheralControlHandle;
13202
13203    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
13204        &self.control_handle
13205    }
13206
13207    fn drop_without_shutdown(mut self) {
13208        // Safety: drops once, never accessed again due to mem::forget
13209        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13210        // Prevent Drop from running (which would shut down the channel)
13211        std::mem::forget(self);
13212    }
13213}
13214
13215impl PrivilegedPeripheralStartAdvertisingResponder {
13216    /// Sends a response to the FIDL transaction.
13217    ///
13218    /// Sets the channel to shutdown if an error occurs.
13219    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
13220        let _result = self.send_raw(result);
13221        if _result.is_err() {
13222            self.control_handle.shutdown();
13223        }
13224        self.drop_without_shutdown();
13225        _result
13226    }
13227
13228    /// Similar to "send" but does not shutdown the channel if an error occurs.
13229    pub fn send_no_shutdown_on_err(
13230        self,
13231        mut result: Result<(), PeripheralError>,
13232    ) -> Result<(), fidl::Error> {
13233        let _result = self.send_raw(result);
13234        self.drop_without_shutdown();
13235        _result
13236    }
13237
13238    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
13239        self.control_handle.inner.send::<fidl::encoding::ResultType<
13240            fidl::encoding::EmptyStruct,
13241            PeripheralError,
13242        >>(
13243            result,
13244            self.tx_id,
13245            0x5875c1c575f00f7d,
13246            fidl::encoding::DynamicFlags::empty(),
13247        )
13248    }
13249}
13250
13251#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13252pub struct ScanResultWatcherMarker;
13253
13254impl fidl::endpoints::ProtocolMarker for ScanResultWatcherMarker {
13255    type Proxy = ScanResultWatcherProxy;
13256    type RequestStream = ScanResultWatcherRequestStream;
13257    #[cfg(target_os = "fuchsia")]
13258    type SynchronousProxy = ScanResultWatcherSynchronousProxy;
13259
13260    const DEBUG_NAME: &'static str = "(anonymous) ScanResultWatcher";
13261}
13262
13263pub trait ScanResultWatcherProxyInterface: Send + Sync {
13264    type WatchResponseFut: std::future::Future<Output = Result<Vec<Peer>, fidl::Error>> + Send;
13265    fn r#watch(&self) -> Self::WatchResponseFut;
13266}
13267#[derive(Debug)]
13268#[cfg(target_os = "fuchsia")]
13269pub struct ScanResultWatcherSynchronousProxy {
13270    client: fidl::client::sync::Client,
13271}
13272
13273#[cfg(target_os = "fuchsia")]
13274impl fidl::endpoints::SynchronousProxy for ScanResultWatcherSynchronousProxy {
13275    type Proxy = ScanResultWatcherProxy;
13276    type Protocol = ScanResultWatcherMarker;
13277
13278    fn from_channel(inner: fidl::Channel) -> Self {
13279        Self::new(inner)
13280    }
13281
13282    fn into_channel(self) -> fidl::Channel {
13283        self.client.into_channel()
13284    }
13285
13286    fn as_channel(&self) -> &fidl::Channel {
13287        self.client.as_channel()
13288    }
13289}
13290
13291#[cfg(target_os = "fuchsia")]
13292impl ScanResultWatcherSynchronousProxy {
13293    pub fn new(channel: fidl::Channel) -> Self {
13294        Self { client: fidl::client::sync::Client::new(channel) }
13295    }
13296
13297    pub fn into_channel(self) -> fidl::Channel {
13298        self.client.into_channel()
13299    }
13300
13301    /// Waits until an event arrives and returns it. It is safe for other
13302    /// threads to make concurrent requests while waiting for an event.
13303    pub fn wait_for_event(
13304        &self,
13305        deadline: zx::MonotonicInstant,
13306    ) -> Result<ScanResultWatcherEvent, fidl::Error> {
13307        ScanResultWatcherEvent::decode(
13308            self.client.wait_for_event::<ScanResultWatcherMarker>(deadline)?,
13309        )
13310    }
13311
13312    /// Returns a list of all LE peers that satisfy the filters indicated in
13313    /// `ScanOptions`. The first response(s) will return matching discovered
13314    /// peers immediately. Subsequent calls receive a response only when peers
13315    /// have been scanned or updated since the last call. If a second call to
13316    /// `Watch` is erronously sent while one call is already pending, the scan
13317    /// will be canceled and the protocol will be closed.
13318    ///
13319    /// - response `updated` Peers that were added or updated since the last
13320    ///   call to Watch().
13321    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<Peer>, fidl::Error> {
13322        let _response = self.client.send_query::<
13323            fidl::encoding::EmptyPayload,
13324            ScanResultWatcherWatchResponse,
13325            ScanResultWatcherMarker,
13326        >(
13327            (),
13328            0x713a122e949f301a,
13329            fidl::encoding::DynamicFlags::empty(),
13330            ___deadline,
13331        )?;
13332        Ok(_response.updated)
13333    }
13334}
13335
13336#[cfg(target_os = "fuchsia")]
13337impl From<ScanResultWatcherSynchronousProxy> for zx::NullableHandle {
13338    fn from(value: ScanResultWatcherSynchronousProxy) -> Self {
13339        value.into_channel().into()
13340    }
13341}
13342
13343#[cfg(target_os = "fuchsia")]
13344impl From<fidl::Channel> for ScanResultWatcherSynchronousProxy {
13345    fn from(value: fidl::Channel) -> Self {
13346        Self::new(value)
13347    }
13348}
13349
13350#[cfg(target_os = "fuchsia")]
13351impl fidl::endpoints::FromClient for ScanResultWatcherSynchronousProxy {
13352    type Protocol = ScanResultWatcherMarker;
13353
13354    fn from_client(value: fidl::endpoints::ClientEnd<ScanResultWatcherMarker>) -> Self {
13355        Self::new(value.into_channel())
13356    }
13357}
13358
13359#[derive(Debug, Clone)]
13360pub struct ScanResultWatcherProxy {
13361    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
13362}
13363
13364impl fidl::endpoints::Proxy for ScanResultWatcherProxy {
13365    type Protocol = ScanResultWatcherMarker;
13366
13367    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
13368        Self::new(inner)
13369    }
13370
13371    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
13372        self.client.into_channel().map_err(|client| Self { client })
13373    }
13374
13375    fn as_channel(&self) -> &::fidl::AsyncChannel {
13376        self.client.as_channel()
13377    }
13378}
13379
13380impl ScanResultWatcherProxy {
13381    /// Create a new Proxy for fuchsia.bluetooth.le/ScanResultWatcher.
13382    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
13383        let protocol_name =
13384            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13385        Self { client: fidl::client::Client::new(channel, protocol_name) }
13386    }
13387
13388    /// Get a Stream of events from the remote end of the protocol.
13389    ///
13390    /// # Panics
13391    ///
13392    /// Panics if the event stream was already taken.
13393    pub fn take_event_stream(&self) -> ScanResultWatcherEventStream {
13394        ScanResultWatcherEventStream { event_receiver: self.client.take_event_receiver() }
13395    }
13396
13397    /// Returns a list of all LE peers that satisfy the filters indicated in
13398    /// `ScanOptions`. The first response(s) will return matching discovered
13399    /// peers immediately. Subsequent calls receive a response only when peers
13400    /// have been scanned or updated since the last call. If a second call to
13401    /// `Watch` is erronously sent while one call is already pending, the scan
13402    /// will be canceled and the protocol will be closed.
13403    ///
13404    /// - response `updated` Peers that were added or updated since the last
13405    ///   call to Watch().
13406    pub fn r#watch(
13407        &self,
13408    ) -> fidl::client::QueryResponseFut<Vec<Peer>, fidl::encoding::DefaultFuchsiaResourceDialect>
13409    {
13410        ScanResultWatcherProxyInterface::r#watch(self)
13411    }
13412}
13413
13414impl ScanResultWatcherProxyInterface for ScanResultWatcherProxy {
13415    type WatchResponseFut =
13416        fidl::client::QueryResponseFut<Vec<Peer>, fidl::encoding::DefaultFuchsiaResourceDialect>;
13417    fn r#watch(&self) -> Self::WatchResponseFut {
13418        fn _decode(
13419            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
13420        ) -> Result<Vec<Peer>, fidl::Error> {
13421            let _response = fidl::client::decode_transaction_body::<
13422                ScanResultWatcherWatchResponse,
13423                fidl::encoding::DefaultFuchsiaResourceDialect,
13424                0x713a122e949f301a,
13425            >(_buf?)?;
13426            Ok(_response.updated)
13427        }
13428        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Peer>>(
13429            (),
13430            0x713a122e949f301a,
13431            fidl::encoding::DynamicFlags::empty(),
13432            _decode,
13433        )
13434    }
13435}
13436
13437pub struct ScanResultWatcherEventStream {
13438    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
13439}
13440
13441impl std::marker::Unpin for ScanResultWatcherEventStream {}
13442
13443impl futures::stream::FusedStream for ScanResultWatcherEventStream {
13444    fn is_terminated(&self) -> bool {
13445        self.event_receiver.is_terminated()
13446    }
13447}
13448
13449impl futures::Stream for ScanResultWatcherEventStream {
13450    type Item = Result<ScanResultWatcherEvent, fidl::Error>;
13451
13452    fn poll_next(
13453        mut self: std::pin::Pin<&mut Self>,
13454        cx: &mut std::task::Context<'_>,
13455    ) -> std::task::Poll<Option<Self::Item>> {
13456        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
13457            &mut self.event_receiver,
13458            cx
13459        )?) {
13460            Some(buf) => std::task::Poll::Ready(Some(ScanResultWatcherEvent::decode(buf))),
13461            None => std::task::Poll::Ready(None),
13462        }
13463    }
13464}
13465
13466#[derive(Debug)]
13467pub enum ScanResultWatcherEvent {}
13468
13469impl ScanResultWatcherEvent {
13470    /// Decodes a message buffer as a [`ScanResultWatcherEvent`].
13471    fn decode(
13472        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
13473    ) -> Result<ScanResultWatcherEvent, fidl::Error> {
13474        let (bytes, _handles) = buf.split_mut();
13475        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13476        debug_assert_eq!(tx_header.tx_id, 0);
13477        match tx_header.ordinal {
13478            _ => Err(fidl::Error::UnknownOrdinal {
13479                ordinal: tx_header.ordinal,
13480                protocol_name:
13481                    <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13482            }),
13483        }
13484    }
13485}
13486
13487/// A Stream of incoming requests for fuchsia.bluetooth.le/ScanResultWatcher.
13488pub struct ScanResultWatcherRequestStream {
13489    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13490    is_terminated: bool,
13491}
13492
13493impl std::marker::Unpin for ScanResultWatcherRequestStream {}
13494
13495impl futures::stream::FusedStream for ScanResultWatcherRequestStream {
13496    fn is_terminated(&self) -> bool {
13497        self.is_terminated
13498    }
13499}
13500
13501impl fidl::endpoints::RequestStream for ScanResultWatcherRequestStream {
13502    type Protocol = ScanResultWatcherMarker;
13503    type ControlHandle = ScanResultWatcherControlHandle;
13504
13505    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
13506        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
13507    }
13508
13509    fn control_handle(&self) -> Self::ControlHandle {
13510        ScanResultWatcherControlHandle { inner: self.inner.clone() }
13511    }
13512
13513    fn into_inner(
13514        self,
13515    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
13516    {
13517        (self.inner, self.is_terminated)
13518    }
13519
13520    fn from_inner(
13521        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13522        is_terminated: bool,
13523    ) -> Self {
13524        Self { inner, is_terminated }
13525    }
13526}
13527
13528impl futures::Stream for ScanResultWatcherRequestStream {
13529    type Item = Result<ScanResultWatcherRequest, fidl::Error>;
13530
13531    fn poll_next(
13532        mut self: std::pin::Pin<&mut Self>,
13533        cx: &mut std::task::Context<'_>,
13534    ) -> std::task::Poll<Option<Self::Item>> {
13535        let this = &mut *self;
13536        if this.inner.check_shutdown(cx) {
13537            this.is_terminated = true;
13538            return std::task::Poll::Ready(None);
13539        }
13540        if this.is_terminated {
13541            panic!("polled ScanResultWatcherRequestStream after completion");
13542        }
13543        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
13544            |bytes, handles| {
13545                match this.inner.channel().read_etc(cx, bytes, handles) {
13546                    std::task::Poll::Ready(Ok(())) => {}
13547                    std::task::Poll::Pending => return std::task::Poll::Pending,
13548                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
13549                        this.is_terminated = true;
13550                        return std::task::Poll::Ready(None);
13551                    }
13552                    std::task::Poll::Ready(Err(e)) => {
13553                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
13554                            e.into(),
13555                        ))));
13556                    }
13557                }
13558
13559                // A message has been received from the channel
13560                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13561
13562                std::task::Poll::Ready(Some(match header.ordinal {
13563                    0x713a122e949f301a => {
13564                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
13565                        let mut req = fidl::new_empty!(
13566                            fidl::encoding::EmptyPayload,
13567                            fidl::encoding::DefaultFuchsiaResourceDialect
13568                        );
13569                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13570                        let control_handle =
13571                            ScanResultWatcherControlHandle { inner: this.inner.clone() };
13572                        Ok(ScanResultWatcherRequest::Watch {
13573                            responder: ScanResultWatcherWatchResponder {
13574                                control_handle: std::mem::ManuallyDrop::new(control_handle),
13575                                tx_id: header.tx_id,
13576                            },
13577                        })
13578                    }
13579                    _ => Err(fidl::Error::UnknownOrdinal {
13580                        ordinal: header.ordinal,
13581                        protocol_name:
13582                            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13583                    }),
13584                }))
13585            },
13586        )
13587    }
13588}
13589
13590/// Represents an active scan procedure. This protocol remains valid for the
13591/// duration of a scan and can be used to obtain scan results. The client can
13592/// close the protocol to stop scanning. If a scan is stopped by the system, the
13593/// protocol will be closed with the epitaph `CANCELED` to communicate this to
13594/// the client.
13595#[derive(Debug)]
13596pub enum ScanResultWatcherRequest {
13597    /// Returns a list of all LE peers that satisfy the filters indicated in
13598    /// `ScanOptions`. The first response(s) will return matching discovered
13599    /// peers immediately. Subsequent calls receive a response only when peers
13600    /// have been scanned or updated since the last call. If a second call to
13601    /// `Watch` is erronously sent while one call is already pending, the scan
13602    /// will be canceled and the protocol will be closed.
13603    ///
13604    /// - response `updated` Peers that were added or updated since the last
13605    ///   call to Watch().
13606    Watch { responder: ScanResultWatcherWatchResponder },
13607}
13608
13609impl ScanResultWatcherRequest {
13610    #[allow(irrefutable_let_patterns)]
13611    pub fn into_watch(self) -> Option<(ScanResultWatcherWatchResponder)> {
13612        if let ScanResultWatcherRequest::Watch { responder } = self {
13613            Some((responder))
13614        } else {
13615            None
13616        }
13617    }
13618
13619    /// Name of the method defined in FIDL
13620    pub fn method_name(&self) -> &'static str {
13621        match *self {
13622            ScanResultWatcherRequest::Watch { .. } => "watch",
13623        }
13624    }
13625}
13626
13627#[derive(Debug, Clone)]
13628pub struct ScanResultWatcherControlHandle {
13629    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13630}
13631
13632impl ScanResultWatcherControlHandle {
13633    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
13634        self.inner.shutdown_with_epitaph(status.into())
13635    }
13636}
13637
13638impl fidl::endpoints::ControlHandle for ScanResultWatcherControlHandle {
13639    fn shutdown(&self) {
13640        self.inner.shutdown()
13641    }
13642
13643    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
13644        self.inner.shutdown_with_epitaph(status)
13645    }
13646
13647    fn is_closed(&self) -> bool {
13648        self.inner.channel().is_closed()
13649    }
13650    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13651        self.inner.channel().on_closed()
13652    }
13653
13654    #[cfg(target_os = "fuchsia")]
13655    fn signal_peer(
13656        &self,
13657        clear_mask: zx::Signals,
13658        set_mask: zx::Signals,
13659    ) -> Result<(), zx_status::Status> {
13660        use fidl::Peered;
13661        self.inner.channel().signal_peer(clear_mask, set_mask)
13662    }
13663}
13664
13665impl ScanResultWatcherControlHandle {}
13666
13667#[must_use = "FIDL methods require a response to be sent"]
13668#[derive(Debug)]
13669pub struct ScanResultWatcherWatchResponder {
13670    control_handle: std::mem::ManuallyDrop<ScanResultWatcherControlHandle>,
13671    tx_id: u32,
13672}
13673
13674/// Set the the channel to be shutdown (see [`ScanResultWatcherControlHandle::shutdown`])
13675/// if the responder is dropped without sending a response, so that the client
13676/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13677impl std::ops::Drop for ScanResultWatcherWatchResponder {
13678    fn drop(&mut self) {
13679        self.control_handle.shutdown();
13680        // Safety: drops once, never accessed again
13681        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13682    }
13683}
13684
13685impl fidl::endpoints::Responder for ScanResultWatcherWatchResponder {
13686    type ControlHandle = ScanResultWatcherControlHandle;
13687
13688    fn control_handle(&self) -> &ScanResultWatcherControlHandle {
13689        &self.control_handle
13690    }
13691
13692    fn drop_without_shutdown(mut self) {
13693        // Safety: drops once, never accessed again due to mem::forget
13694        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13695        // Prevent Drop from running (which would shut down the channel)
13696        std::mem::forget(self);
13697    }
13698}
13699
13700impl ScanResultWatcherWatchResponder {
13701    /// Sends a response to the FIDL transaction.
13702    ///
13703    /// Sets the channel to shutdown if an error occurs.
13704    pub fn send(self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
13705        let _result = self.send_raw(updated);
13706        if _result.is_err() {
13707            self.control_handle.shutdown();
13708        }
13709        self.drop_without_shutdown();
13710        _result
13711    }
13712
13713    /// Similar to "send" but does not shutdown the channel if an error occurs.
13714    pub fn send_no_shutdown_on_err(self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
13715        let _result = self.send_raw(updated);
13716        self.drop_without_shutdown();
13717        _result
13718    }
13719
13720    fn send_raw(&self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
13721        self.control_handle.inner.send::<ScanResultWatcherWatchResponse>(
13722            (updated,),
13723            self.tx_id,
13724            0x713a122e949f301a,
13725            fidl::encoding::DynamicFlags::empty(),
13726        )
13727    }
13728}
13729
13730mod internal {
13731    use super::*;
13732
13733    impl fidl::encoding::ResourceTypeMarker for AdvertisedPeripheralOnConnectedRequest {
13734        type Borrowed<'a> = &'a mut Self;
13735        fn take_or_borrow<'a>(
13736            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13737        ) -> Self::Borrowed<'a> {
13738            value
13739        }
13740    }
13741
13742    unsafe impl fidl::encoding::TypeMarker for AdvertisedPeripheralOnConnectedRequest {
13743        type Owned = Self;
13744
13745        #[inline(always)]
13746        fn inline_align(_context: fidl::encoding::Context) -> usize {
13747            8
13748        }
13749
13750        #[inline(always)]
13751        fn inline_size(_context: fidl::encoding::Context) -> usize {
13752            24
13753        }
13754    }
13755
13756    unsafe impl
13757        fidl::encoding::Encode<
13758            AdvertisedPeripheralOnConnectedRequest,
13759            fidl::encoding::DefaultFuchsiaResourceDialect,
13760        > for &mut AdvertisedPeripheralOnConnectedRequest
13761    {
13762        #[inline]
13763        unsafe fn encode(
13764            self,
13765            encoder: &mut fidl::encoding::Encoder<
13766                '_,
13767                fidl::encoding::DefaultFuchsiaResourceDialect,
13768            >,
13769            offset: usize,
13770            _depth: fidl::encoding::Depth,
13771        ) -> fidl::Result<()> {
13772            encoder.debug_check_bounds::<AdvertisedPeripheralOnConnectedRequest>(offset);
13773            // Delegate to tuple encoding.
13774            fidl::encoding::Encode::<AdvertisedPeripheralOnConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
13775                (
13776                    <Peer as fidl::encoding::ValueTypeMarker>::borrow(&self.peer),
13777                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.connection),
13778                ),
13779                encoder, offset, _depth
13780            )
13781        }
13782    }
13783    unsafe impl<
13784        T0: fidl::encoding::Encode<Peer, fidl::encoding::DefaultFuchsiaResourceDialect>,
13785        T1: fidl::encoding::Encode<
13786                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
13787                fidl::encoding::DefaultFuchsiaResourceDialect,
13788            >,
13789    >
13790        fidl::encoding::Encode<
13791            AdvertisedPeripheralOnConnectedRequest,
13792            fidl::encoding::DefaultFuchsiaResourceDialect,
13793        > for (T0, T1)
13794    {
13795        #[inline]
13796        unsafe fn encode(
13797            self,
13798            encoder: &mut fidl::encoding::Encoder<
13799                '_,
13800                fidl::encoding::DefaultFuchsiaResourceDialect,
13801            >,
13802            offset: usize,
13803            depth: fidl::encoding::Depth,
13804        ) -> fidl::Result<()> {
13805            encoder.debug_check_bounds::<AdvertisedPeripheralOnConnectedRequest>(offset);
13806            // Zero out padding regions. There's no need to apply masks
13807            // because the unmasked parts will be overwritten by fields.
13808            unsafe {
13809                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
13810                (ptr as *mut u64).write_unaligned(0);
13811            }
13812            // Write the fields.
13813            self.0.encode(encoder, offset + 0, depth)?;
13814            self.1.encode(encoder, offset + 16, depth)?;
13815            Ok(())
13816        }
13817    }
13818
13819    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13820        for AdvertisedPeripheralOnConnectedRequest
13821    {
13822        #[inline(always)]
13823        fn new_empty() -> Self {
13824            Self {
13825                peer: fidl::new_empty!(Peer, fidl::encoding::DefaultFuchsiaResourceDialect),
13826                connection: fidl::new_empty!(
13827                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
13828                    fidl::encoding::DefaultFuchsiaResourceDialect
13829                ),
13830            }
13831        }
13832
13833        #[inline]
13834        unsafe fn decode(
13835            &mut self,
13836            decoder: &mut fidl::encoding::Decoder<
13837                '_,
13838                fidl::encoding::DefaultFuchsiaResourceDialect,
13839            >,
13840            offset: usize,
13841            _depth: fidl::encoding::Depth,
13842        ) -> fidl::Result<()> {
13843            decoder.debug_check_bounds::<Self>(offset);
13844            // Verify that padding bytes are zero.
13845            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
13846            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13847            let mask = 0xffffffff00000000u64;
13848            let maskedval = padval & mask;
13849            if maskedval != 0 {
13850                return Err(fidl::Error::NonZeroPadding {
13851                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
13852                });
13853            }
13854            fidl::decode!(
13855                Peer,
13856                fidl::encoding::DefaultFuchsiaResourceDialect,
13857                &mut self.peer,
13858                decoder,
13859                offset + 0,
13860                _depth
13861            )?;
13862            fidl::decode!(
13863                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
13864                fidl::encoding::DefaultFuchsiaResourceDialect,
13865                &mut self.connection,
13866                decoder,
13867                offset + 16,
13868                _depth
13869            )?;
13870            Ok(())
13871        }
13872    }
13873
13874    impl fidl::encoding::ResourceTypeMarker for CentralConnectPeripheralRequest {
13875        type Borrowed<'a> = &'a mut Self;
13876        fn take_or_borrow<'a>(
13877            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13878        ) -> Self::Borrowed<'a> {
13879            value
13880        }
13881    }
13882
13883    unsafe impl fidl::encoding::TypeMarker for CentralConnectPeripheralRequest {
13884        type Owned = Self;
13885
13886        #[inline(always)]
13887        fn inline_align(_context: fidl::encoding::Context) -> usize {
13888            8
13889        }
13890
13891        #[inline(always)]
13892        fn inline_size(_context: fidl::encoding::Context) -> usize {
13893            40
13894        }
13895    }
13896
13897    unsafe impl
13898        fidl::encoding::Encode<
13899            CentralConnectPeripheralRequest,
13900            fidl::encoding::DefaultFuchsiaResourceDialect,
13901        > for &mut CentralConnectPeripheralRequest
13902    {
13903        #[inline]
13904        unsafe fn encode(
13905            self,
13906            encoder: &mut fidl::encoding::Encoder<
13907                '_,
13908                fidl::encoding::DefaultFuchsiaResourceDialect,
13909            >,
13910            offset: usize,
13911            _depth: fidl::encoding::Depth,
13912        ) -> fidl::Result<()> {
13913            encoder.debug_check_bounds::<CentralConnectPeripheralRequest>(offset);
13914            // Delegate to tuple encoding.
13915            fidl::encoding::Encode::<
13916                CentralConnectPeripheralRequest,
13917                fidl::encoding::DefaultFuchsiaResourceDialect,
13918            >::encode(
13919                (
13920                    <fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(
13921                        &self.identifier,
13922                    ),
13923                    <ConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
13924                    <fidl::encoding::Endpoint<
13925                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
13926                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13927                        &mut self.gatt_client
13928                    ),
13929                ),
13930                encoder,
13931                offset,
13932                _depth,
13933            )
13934        }
13935    }
13936    unsafe impl<
13937        T0: fidl::encoding::Encode<
13938                fidl::encoding::BoundedString<16>,
13939                fidl::encoding::DefaultFuchsiaResourceDialect,
13940            >,
13941        T1: fidl::encoding::Encode<ConnectionOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
13942        T2: fidl::encoding::Encode<
13943                fidl::encoding::Endpoint<
13944                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
13945                >,
13946                fidl::encoding::DefaultFuchsiaResourceDialect,
13947            >,
13948    >
13949        fidl::encoding::Encode<
13950            CentralConnectPeripheralRequest,
13951            fidl::encoding::DefaultFuchsiaResourceDialect,
13952        > for (T0, T1, T2)
13953    {
13954        #[inline]
13955        unsafe fn encode(
13956            self,
13957            encoder: &mut fidl::encoding::Encoder<
13958                '_,
13959                fidl::encoding::DefaultFuchsiaResourceDialect,
13960            >,
13961            offset: usize,
13962            depth: fidl::encoding::Depth,
13963        ) -> fidl::Result<()> {
13964            encoder.debug_check_bounds::<CentralConnectPeripheralRequest>(offset);
13965            // Zero out padding regions. There's no need to apply masks
13966            // because the unmasked parts will be overwritten by fields.
13967            unsafe {
13968                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
13969                (ptr as *mut u64).write_unaligned(0);
13970            }
13971            // Write the fields.
13972            self.0.encode(encoder, offset + 0, depth)?;
13973            self.1.encode(encoder, offset + 16, depth)?;
13974            self.2.encode(encoder, offset + 32, depth)?;
13975            Ok(())
13976        }
13977    }
13978
13979    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13980        for CentralConnectPeripheralRequest
13981    {
13982        #[inline(always)]
13983        fn new_empty() -> Self {
13984            Self {
13985                identifier: fidl::new_empty!(
13986                    fidl::encoding::BoundedString<16>,
13987                    fidl::encoding::DefaultFuchsiaResourceDialect
13988                ),
13989                options: fidl::new_empty!(
13990                    ConnectionOptions,
13991                    fidl::encoding::DefaultFuchsiaResourceDialect
13992                ),
13993                gatt_client: fidl::new_empty!(
13994                    fidl::encoding::Endpoint<
13995                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
13996                    >,
13997                    fidl::encoding::DefaultFuchsiaResourceDialect
13998                ),
13999            }
14000        }
14001
14002        #[inline]
14003        unsafe fn decode(
14004            &mut self,
14005            decoder: &mut fidl::encoding::Decoder<
14006                '_,
14007                fidl::encoding::DefaultFuchsiaResourceDialect,
14008            >,
14009            offset: usize,
14010            _depth: fidl::encoding::Depth,
14011        ) -> fidl::Result<()> {
14012            decoder.debug_check_bounds::<Self>(offset);
14013            // Verify that padding bytes are zero.
14014            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
14015            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14016            let mask = 0xffffffff00000000u64;
14017            let maskedval = padval & mask;
14018            if maskedval != 0 {
14019                return Err(fidl::Error::NonZeroPadding {
14020                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
14021                });
14022            }
14023            fidl::decode!(
14024                fidl::encoding::BoundedString<16>,
14025                fidl::encoding::DefaultFuchsiaResourceDialect,
14026                &mut self.identifier,
14027                decoder,
14028                offset + 0,
14029                _depth
14030            )?;
14031            fidl::decode!(
14032                ConnectionOptions,
14033                fidl::encoding::DefaultFuchsiaResourceDialect,
14034                &mut self.options,
14035                decoder,
14036                offset + 16,
14037                _depth
14038            )?;
14039            fidl::decode!(
14040                fidl::encoding::Endpoint<
14041                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
14042                >,
14043                fidl::encoding::DefaultFuchsiaResourceDialect,
14044                &mut self.gatt_client,
14045                decoder,
14046                offset + 32,
14047                _depth
14048            )?;
14049            Ok(())
14050        }
14051    }
14052
14053    impl fidl::encoding::ResourceTypeMarker for CentralConnectRequest {
14054        type Borrowed<'a> = &'a mut Self;
14055        fn take_or_borrow<'a>(
14056            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14057        ) -> Self::Borrowed<'a> {
14058            value
14059        }
14060    }
14061
14062    unsafe impl fidl::encoding::TypeMarker for CentralConnectRequest {
14063        type Owned = Self;
14064
14065        #[inline(always)]
14066        fn inline_align(_context: fidl::encoding::Context) -> usize {
14067            8
14068        }
14069
14070        #[inline(always)]
14071        fn inline_size(_context: fidl::encoding::Context) -> usize {
14072            32
14073        }
14074    }
14075
14076    unsafe impl
14077        fidl::encoding::Encode<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
14078        for &mut CentralConnectRequest
14079    {
14080        #[inline]
14081        unsafe fn encode(
14082            self,
14083            encoder: &mut fidl::encoding::Encoder<
14084                '_,
14085                fidl::encoding::DefaultFuchsiaResourceDialect,
14086            >,
14087            offset: usize,
14088            _depth: fidl::encoding::Depth,
14089        ) -> fidl::Result<()> {
14090            encoder.debug_check_bounds::<CentralConnectRequest>(offset);
14091            // Delegate to tuple encoding.
14092            fidl::encoding::Encode::<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14093                (
14094                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
14095                    <ConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
14096                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
14097                ),
14098                encoder, offset, _depth
14099            )
14100        }
14101    }
14102    unsafe impl<
14103        T0: fidl::encoding::Encode<
14104                fidl_fuchsia_bluetooth::PeerId,
14105                fidl::encoding::DefaultFuchsiaResourceDialect,
14106            >,
14107        T1: fidl::encoding::Encode<ConnectionOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
14108        T2: fidl::encoding::Encode<
14109                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
14110                fidl::encoding::DefaultFuchsiaResourceDialect,
14111            >,
14112    >
14113        fidl::encoding::Encode<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
14114        for (T0, T1, T2)
14115    {
14116        #[inline]
14117        unsafe fn encode(
14118            self,
14119            encoder: &mut fidl::encoding::Encoder<
14120                '_,
14121                fidl::encoding::DefaultFuchsiaResourceDialect,
14122            >,
14123            offset: usize,
14124            depth: fidl::encoding::Depth,
14125        ) -> fidl::Result<()> {
14126            encoder.debug_check_bounds::<CentralConnectRequest>(offset);
14127            // Zero out padding regions. There's no need to apply masks
14128            // because the unmasked parts will be overwritten by fields.
14129            unsafe {
14130                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
14131                (ptr as *mut u64).write_unaligned(0);
14132            }
14133            // Write the fields.
14134            self.0.encode(encoder, offset + 0, depth)?;
14135            self.1.encode(encoder, offset + 8, depth)?;
14136            self.2.encode(encoder, offset + 24, depth)?;
14137            Ok(())
14138        }
14139    }
14140
14141    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14142        for CentralConnectRequest
14143    {
14144        #[inline(always)]
14145        fn new_empty() -> Self {
14146            Self {
14147                id: fidl::new_empty!(
14148                    fidl_fuchsia_bluetooth::PeerId,
14149                    fidl::encoding::DefaultFuchsiaResourceDialect
14150                ),
14151                options: fidl::new_empty!(
14152                    ConnectionOptions,
14153                    fidl::encoding::DefaultFuchsiaResourceDialect
14154                ),
14155                handle: fidl::new_empty!(
14156                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
14157                    fidl::encoding::DefaultFuchsiaResourceDialect
14158                ),
14159            }
14160        }
14161
14162        #[inline]
14163        unsafe fn decode(
14164            &mut self,
14165            decoder: &mut fidl::encoding::Decoder<
14166                '_,
14167                fidl::encoding::DefaultFuchsiaResourceDialect,
14168            >,
14169            offset: usize,
14170            _depth: fidl::encoding::Depth,
14171        ) -> fidl::Result<()> {
14172            decoder.debug_check_bounds::<Self>(offset);
14173            // Verify that padding bytes are zero.
14174            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
14175            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14176            let mask = 0xffffffff00000000u64;
14177            let maskedval = padval & mask;
14178            if maskedval != 0 {
14179                return Err(fidl::Error::NonZeroPadding {
14180                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
14181                });
14182            }
14183            fidl::decode!(
14184                fidl_fuchsia_bluetooth::PeerId,
14185                fidl::encoding::DefaultFuchsiaResourceDialect,
14186                &mut self.id,
14187                decoder,
14188                offset + 0,
14189                _depth
14190            )?;
14191            fidl::decode!(
14192                ConnectionOptions,
14193                fidl::encoding::DefaultFuchsiaResourceDialect,
14194                &mut self.options,
14195                decoder,
14196                offset + 8,
14197                _depth
14198            )?;
14199            fidl::decode!(
14200                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
14201                fidl::encoding::DefaultFuchsiaResourceDialect,
14202                &mut self.handle,
14203                decoder,
14204                offset + 24,
14205                _depth
14206            )?;
14207            Ok(())
14208        }
14209    }
14210
14211    impl fidl::encoding::ResourceTypeMarker for CentralScanRequest {
14212        type Borrowed<'a> = &'a mut Self;
14213        fn take_or_borrow<'a>(
14214            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14215        ) -> Self::Borrowed<'a> {
14216            value
14217        }
14218    }
14219
14220    unsafe impl fidl::encoding::TypeMarker for CentralScanRequest {
14221        type Owned = Self;
14222
14223        #[inline(always)]
14224        fn inline_align(_context: fidl::encoding::Context) -> usize {
14225            8
14226        }
14227
14228        #[inline(always)]
14229        fn inline_size(_context: fidl::encoding::Context) -> usize {
14230            24
14231        }
14232    }
14233
14234    unsafe impl
14235        fidl::encoding::Encode<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
14236        for &mut CentralScanRequest
14237    {
14238        #[inline]
14239        unsafe fn encode(
14240            self,
14241            encoder: &mut fidl::encoding::Encoder<
14242                '_,
14243                fidl::encoding::DefaultFuchsiaResourceDialect,
14244            >,
14245            offset: usize,
14246            _depth: fidl::encoding::Depth,
14247        ) -> fidl::Result<()> {
14248            encoder.debug_check_bounds::<CentralScanRequest>(offset);
14249            // Delegate to tuple encoding.
14250            fidl::encoding::Encode::<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14251                (
14252                    <ScanOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
14253                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.result_watcher),
14254                ),
14255                encoder, offset, _depth
14256            )
14257        }
14258    }
14259    unsafe impl<
14260        T0: fidl::encoding::Encode<ScanOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
14261        T1: fidl::encoding::Encode<
14262                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
14263                fidl::encoding::DefaultFuchsiaResourceDialect,
14264            >,
14265    > fidl::encoding::Encode<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
14266        for (T0, T1)
14267    {
14268        #[inline]
14269        unsafe fn encode(
14270            self,
14271            encoder: &mut fidl::encoding::Encoder<
14272                '_,
14273                fidl::encoding::DefaultFuchsiaResourceDialect,
14274            >,
14275            offset: usize,
14276            depth: fidl::encoding::Depth,
14277        ) -> fidl::Result<()> {
14278            encoder.debug_check_bounds::<CentralScanRequest>(offset);
14279            // Zero out padding regions. There's no need to apply masks
14280            // because the unmasked parts will be overwritten by fields.
14281            unsafe {
14282                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
14283                (ptr as *mut u64).write_unaligned(0);
14284            }
14285            // Write the fields.
14286            self.0.encode(encoder, offset + 0, depth)?;
14287            self.1.encode(encoder, offset + 16, depth)?;
14288            Ok(())
14289        }
14290    }
14291
14292    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14293        for CentralScanRequest
14294    {
14295        #[inline(always)]
14296        fn new_empty() -> Self {
14297            Self {
14298                options: fidl::new_empty!(
14299                    ScanOptions,
14300                    fidl::encoding::DefaultFuchsiaResourceDialect
14301                ),
14302                result_watcher: fidl::new_empty!(
14303                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
14304                    fidl::encoding::DefaultFuchsiaResourceDialect
14305                ),
14306            }
14307        }
14308
14309        #[inline]
14310        unsafe fn decode(
14311            &mut self,
14312            decoder: &mut fidl::encoding::Decoder<
14313                '_,
14314                fidl::encoding::DefaultFuchsiaResourceDialect,
14315            >,
14316            offset: usize,
14317            _depth: fidl::encoding::Depth,
14318        ) -> fidl::Result<()> {
14319            decoder.debug_check_bounds::<Self>(offset);
14320            // Verify that padding bytes are zero.
14321            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
14322            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14323            let mask = 0xffffffff00000000u64;
14324            let maskedval = padval & mask;
14325            if maskedval != 0 {
14326                return Err(fidl::Error::NonZeroPadding {
14327                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
14328                });
14329            }
14330            fidl::decode!(
14331                ScanOptions,
14332                fidl::encoding::DefaultFuchsiaResourceDialect,
14333                &mut self.options,
14334                decoder,
14335                offset + 0,
14336                _depth
14337            )?;
14338            fidl::decode!(
14339                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
14340                fidl::encoding::DefaultFuchsiaResourceDialect,
14341                &mut self.result_watcher,
14342                decoder,
14343                offset + 16,
14344                _depth
14345            )?;
14346            Ok(())
14347        }
14348    }
14349
14350    impl fidl::encoding::ResourceTypeMarker for ChannelListenerAcceptRequest {
14351        type Borrowed<'a> = &'a mut Self;
14352        fn take_or_borrow<'a>(
14353            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14354        ) -> Self::Borrowed<'a> {
14355            value
14356        }
14357    }
14358
14359    unsafe impl fidl::encoding::TypeMarker for ChannelListenerAcceptRequest {
14360        type Owned = Self;
14361
14362        #[inline(always)]
14363        fn inline_align(_context: fidl::encoding::Context) -> usize {
14364            4
14365        }
14366
14367        #[inline(always)]
14368        fn inline_size(_context: fidl::encoding::Context) -> usize {
14369            4
14370        }
14371    }
14372
14373    unsafe impl
14374        fidl::encoding::Encode<
14375            ChannelListenerAcceptRequest,
14376            fidl::encoding::DefaultFuchsiaResourceDialect,
14377        > for &mut ChannelListenerAcceptRequest
14378    {
14379        #[inline]
14380        unsafe fn encode(
14381            self,
14382            encoder: &mut fidl::encoding::Encoder<
14383                '_,
14384                fidl::encoding::DefaultFuchsiaResourceDialect,
14385            >,
14386            offset: usize,
14387            _depth: fidl::encoding::Depth,
14388        ) -> fidl::Result<()> {
14389            encoder.debug_check_bounds::<ChannelListenerAcceptRequest>(offset);
14390            // Delegate to tuple encoding.
14391            fidl::encoding::Encode::<
14392                ChannelListenerAcceptRequest,
14393                fidl::encoding::DefaultFuchsiaResourceDialect,
14394            >::encode(
14395                (<fidl::encoding::Endpoint<
14396                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14397                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14398                    &mut self.channel
14399                ),),
14400                encoder,
14401                offset,
14402                _depth,
14403            )
14404        }
14405    }
14406    unsafe impl<
14407        T0: fidl::encoding::Encode<
14408                fidl::encoding::Endpoint<
14409                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14410                >,
14411                fidl::encoding::DefaultFuchsiaResourceDialect,
14412            >,
14413    >
14414        fidl::encoding::Encode<
14415            ChannelListenerAcceptRequest,
14416            fidl::encoding::DefaultFuchsiaResourceDialect,
14417        > for (T0,)
14418    {
14419        #[inline]
14420        unsafe fn encode(
14421            self,
14422            encoder: &mut fidl::encoding::Encoder<
14423                '_,
14424                fidl::encoding::DefaultFuchsiaResourceDialect,
14425            >,
14426            offset: usize,
14427            depth: fidl::encoding::Depth,
14428        ) -> fidl::Result<()> {
14429            encoder.debug_check_bounds::<ChannelListenerAcceptRequest>(offset);
14430            // Zero out padding regions. There's no need to apply masks
14431            // because the unmasked parts will be overwritten by fields.
14432            // Write the fields.
14433            self.0.encode(encoder, offset + 0, depth)?;
14434            Ok(())
14435        }
14436    }
14437
14438    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14439        for ChannelListenerAcceptRequest
14440    {
14441        #[inline(always)]
14442        fn new_empty() -> Self {
14443            Self {
14444                channel: fidl::new_empty!(
14445                    fidl::encoding::Endpoint<
14446                        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14447                    >,
14448                    fidl::encoding::DefaultFuchsiaResourceDialect
14449                ),
14450            }
14451        }
14452
14453        #[inline]
14454        unsafe fn decode(
14455            &mut self,
14456            decoder: &mut fidl::encoding::Decoder<
14457                '_,
14458                fidl::encoding::DefaultFuchsiaResourceDialect,
14459            >,
14460            offset: usize,
14461            _depth: fidl::encoding::Depth,
14462        ) -> fidl::Result<()> {
14463            decoder.debug_check_bounds::<Self>(offset);
14464            // Verify that padding bytes are zero.
14465            fidl::decode!(
14466                fidl::encoding::Endpoint<
14467                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14468                >,
14469                fidl::encoding::DefaultFuchsiaResourceDialect,
14470                &mut self.channel,
14471                decoder,
14472                offset + 0,
14473                _depth
14474            )?;
14475            Ok(())
14476        }
14477    }
14478
14479    impl fidl::encoding::ResourceTypeMarker for ConnectionRequestGattClientRequest {
14480        type Borrowed<'a> = &'a mut Self;
14481        fn take_or_borrow<'a>(
14482            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14483        ) -> Self::Borrowed<'a> {
14484            value
14485        }
14486    }
14487
14488    unsafe impl fidl::encoding::TypeMarker for ConnectionRequestGattClientRequest {
14489        type Owned = Self;
14490
14491        #[inline(always)]
14492        fn inline_align(_context: fidl::encoding::Context) -> usize {
14493            4
14494        }
14495
14496        #[inline(always)]
14497        fn inline_size(_context: fidl::encoding::Context) -> usize {
14498            4
14499        }
14500    }
14501
14502    unsafe impl
14503        fidl::encoding::Encode<
14504            ConnectionRequestGattClientRequest,
14505            fidl::encoding::DefaultFuchsiaResourceDialect,
14506        > for &mut ConnectionRequestGattClientRequest
14507    {
14508        #[inline]
14509        unsafe fn encode(
14510            self,
14511            encoder: &mut fidl::encoding::Encoder<
14512                '_,
14513                fidl::encoding::DefaultFuchsiaResourceDialect,
14514            >,
14515            offset: usize,
14516            _depth: fidl::encoding::Depth,
14517        ) -> fidl::Result<()> {
14518            encoder.debug_check_bounds::<ConnectionRequestGattClientRequest>(offset);
14519            // Delegate to tuple encoding.
14520            fidl::encoding::Encode::<
14521                ConnectionRequestGattClientRequest,
14522                fidl::encoding::DefaultFuchsiaResourceDialect,
14523            >::encode(
14524                (<fidl::encoding::Endpoint<
14525                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
14526                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14527                    &mut self.client
14528                ),),
14529                encoder,
14530                offset,
14531                _depth,
14532            )
14533        }
14534    }
14535    unsafe impl<
14536        T0: fidl::encoding::Encode<
14537                fidl::encoding::Endpoint<
14538                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
14539                >,
14540                fidl::encoding::DefaultFuchsiaResourceDialect,
14541            >,
14542    >
14543        fidl::encoding::Encode<
14544            ConnectionRequestGattClientRequest,
14545            fidl::encoding::DefaultFuchsiaResourceDialect,
14546        > for (T0,)
14547    {
14548        #[inline]
14549        unsafe fn encode(
14550            self,
14551            encoder: &mut fidl::encoding::Encoder<
14552                '_,
14553                fidl::encoding::DefaultFuchsiaResourceDialect,
14554            >,
14555            offset: usize,
14556            depth: fidl::encoding::Depth,
14557        ) -> fidl::Result<()> {
14558            encoder.debug_check_bounds::<ConnectionRequestGattClientRequest>(offset);
14559            // Zero out padding regions. There's no need to apply masks
14560            // because the unmasked parts will be overwritten by fields.
14561            // Write the fields.
14562            self.0.encode(encoder, offset + 0, depth)?;
14563            Ok(())
14564        }
14565    }
14566
14567    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14568        for ConnectionRequestGattClientRequest
14569    {
14570        #[inline(always)]
14571        fn new_empty() -> Self {
14572            Self {
14573                client: fidl::new_empty!(
14574                    fidl::encoding::Endpoint<
14575                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
14576                    >,
14577                    fidl::encoding::DefaultFuchsiaResourceDialect
14578                ),
14579            }
14580        }
14581
14582        #[inline]
14583        unsafe fn decode(
14584            &mut self,
14585            decoder: &mut fidl::encoding::Decoder<
14586                '_,
14587                fidl::encoding::DefaultFuchsiaResourceDialect,
14588            >,
14589            offset: usize,
14590            _depth: fidl::encoding::Depth,
14591        ) -> fidl::Result<()> {
14592            decoder.debug_check_bounds::<Self>(offset);
14593            // Verify that padding bytes are zero.
14594            fidl::decode!(
14595                fidl::encoding::Endpoint<
14596                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
14597                >,
14598                fidl::encoding::DefaultFuchsiaResourceDialect,
14599                &mut self.client,
14600                decoder,
14601                offset + 0,
14602                _depth
14603            )?;
14604            Ok(())
14605        }
14606    }
14607
14608    impl fidl::encoding::ResourceTypeMarker for PeripheralAdvertiseRequest {
14609        type Borrowed<'a> = &'a mut Self;
14610        fn take_or_borrow<'a>(
14611            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14612        ) -> Self::Borrowed<'a> {
14613            value
14614        }
14615    }
14616
14617    unsafe impl fidl::encoding::TypeMarker for PeripheralAdvertiseRequest {
14618        type Owned = Self;
14619
14620        #[inline(always)]
14621        fn inline_align(_context: fidl::encoding::Context) -> usize {
14622            8
14623        }
14624
14625        #[inline(always)]
14626        fn inline_size(_context: fidl::encoding::Context) -> usize {
14627            24
14628        }
14629    }
14630
14631    unsafe impl
14632        fidl::encoding::Encode<
14633            PeripheralAdvertiseRequest,
14634            fidl::encoding::DefaultFuchsiaResourceDialect,
14635        > for &mut PeripheralAdvertiseRequest
14636    {
14637        #[inline]
14638        unsafe fn encode(
14639            self,
14640            encoder: &mut fidl::encoding::Encoder<
14641                '_,
14642                fidl::encoding::DefaultFuchsiaResourceDialect,
14643            >,
14644            offset: usize,
14645            _depth: fidl::encoding::Depth,
14646        ) -> fidl::Result<()> {
14647            encoder.debug_check_bounds::<PeripheralAdvertiseRequest>(offset);
14648            // Delegate to tuple encoding.
14649            fidl::encoding::Encode::<
14650                PeripheralAdvertiseRequest,
14651                fidl::encoding::DefaultFuchsiaResourceDialect,
14652            >::encode(
14653                (
14654                    <AdvertisingParameters as fidl::encoding::ValueTypeMarker>::borrow(
14655                        &self.parameters,
14656                    ),
14657                    <fidl::encoding::Endpoint<
14658                        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
14659                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14660                        &mut self.advertised_peripheral,
14661                    ),
14662                ),
14663                encoder,
14664                offset,
14665                _depth,
14666            )
14667        }
14668    }
14669    unsafe impl<
14670        T0: fidl::encoding::Encode<
14671                AdvertisingParameters,
14672                fidl::encoding::DefaultFuchsiaResourceDialect,
14673            >,
14674        T1: fidl::encoding::Encode<
14675                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>>,
14676                fidl::encoding::DefaultFuchsiaResourceDialect,
14677            >,
14678    >
14679        fidl::encoding::Encode<
14680            PeripheralAdvertiseRequest,
14681            fidl::encoding::DefaultFuchsiaResourceDialect,
14682        > for (T0, T1)
14683    {
14684        #[inline]
14685        unsafe fn encode(
14686            self,
14687            encoder: &mut fidl::encoding::Encoder<
14688                '_,
14689                fidl::encoding::DefaultFuchsiaResourceDialect,
14690            >,
14691            offset: usize,
14692            depth: fidl::encoding::Depth,
14693        ) -> fidl::Result<()> {
14694            encoder.debug_check_bounds::<PeripheralAdvertiseRequest>(offset);
14695            // Zero out padding regions. There's no need to apply masks
14696            // because the unmasked parts will be overwritten by fields.
14697            unsafe {
14698                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
14699                (ptr as *mut u64).write_unaligned(0);
14700            }
14701            // Write the fields.
14702            self.0.encode(encoder, offset + 0, depth)?;
14703            self.1.encode(encoder, offset + 16, depth)?;
14704            Ok(())
14705        }
14706    }
14707
14708    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14709        for PeripheralAdvertiseRequest
14710    {
14711        #[inline(always)]
14712        fn new_empty() -> Self {
14713            Self {
14714                parameters: fidl::new_empty!(
14715                    AdvertisingParameters,
14716                    fidl::encoding::DefaultFuchsiaResourceDialect
14717                ),
14718                advertised_peripheral: fidl::new_empty!(
14719                    fidl::encoding::Endpoint<
14720                        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
14721                    >,
14722                    fidl::encoding::DefaultFuchsiaResourceDialect
14723                ),
14724            }
14725        }
14726
14727        #[inline]
14728        unsafe fn decode(
14729            &mut self,
14730            decoder: &mut fidl::encoding::Decoder<
14731                '_,
14732                fidl::encoding::DefaultFuchsiaResourceDialect,
14733            >,
14734            offset: usize,
14735            _depth: fidl::encoding::Depth,
14736        ) -> fidl::Result<()> {
14737            decoder.debug_check_bounds::<Self>(offset);
14738            // Verify that padding bytes are zero.
14739            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
14740            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14741            let mask = 0xffffffff00000000u64;
14742            let maskedval = padval & mask;
14743            if maskedval != 0 {
14744                return Err(fidl::Error::NonZeroPadding {
14745                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
14746                });
14747            }
14748            fidl::decode!(
14749                AdvertisingParameters,
14750                fidl::encoding::DefaultFuchsiaResourceDialect,
14751                &mut self.parameters,
14752                decoder,
14753                offset + 0,
14754                _depth
14755            )?;
14756            fidl::decode!(
14757                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>>,
14758                fidl::encoding::DefaultFuchsiaResourceDialect,
14759                &mut self.advertised_peripheral,
14760                decoder,
14761                offset + 16,
14762                _depth
14763            )?;
14764            Ok(())
14765        }
14766    }
14767
14768    impl fidl::encoding::ResourceTypeMarker for PeripheralOnPeerConnectedRequest {
14769        type Borrowed<'a> = &'a mut Self;
14770        fn take_or_borrow<'a>(
14771            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14772        ) -> Self::Borrowed<'a> {
14773            value
14774        }
14775    }
14776
14777    unsafe impl fidl::encoding::TypeMarker for PeripheralOnPeerConnectedRequest {
14778        type Owned = Self;
14779
14780        #[inline(always)]
14781        fn inline_align(_context: fidl::encoding::Context) -> usize {
14782            8
14783        }
14784
14785        #[inline(always)]
14786        fn inline_size(_context: fidl::encoding::Context) -> usize {
14787            24
14788        }
14789    }
14790
14791    unsafe impl
14792        fidl::encoding::Encode<
14793            PeripheralOnPeerConnectedRequest,
14794            fidl::encoding::DefaultFuchsiaResourceDialect,
14795        > for &mut PeripheralOnPeerConnectedRequest
14796    {
14797        #[inline]
14798        unsafe fn encode(
14799            self,
14800            encoder: &mut fidl::encoding::Encoder<
14801                '_,
14802                fidl::encoding::DefaultFuchsiaResourceDialect,
14803            >,
14804            offset: usize,
14805            _depth: fidl::encoding::Depth,
14806        ) -> fidl::Result<()> {
14807            encoder.debug_check_bounds::<PeripheralOnPeerConnectedRequest>(offset);
14808            // Delegate to tuple encoding.
14809            fidl::encoding::Encode::<PeripheralOnPeerConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14810                (
14811                    <Peer as fidl::encoding::ValueTypeMarker>::borrow(&self.peer),
14812                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.connection),
14813                ),
14814                encoder, offset, _depth
14815            )
14816        }
14817    }
14818    unsafe impl<
14819        T0: fidl::encoding::Encode<Peer, fidl::encoding::DefaultFuchsiaResourceDialect>,
14820        T1: fidl::encoding::Encode<
14821                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
14822                fidl::encoding::DefaultFuchsiaResourceDialect,
14823            >,
14824    >
14825        fidl::encoding::Encode<
14826            PeripheralOnPeerConnectedRequest,
14827            fidl::encoding::DefaultFuchsiaResourceDialect,
14828        > for (T0, T1)
14829    {
14830        #[inline]
14831        unsafe fn encode(
14832            self,
14833            encoder: &mut fidl::encoding::Encoder<
14834                '_,
14835                fidl::encoding::DefaultFuchsiaResourceDialect,
14836            >,
14837            offset: usize,
14838            depth: fidl::encoding::Depth,
14839        ) -> fidl::Result<()> {
14840            encoder.debug_check_bounds::<PeripheralOnPeerConnectedRequest>(offset);
14841            // Zero out padding regions. There's no need to apply masks
14842            // because the unmasked parts will be overwritten by fields.
14843            unsafe {
14844                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
14845                (ptr as *mut u64).write_unaligned(0);
14846            }
14847            // Write the fields.
14848            self.0.encode(encoder, offset + 0, depth)?;
14849            self.1.encode(encoder, offset + 16, depth)?;
14850            Ok(())
14851        }
14852    }
14853
14854    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14855        for PeripheralOnPeerConnectedRequest
14856    {
14857        #[inline(always)]
14858        fn new_empty() -> Self {
14859            Self {
14860                peer: fidl::new_empty!(Peer, fidl::encoding::DefaultFuchsiaResourceDialect),
14861                connection: fidl::new_empty!(
14862                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
14863                    fidl::encoding::DefaultFuchsiaResourceDialect
14864                ),
14865            }
14866        }
14867
14868        #[inline]
14869        unsafe fn decode(
14870            &mut self,
14871            decoder: &mut fidl::encoding::Decoder<
14872                '_,
14873                fidl::encoding::DefaultFuchsiaResourceDialect,
14874            >,
14875            offset: usize,
14876            _depth: fidl::encoding::Depth,
14877        ) -> fidl::Result<()> {
14878            decoder.debug_check_bounds::<Self>(offset);
14879            // Verify that padding bytes are zero.
14880            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
14881            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14882            let mask = 0xffffffff00000000u64;
14883            let maskedval = padval & mask;
14884            if maskedval != 0 {
14885                return Err(fidl::Error::NonZeroPadding {
14886                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
14887                });
14888            }
14889            fidl::decode!(
14890                Peer,
14891                fidl::encoding::DefaultFuchsiaResourceDialect,
14892                &mut self.peer,
14893                decoder,
14894                offset + 0,
14895                _depth
14896            )?;
14897            fidl::decode!(
14898                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
14899                fidl::encoding::DefaultFuchsiaResourceDialect,
14900                &mut self.connection,
14901                decoder,
14902                offset + 16,
14903                _depth
14904            )?;
14905            Ok(())
14906        }
14907    }
14908
14909    impl fidl::encoding::ResourceTypeMarker for PeripheralStartAdvertisingRequest {
14910        type Borrowed<'a> = &'a mut Self;
14911        fn take_or_borrow<'a>(
14912            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14913        ) -> Self::Borrowed<'a> {
14914            value
14915        }
14916    }
14917
14918    unsafe impl fidl::encoding::TypeMarker for PeripheralStartAdvertisingRequest {
14919        type Owned = Self;
14920
14921        #[inline(always)]
14922        fn inline_align(_context: fidl::encoding::Context) -> usize {
14923            8
14924        }
14925
14926        #[inline(always)]
14927        fn inline_size(_context: fidl::encoding::Context) -> usize {
14928            24
14929        }
14930    }
14931
14932    unsafe impl
14933        fidl::encoding::Encode<
14934            PeripheralStartAdvertisingRequest,
14935            fidl::encoding::DefaultFuchsiaResourceDialect,
14936        > for &mut PeripheralStartAdvertisingRequest
14937    {
14938        #[inline]
14939        unsafe fn encode(
14940            self,
14941            encoder: &mut fidl::encoding::Encoder<
14942                '_,
14943                fidl::encoding::DefaultFuchsiaResourceDialect,
14944            >,
14945            offset: usize,
14946            _depth: fidl::encoding::Depth,
14947        ) -> fidl::Result<()> {
14948            encoder.debug_check_bounds::<PeripheralStartAdvertisingRequest>(offset);
14949            // Delegate to tuple encoding.
14950            fidl::encoding::Encode::<PeripheralStartAdvertisingRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14951                (
14952                    <AdvertisingParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.parameters),
14953                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
14954                ),
14955                encoder, offset, _depth
14956            )
14957        }
14958    }
14959    unsafe impl<
14960        T0: fidl::encoding::Encode<
14961                AdvertisingParameters,
14962                fidl::encoding::DefaultFuchsiaResourceDialect,
14963            >,
14964        T1: fidl::encoding::Encode<
14965                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
14966                fidl::encoding::DefaultFuchsiaResourceDialect,
14967            >,
14968    >
14969        fidl::encoding::Encode<
14970            PeripheralStartAdvertisingRequest,
14971            fidl::encoding::DefaultFuchsiaResourceDialect,
14972        > for (T0, T1)
14973    {
14974        #[inline]
14975        unsafe fn encode(
14976            self,
14977            encoder: &mut fidl::encoding::Encoder<
14978                '_,
14979                fidl::encoding::DefaultFuchsiaResourceDialect,
14980            >,
14981            offset: usize,
14982            depth: fidl::encoding::Depth,
14983        ) -> fidl::Result<()> {
14984            encoder.debug_check_bounds::<PeripheralStartAdvertisingRequest>(offset);
14985            // Zero out padding regions. There's no need to apply masks
14986            // because the unmasked parts will be overwritten by fields.
14987            unsafe {
14988                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
14989                (ptr as *mut u64).write_unaligned(0);
14990            }
14991            // Write the fields.
14992            self.0.encode(encoder, offset + 0, depth)?;
14993            self.1.encode(encoder, offset + 16, depth)?;
14994            Ok(())
14995        }
14996    }
14997
14998    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14999        for PeripheralStartAdvertisingRequest
15000    {
15001        #[inline(always)]
15002        fn new_empty() -> Self {
15003            Self {
15004                parameters: fidl::new_empty!(
15005                    AdvertisingParameters,
15006                    fidl::encoding::DefaultFuchsiaResourceDialect
15007                ),
15008                handle: fidl::new_empty!(
15009                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
15010                    fidl::encoding::DefaultFuchsiaResourceDialect
15011                ),
15012            }
15013        }
15014
15015        #[inline]
15016        unsafe fn decode(
15017            &mut self,
15018            decoder: &mut fidl::encoding::Decoder<
15019                '_,
15020                fidl::encoding::DefaultFuchsiaResourceDialect,
15021            >,
15022            offset: usize,
15023            _depth: fidl::encoding::Depth,
15024        ) -> fidl::Result<()> {
15025            decoder.debug_check_bounds::<Self>(offset);
15026            // Verify that padding bytes are zero.
15027            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
15028            let padval = unsafe { (ptr as *const u64).read_unaligned() };
15029            let mask = 0xffffffff00000000u64;
15030            let maskedval = padval & mask;
15031            if maskedval != 0 {
15032                return Err(fidl::Error::NonZeroPadding {
15033                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
15034                });
15035            }
15036            fidl::decode!(
15037                AdvertisingParameters,
15038                fidl::encoding::DefaultFuchsiaResourceDialect,
15039                &mut self.parameters,
15040                decoder,
15041                offset + 0,
15042                _depth
15043            )?;
15044            fidl::decode!(
15045                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
15046                fidl::encoding::DefaultFuchsiaResourceDialect,
15047                &mut self.handle,
15048                decoder,
15049                offset + 16,
15050                _depth
15051            )?;
15052            Ok(())
15053        }
15054    }
15055
15056    impl CentralCreateConnectedIsochronousGroupRequest {
15057        #[inline(always)]
15058        fn max_ordinal_present(&self) -> u64 {
15059            if let Some(_) = self.cig {
15060                return 3;
15061            }
15062            if let Some(_) = self.cis_requested_parameters {
15063                return 2;
15064            }
15065            if let Some(_) = self.cig_parameters {
15066                return 1;
15067            }
15068            0
15069        }
15070    }
15071
15072    impl fidl::encoding::ResourceTypeMarker for CentralCreateConnectedIsochronousGroupRequest {
15073        type Borrowed<'a> = &'a mut Self;
15074        fn take_or_borrow<'a>(
15075            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15076        ) -> Self::Borrowed<'a> {
15077            value
15078        }
15079    }
15080
15081    unsafe impl fidl::encoding::TypeMarker for CentralCreateConnectedIsochronousGroupRequest {
15082        type Owned = Self;
15083
15084        #[inline(always)]
15085        fn inline_align(_context: fidl::encoding::Context) -> usize {
15086            8
15087        }
15088
15089        #[inline(always)]
15090        fn inline_size(_context: fidl::encoding::Context) -> usize {
15091            16
15092        }
15093    }
15094
15095    unsafe impl
15096        fidl::encoding::Encode<
15097            CentralCreateConnectedIsochronousGroupRequest,
15098            fidl::encoding::DefaultFuchsiaResourceDialect,
15099        > for &mut CentralCreateConnectedIsochronousGroupRequest
15100    {
15101        unsafe fn encode(
15102            self,
15103            encoder: &mut fidl::encoding::Encoder<
15104                '_,
15105                fidl::encoding::DefaultFuchsiaResourceDialect,
15106            >,
15107            offset: usize,
15108            mut depth: fidl::encoding::Depth,
15109        ) -> fidl::Result<()> {
15110            encoder.debug_check_bounds::<CentralCreateConnectedIsochronousGroupRequest>(offset);
15111            // Vector header
15112            let max_ordinal: u64 = self.max_ordinal_present();
15113            encoder.write_num(max_ordinal, offset);
15114            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15115            // Calling encoder.out_of_line_offset(0) is not allowed.
15116            if max_ordinal == 0 {
15117                return Ok(());
15118            }
15119            depth.increment()?;
15120            let envelope_size = 8;
15121            let bytes_len = max_ordinal as usize * envelope_size;
15122            #[allow(unused_variables)]
15123            let offset = encoder.out_of_line_offset(bytes_len);
15124            let mut _prev_end_offset: usize = 0;
15125            if 1 > max_ordinal {
15126                return Ok(());
15127            }
15128
15129            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15130            // are envelope_size bytes.
15131            let cur_offset: usize = (1 - 1) * envelope_size;
15132
15133            // Zero reserved fields.
15134            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15135
15136            // Safety:
15137            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15138            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15139            //   envelope_size bytes, there is always sufficient room.
15140            fidl::encoding::encode_in_envelope_optional::<
15141                CigParameters,
15142                fidl::encoding::DefaultFuchsiaResourceDialect,
15143            >(
15144                self.cig_parameters
15145                    .as_ref()
15146                    .map(<CigParameters as fidl::encoding::ValueTypeMarker>::borrow),
15147                encoder,
15148                offset + cur_offset,
15149                depth,
15150            )?;
15151
15152            _prev_end_offset = cur_offset + envelope_size;
15153            if 2 > max_ordinal {
15154                return Ok(());
15155            }
15156
15157            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15158            // are envelope_size bytes.
15159            let cur_offset: usize = (2 - 1) * envelope_size;
15160
15161            // Zero reserved fields.
15162            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15163
15164            // Safety:
15165            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15166            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15167            //   envelope_size bytes, there is always sufficient room.
15168            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect>(
15169            self.cis_requested_parameters.as_mut().map(<fidl::encoding::Vector<CisRequestedParameters, 31> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
15170            encoder, offset + cur_offset, depth
15171        )?;
15172
15173            _prev_end_offset = cur_offset + envelope_size;
15174            if 3 > max_ordinal {
15175                return Ok(());
15176            }
15177
15178            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15179            // are envelope_size bytes.
15180            let cur_offset: usize = (3 - 1) * envelope_size;
15181
15182            // Zero reserved fields.
15183            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15184
15185            // Safety:
15186            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15187            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15188            //   envelope_size bytes, there is always sufficient room.
15189            fidl::encoding::encode_in_envelope_optional::<
15190                fidl::encoding::Endpoint<
15191                    fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
15192                >,
15193                fidl::encoding::DefaultFuchsiaResourceDialect,
15194            >(
15195                self.cig.as_mut().map(
15196                    <fidl::encoding::Endpoint<
15197                        fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
15198                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15199                ),
15200                encoder,
15201                offset + cur_offset,
15202                depth,
15203            )?;
15204
15205            _prev_end_offset = cur_offset + envelope_size;
15206
15207            Ok(())
15208        }
15209    }
15210
15211    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
15212        for CentralCreateConnectedIsochronousGroupRequest
15213    {
15214        #[inline(always)]
15215        fn new_empty() -> Self {
15216            Self::default()
15217        }
15218
15219        unsafe fn decode(
15220            &mut self,
15221            decoder: &mut fidl::encoding::Decoder<
15222                '_,
15223                fidl::encoding::DefaultFuchsiaResourceDialect,
15224            >,
15225            offset: usize,
15226            mut depth: fidl::encoding::Depth,
15227        ) -> fidl::Result<()> {
15228            decoder.debug_check_bounds::<Self>(offset);
15229            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15230                None => return Err(fidl::Error::NotNullable),
15231                Some(len) => len,
15232            };
15233            // Calling decoder.out_of_line_offset(0) is not allowed.
15234            if len == 0 {
15235                return Ok(());
15236            };
15237            depth.increment()?;
15238            let envelope_size = 8;
15239            let bytes_len = len * envelope_size;
15240            let offset = decoder.out_of_line_offset(bytes_len)?;
15241            // Decode the envelope for each type.
15242            let mut _next_ordinal_to_read = 0;
15243            let mut next_offset = offset;
15244            let end_offset = offset + bytes_len;
15245            _next_ordinal_to_read += 1;
15246            if next_offset >= end_offset {
15247                return Ok(());
15248            }
15249
15250            // Decode unknown envelopes for gaps in ordinals.
15251            while _next_ordinal_to_read < 1 {
15252                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15253                _next_ordinal_to_read += 1;
15254                next_offset += envelope_size;
15255            }
15256
15257            let next_out_of_line = decoder.next_out_of_line();
15258            let handles_before = decoder.remaining_handles();
15259            if let Some((inlined, num_bytes, num_handles)) =
15260                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15261            {
15262                let member_inline_size =
15263                    <CigParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15264                if inlined != (member_inline_size <= 4) {
15265                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15266                }
15267                let inner_offset;
15268                let mut inner_depth = depth.clone();
15269                if inlined {
15270                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15271                    inner_offset = next_offset;
15272                } else {
15273                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15274                    inner_depth.increment()?;
15275                }
15276                let val_ref = self.cig_parameters.get_or_insert_with(|| {
15277                    fidl::new_empty!(CigParameters, fidl::encoding::DefaultFuchsiaResourceDialect)
15278                });
15279                fidl::decode!(
15280                    CigParameters,
15281                    fidl::encoding::DefaultFuchsiaResourceDialect,
15282                    val_ref,
15283                    decoder,
15284                    inner_offset,
15285                    inner_depth
15286                )?;
15287                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15288                {
15289                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15290                }
15291                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15292                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15293                }
15294            }
15295
15296            next_offset += envelope_size;
15297            _next_ordinal_to_read += 1;
15298            if next_offset >= end_offset {
15299                return Ok(());
15300            }
15301
15302            // Decode unknown envelopes for gaps in ordinals.
15303            while _next_ordinal_to_read < 2 {
15304                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15305                _next_ordinal_to_read += 1;
15306                next_offset += envelope_size;
15307            }
15308
15309            let next_out_of_line = decoder.next_out_of_line();
15310            let handles_before = decoder.remaining_handles();
15311            if let Some((inlined, num_bytes, num_handles)) =
15312                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15313            {
15314                let member_inline_size = <fidl::encoding::Vector<CisRequestedParameters, 31> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15315                if inlined != (member_inline_size <= 4) {
15316                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15317                }
15318                let inner_offset;
15319                let mut inner_depth = depth.clone();
15320                if inlined {
15321                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15322                    inner_offset = next_offset;
15323                } else {
15324                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15325                    inner_depth.increment()?;
15326                }
15327                let val_ref =
15328                self.cis_requested_parameters.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect));
15329                fidl::decode!(fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
15330                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15331                {
15332                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15333                }
15334                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15335                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15336                }
15337            }
15338
15339            next_offset += envelope_size;
15340            _next_ordinal_to_read += 1;
15341            if next_offset >= end_offset {
15342                return Ok(());
15343            }
15344
15345            // Decode unknown envelopes for gaps in ordinals.
15346            while _next_ordinal_to_read < 3 {
15347                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15348                _next_ordinal_to_read += 1;
15349                next_offset += envelope_size;
15350            }
15351
15352            let next_out_of_line = decoder.next_out_of_line();
15353            let handles_before = decoder.remaining_handles();
15354            if let Some((inlined, num_bytes, num_handles)) =
15355                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15356            {
15357                let member_inline_size = <fidl::encoding::Endpoint<
15358                    fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
15359                > as fidl::encoding::TypeMarker>::inline_size(
15360                    decoder.context
15361                );
15362                if inlined != (member_inline_size <= 4) {
15363                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15364                }
15365                let inner_offset;
15366                let mut inner_depth = depth.clone();
15367                if inlined {
15368                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15369                    inner_offset = next_offset;
15370                } else {
15371                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15372                    inner_depth.increment()?;
15373                }
15374                let val_ref = self.cig.get_or_insert_with(|| {
15375                    fidl::new_empty!(
15376                        fidl::encoding::Endpoint<
15377                            fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
15378                        >,
15379                        fidl::encoding::DefaultFuchsiaResourceDialect
15380                    )
15381                });
15382                fidl::decode!(
15383                    fidl::encoding::Endpoint<
15384                        fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
15385                    >,
15386                    fidl::encoding::DefaultFuchsiaResourceDialect,
15387                    val_ref,
15388                    decoder,
15389                    inner_offset,
15390                    inner_depth
15391                )?;
15392                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15393                {
15394                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15395                }
15396                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15397                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15398                }
15399            }
15400
15401            next_offset += envelope_size;
15402
15403            // Decode the remaining unknown envelopes.
15404            while next_offset < end_offset {
15405                _next_ordinal_to_read += 1;
15406                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15407                next_offset += envelope_size;
15408            }
15409
15410            Ok(())
15411        }
15412    }
15413
15414    impl CentralSyncToPeriodicAdvertisingRequest {
15415        #[inline(always)]
15416        fn max_ordinal_present(&self) -> u64 {
15417            if let Some(_) = self.config {
15418                return 4;
15419            }
15420            if let Some(_) = self.sync {
15421                return 3;
15422            }
15423            if let Some(_) = self.advertising_sid {
15424                return 2;
15425            }
15426            if let Some(_) = self.peer_id {
15427                return 1;
15428            }
15429            0
15430        }
15431    }
15432
15433    impl fidl::encoding::ResourceTypeMarker for CentralSyncToPeriodicAdvertisingRequest {
15434        type Borrowed<'a> = &'a mut Self;
15435        fn take_or_borrow<'a>(
15436            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15437        ) -> Self::Borrowed<'a> {
15438            value
15439        }
15440    }
15441
15442    unsafe impl fidl::encoding::TypeMarker for CentralSyncToPeriodicAdvertisingRequest {
15443        type Owned = Self;
15444
15445        #[inline(always)]
15446        fn inline_align(_context: fidl::encoding::Context) -> usize {
15447            8
15448        }
15449
15450        #[inline(always)]
15451        fn inline_size(_context: fidl::encoding::Context) -> usize {
15452            16
15453        }
15454    }
15455
15456    unsafe impl
15457        fidl::encoding::Encode<
15458            CentralSyncToPeriodicAdvertisingRequest,
15459            fidl::encoding::DefaultFuchsiaResourceDialect,
15460        > for &mut CentralSyncToPeriodicAdvertisingRequest
15461    {
15462        unsafe fn encode(
15463            self,
15464            encoder: &mut fidl::encoding::Encoder<
15465                '_,
15466                fidl::encoding::DefaultFuchsiaResourceDialect,
15467            >,
15468            offset: usize,
15469            mut depth: fidl::encoding::Depth,
15470        ) -> fidl::Result<()> {
15471            encoder.debug_check_bounds::<CentralSyncToPeriodicAdvertisingRequest>(offset);
15472            // Vector header
15473            let max_ordinal: u64 = self.max_ordinal_present();
15474            encoder.write_num(max_ordinal, offset);
15475            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15476            // Calling encoder.out_of_line_offset(0) is not allowed.
15477            if max_ordinal == 0 {
15478                return Ok(());
15479            }
15480            depth.increment()?;
15481            let envelope_size = 8;
15482            let bytes_len = max_ordinal as usize * envelope_size;
15483            #[allow(unused_variables)]
15484            let offset = encoder.out_of_line_offset(bytes_len);
15485            let mut _prev_end_offset: usize = 0;
15486            if 1 > max_ordinal {
15487                return Ok(());
15488            }
15489
15490            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15491            // are envelope_size bytes.
15492            let cur_offset: usize = (1 - 1) * envelope_size;
15493
15494            // Zero reserved fields.
15495            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15496
15497            // Safety:
15498            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15499            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15500            //   envelope_size bytes, there is always sufficient room.
15501            fidl::encoding::encode_in_envelope_optional::<
15502                fidl_fuchsia_bluetooth::PeerId,
15503                fidl::encoding::DefaultFuchsiaResourceDialect,
15504            >(
15505                self.peer_id.as_ref().map(
15506                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow,
15507                ),
15508                encoder,
15509                offset + cur_offset,
15510                depth,
15511            )?;
15512
15513            _prev_end_offset = cur_offset + envelope_size;
15514            if 2 > max_ordinal {
15515                return Ok(());
15516            }
15517
15518            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15519            // are envelope_size bytes.
15520            let cur_offset: usize = (2 - 1) * envelope_size;
15521
15522            // Zero reserved fields.
15523            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15524
15525            // Safety:
15526            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15527            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15528            //   envelope_size bytes, there is always sufficient room.
15529            fidl::encoding::encode_in_envelope_optional::<
15530                u8,
15531                fidl::encoding::DefaultFuchsiaResourceDialect,
15532            >(
15533                self.advertising_sid.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
15534                encoder,
15535                offset + cur_offset,
15536                depth,
15537            )?;
15538
15539            _prev_end_offset = cur_offset + envelope_size;
15540            if 3 > max_ordinal {
15541                return Ok(());
15542            }
15543
15544            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15545            // are envelope_size bytes.
15546            let cur_offset: usize = (3 - 1) * envelope_size;
15547
15548            // Zero reserved fields.
15549            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15550
15551            // Safety:
15552            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15553            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15554            //   envelope_size bytes, there is always sufficient room.
15555            fidl::encoding::encode_in_envelope_optional::<
15556                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>>,
15557                fidl::encoding::DefaultFuchsiaResourceDialect,
15558            >(
15559                self.sync.as_mut().map(
15560                    <fidl::encoding::Endpoint<
15561                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
15562                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15563                ),
15564                encoder,
15565                offset + cur_offset,
15566                depth,
15567            )?;
15568
15569            _prev_end_offset = cur_offset + envelope_size;
15570            if 4 > max_ordinal {
15571                return Ok(());
15572            }
15573
15574            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15575            // are envelope_size bytes.
15576            let cur_offset: usize = (4 - 1) * envelope_size;
15577
15578            // Zero reserved fields.
15579            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15580
15581            // Safety:
15582            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15583            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15584            //   envelope_size bytes, there is always sufficient room.
15585            fidl::encoding::encode_in_envelope_optional::<PeriodicAdvertisingSyncConfiguration, fidl::encoding::DefaultFuchsiaResourceDialect>(
15586            self.config.as_ref().map(<PeriodicAdvertisingSyncConfiguration as fidl::encoding::ValueTypeMarker>::borrow),
15587            encoder, offset + cur_offset, depth
15588        )?;
15589
15590            _prev_end_offset = cur_offset + envelope_size;
15591
15592            Ok(())
15593        }
15594    }
15595
15596    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
15597        for CentralSyncToPeriodicAdvertisingRequest
15598    {
15599        #[inline(always)]
15600        fn new_empty() -> Self {
15601            Self::default()
15602        }
15603
15604        unsafe fn decode(
15605            &mut self,
15606            decoder: &mut fidl::encoding::Decoder<
15607                '_,
15608                fidl::encoding::DefaultFuchsiaResourceDialect,
15609            >,
15610            offset: usize,
15611            mut depth: fidl::encoding::Depth,
15612        ) -> fidl::Result<()> {
15613            decoder.debug_check_bounds::<Self>(offset);
15614            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15615                None => return Err(fidl::Error::NotNullable),
15616                Some(len) => len,
15617            };
15618            // Calling decoder.out_of_line_offset(0) is not allowed.
15619            if len == 0 {
15620                return Ok(());
15621            };
15622            depth.increment()?;
15623            let envelope_size = 8;
15624            let bytes_len = len * envelope_size;
15625            let offset = decoder.out_of_line_offset(bytes_len)?;
15626            // Decode the envelope for each type.
15627            let mut _next_ordinal_to_read = 0;
15628            let mut next_offset = offset;
15629            let end_offset = offset + bytes_len;
15630            _next_ordinal_to_read += 1;
15631            if next_offset >= end_offset {
15632                return Ok(());
15633            }
15634
15635            // Decode unknown envelopes for gaps in ordinals.
15636            while _next_ordinal_to_read < 1 {
15637                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15638                _next_ordinal_to_read += 1;
15639                next_offset += envelope_size;
15640            }
15641
15642            let next_out_of_line = decoder.next_out_of_line();
15643            let handles_before = decoder.remaining_handles();
15644            if let Some((inlined, num_bytes, num_handles)) =
15645                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15646            {
15647                let member_inline_size =
15648                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::TypeMarker>::inline_size(
15649                        decoder.context,
15650                    );
15651                if inlined != (member_inline_size <= 4) {
15652                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15653                }
15654                let inner_offset;
15655                let mut inner_depth = depth.clone();
15656                if inlined {
15657                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15658                    inner_offset = next_offset;
15659                } else {
15660                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15661                    inner_depth.increment()?;
15662                }
15663                let val_ref = self.peer_id.get_or_insert_with(|| {
15664                    fidl::new_empty!(
15665                        fidl_fuchsia_bluetooth::PeerId,
15666                        fidl::encoding::DefaultFuchsiaResourceDialect
15667                    )
15668                });
15669                fidl::decode!(
15670                    fidl_fuchsia_bluetooth::PeerId,
15671                    fidl::encoding::DefaultFuchsiaResourceDialect,
15672                    val_ref,
15673                    decoder,
15674                    inner_offset,
15675                    inner_depth
15676                )?;
15677                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15678                {
15679                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15680                }
15681                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15682                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15683                }
15684            }
15685
15686            next_offset += envelope_size;
15687            _next_ordinal_to_read += 1;
15688            if next_offset >= end_offset {
15689                return Ok(());
15690            }
15691
15692            // Decode unknown envelopes for gaps in ordinals.
15693            while _next_ordinal_to_read < 2 {
15694                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15695                _next_ordinal_to_read += 1;
15696                next_offset += envelope_size;
15697            }
15698
15699            let next_out_of_line = decoder.next_out_of_line();
15700            let handles_before = decoder.remaining_handles();
15701            if let Some((inlined, num_bytes, num_handles)) =
15702                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15703            {
15704                let member_inline_size =
15705                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15706                if inlined != (member_inline_size <= 4) {
15707                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15708                }
15709                let inner_offset;
15710                let mut inner_depth = depth.clone();
15711                if inlined {
15712                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15713                    inner_offset = next_offset;
15714                } else {
15715                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15716                    inner_depth.increment()?;
15717                }
15718                let val_ref = self.advertising_sid.get_or_insert_with(|| {
15719                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
15720                });
15721                fidl::decode!(
15722                    u8,
15723                    fidl::encoding::DefaultFuchsiaResourceDialect,
15724                    val_ref,
15725                    decoder,
15726                    inner_offset,
15727                    inner_depth
15728                )?;
15729                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15730                {
15731                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15732                }
15733                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15734                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15735                }
15736            }
15737
15738            next_offset += envelope_size;
15739            _next_ordinal_to_read += 1;
15740            if next_offset >= end_offset {
15741                return Ok(());
15742            }
15743
15744            // Decode unknown envelopes for gaps in ordinals.
15745            while _next_ordinal_to_read < 3 {
15746                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15747                _next_ordinal_to_read += 1;
15748                next_offset += envelope_size;
15749            }
15750
15751            let next_out_of_line = decoder.next_out_of_line();
15752            let handles_before = decoder.remaining_handles();
15753            if let Some((inlined, num_bytes, num_handles)) =
15754                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15755            {
15756                let member_inline_size = <fidl::encoding::Endpoint<
15757                    fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
15758                > as fidl::encoding::TypeMarker>::inline_size(
15759                    decoder.context
15760                );
15761                if inlined != (member_inline_size <= 4) {
15762                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15763                }
15764                let inner_offset;
15765                let mut inner_depth = depth.clone();
15766                if inlined {
15767                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15768                    inner_offset = next_offset;
15769                } else {
15770                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15771                    inner_depth.increment()?;
15772                }
15773                let val_ref = self.sync.get_or_insert_with(|| {
15774                    fidl::new_empty!(
15775                        fidl::encoding::Endpoint<
15776                            fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
15777                        >,
15778                        fidl::encoding::DefaultFuchsiaResourceDialect
15779                    )
15780                });
15781                fidl::decode!(
15782                    fidl::encoding::Endpoint<
15783                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
15784                    >,
15785                    fidl::encoding::DefaultFuchsiaResourceDialect,
15786                    val_ref,
15787                    decoder,
15788                    inner_offset,
15789                    inner_depth
15790                )?;
15791                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15792                {
15793                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15794                }
15795                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15796                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15797                }
15798            }
15799
15800            next_offset += envelope_size;
15801            _next_ordinal_to_read += 1;
15802            if next_offset >= end_offset {
15803                return Ok(());
15804            }
15805
15806            // Decode unknown envelopes for gaps in ordinals.
15807            while _next_ordinal_to_read < 4 {
15808                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15809                _next_ordinal_to_read += 1;
15810                next_offset += envelope_size;
15811            }
15812
15813            let next_out_of_line = decoder.next_out_of_line();
15814            let handles_before = decoder.remaining_handles();
15815            if let Some((inlined, num_bytes, num_handles)) =
15816                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15817            {
15818                let member_inline_size = <PeriodicAdvertisingSyncConfiguration as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15819                if inlined != (member_inline_size <= 4) {
15820                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15821                }
15822                let inner_offset;
15823                let mut inner_depth = depth.clone();
15824                if inlined {
15825                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15826                    inner_offset = next_offset;
15827                } else {
15828                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15829                    inner_depth.increment()?;
15830                }
15831                let val_ref = self.config.get_or_insert_with(|| {
15832                    fidl::new_empty!(
15833                        PeriodicAdvertisingSyncConfiguration,
15834                        fidl::encoding::DefaultFuchsiaResourceDialect
15835                    )
15836                });
15837                fidl::decode!(
15838                    PeriodicAdvertisingSyncConfiguration,
15839                    fidl::encoding::DefaultFuchsiaResourceDialect,
15840                    val_ref,
15841                    decoder,
15842                    inner_offset,
15843                    inner_depth
15844                )?;
15845                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15846                {
15847                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15848                }
15849                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15850                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15851                }
15852            }
15853
15854            next_offset += envelope_size;
15855
15856            // Decode the remaining unknown envelopes.
15857            while next_offset < end_offset {
15858                _next_ordinal_to_read += 1;
15859                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15860                next_offset += envelope_size;
15861            }
15862
15863            Ok(())
15864        }
15865    }
15866
15867    impl ChannelListenerConnectedRequest {
15868        #[inline(always)]
15869        fn max_ordinal_present(&self) -> u64 {
15870            if let Some(_) = self.ext_offload {
15871                return 2;
15872            }
15873            if let Some(_) = self.channel {
15874                return 1;
15875            }
15876            0
15877        }
15878    }
15879
15880    impl fidl::encoding::ResourceTypeMarker for ChannelListenerConnectedRequest {
15881        type Borrowed<'a> = &'a mut Self;
15882        fn take_or_borrow<'a>(
15883            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15884        ) -> Self::Borrowed<'a> {
15885            value
15886        }
15887    }
15888
15889    unsafe impl fidl::encoding::TypeMarker for ChannelListenerConnectedRequest {
15890        type Owned = Self;
15891
15892        #[inline(always)]
15893        fn inline_align(_context: fidl::encoding::Context) -> usize {
15894            8
15895        }
15896
15897        #[inline(always)]
15898        fn inline_size(_context: fidl::encoding::Context) -> usize {
15899            16
15900        }
15901    }
15902
15903    unsafe impl
15904        fidl::encoding::Encode<
15905            ChannelListenerConnectedRequest,
15906            fidl::encoding::DefaultFuchsiaResourceDialect,
15907        > for &mut ChannelListenerConnectedRequest
15908    {
15909        unsafe fn encode(
15910            self,
15911            encoder: &mut fidl::encoding::Encoder<
15912                '_,
15913                fidl::encoding::DefaultFuchsiaResourceDialect,
15914            >,
15915            offset: usize,
15916            mut depth: fidl::encoding::Depth,
15917        ) -> fidl::Result<()> {
15918            encoder.debug_check_bounds::<ChannelListenerConnectedRequest>(offset);
15919            // Vector header
15920            let max_ordinal: u64 = self.max_ordinal_present();
15921            encoder.write_num(max_ordinal, offset);
15922            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15923            // Calling encoder.out_of_line_offset(0) is not allowed.
15924            if max_ordinal == 0 {
15925                return Ok(());
15926            }
15927            depth.increment()?;
15928            let envelope_size = 8;
15929            let bytes_len = max_ordinal as usize * envelope_size;
15930            #[allow(unused_variables)]
15931            let offset = encoder.out_of_line_offset(bytes_len);
15932            let mut _prev_end_offset: usize = 0;
15933            if 1 > max_ordinal {
15934                return Ok(());
15935            }
15936
15937            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15938            // are envelope_size bytes.
15939            let cur_offset: usize = (1 - 1) * envelope_size;
15940
15941            // Zero reserved fields.
15942            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15943
15944            // Safety:
15945            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15946            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15947            //   envelope_size bytes, there is always sufficient room.
15948            fidl::encoding::encode_in_envelope_optional::<
15949                fidl::encoding::Endpoint<
15950                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
15951                >,
15952                fidl::encoding::DefaultFuchsiaResourceDialect,
15953            >(
15954                self.channel.as_mut().map(
15955                    <fidl::encoding::Endpoint<
15956                        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
15957                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15958                ),
15959                encoder,
15960                offset + cur_offset,
15961                depth,
15962            )?;
15963
15964            _prev_end_offset = cur_offset + envelope_size;
15965            if 2 > max_ordinal {
15966                return Ok(());
15967            }
15968
15969            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15970            // are envelope_size bytes.
15971            let cur_offset: usize = (2 - 1) * envelope_size;
15972
15973            // Zero reserved fields.
15974            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15975
15976            // Safety:
15977            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15978            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15979            //   envelope_size bytes, there is always sufficient room.
15980            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
15981            self.ext_offload.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
15982            encoder, offset + cur_offset, depth
15983        )?;
15984
15985            _prev_end_offset = cur_offset + envelope_size;
15986
15987            Ok(())
15988        }
15989    }
15990
15991    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
15992        for ChannelListenerConnectedRequest
15993    {
15994        #[inline(always)]
15995        fn new_empty() -> Self {
15996            Self::default()
15997        }
15998
15999        unsafe fn decode(
16000            &mut self,
16001            decoder: &mut fidl::encoding::Decoder<
16002                '_,
16003                fidl::encoding::DefaultFuchsiaResourceDialect,
16004            >,
16005            offset: usize,
16006            mut depth: fidl::encoding::Depth,
16007        ) -> fidl::Result<()> {
16008            decoder.debug_check_bounds::<Self>(offset);
16009            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16010                None => return Err(fidl::Error::NotNullable),
16011                Some(len) => len,
16012            };
16013            // Calling decoder.out_of_line_offset(0) is not allowed.
16014            if len == 0 {
16015                return Ok(());
16016            };
16017            depth.increment()?;
16018            let envelope_size = 8;
16019            let bytes_len = len * envelope_size;
16020            let offset = decoder.out_of_line_offset(bytes_len)?;
16021            // Decode the envelope for each type.
16022            let mut _next_ordinal_to_read = 0;
16023            let mut next_offset = offset;
16024            let end_offset = offset + bytes_len;
16025            _next_ordinal_to_read += 1;
16026            if next_offset >= end_offset {
16027                return Ok(());
16028            }
16029
16030            // Decode unknown envelopes for gaps in ordinals.
16031            while _next_ordinal_to_read < 1 {
16032                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16033                _next_ordinal_to_read += 1;
16034                next_offset += envelope_size;
16035            }
16036
16037            let next_out_of_line = decoder.next_out_of_line();
16038            let handles_before = decoder.remaining_handles();
16039            if let Some((inlined, num_bytes, num_handles)) =
16040                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16041            {
16042                let member_inline_size = <fidl::encoding::Endpoint<
16043                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
16044                > as fidl::encoding::TypeMarker>::inline_size(
16045                    decoder.context
16046                );
16047                if inlined != (member_inline_size <= 4) {
16048                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16049                }
16050                let inner_offset;
16051                let mut inner_depth = depth.clone();
16052                if inlined {
16053                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16054                    inner_offset = next_offset;
16055                } else {
16056                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16057                    inner_depth.increment()?;
16058                }
16059                let val_ref = self.channel.get_or_insert_with(|| {
16060                    fidl::new_empty!(
16061                        fidl::encoding::Endpoint<
16062                            fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
16063                        >,
16064                        fidl::encoding::DefaultFuchsiaResourceDialect
16065                    )
16066                });
16067                fidl::decode!(
16068                    fidl::encoding::Endpoint<
16069                        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
16070                    >,
16071                    fidl::encoding::DefaultFuchsiaResourceDialect,
16072                    val_ref,
16073                    decoder,
16074                    inner_offset,
16075                    inner_depth
16076                )?;
16077                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16078                {
16079                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16080                }
16081                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16082                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16083                }
16084            }
16085
16086            next_offset += envelope_size;
16087            _next_ordinal_to_read += 1;
16088            if next_offset >= end_offset {
16089                return Ok(());
16090            }
16091
16092            // Decode unknown envelopes for gaps in ordinals.
16093            while _next_ordinal_to_read < 2 {
16094                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16095                _next_ordinal_to_read += 1;
16096                next_offset += envelope_size;
16097            }
16098
16099            let next_out_of_line = decoder.next_out_of_line();
16100            let handles_before = decoder.remaining_handles();
16101            if let Some((inlined, num_bytes, num_handles)) =
16102                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16103            {
16104                let member_inline_size = <fidl::encoding::Endpoint<
16105                    fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>,
16106                > as fidl::encoding::TypeMarker>::inline_size(
16107                    decoder.context
16108                );
16109                if inlined != (member_inline_size <= 4) {
16110                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16111                }
16112                let inner_offset;
16113                let mut inner_depth = depth.clone();
16114                if inlined {
16115                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16116                    inner_offset = next_offset;
16117                } else {
16118                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16119                    inner_depth.increment()?;
16120                }
16121                let val_ref = self.ext_offload.get_or_insert_with(|| {
16122                    fidl::new_empty!(
16123                        fidl::encoding::Endpoint<
16124                            fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>,
16125                        >,
16126                        fidl::encoding::DefaultFuchsiaResourceDialect
16127                    )
16128                });
16129                fidl::decode!(
16130                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>>,
16131                    fidl::encoding::DefaultFuchsiaResourceDialect,
16132                    val_ref,
16133                    decoder,
16134                    inner_offset,
16135                    inner_depth
16136                )?;
16137                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16138                {
16139                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16140                }
16141                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16142                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16143                }
16144            }
16145
16146            next_offset += envelope_size;
16147
16148            // Decode the remaining unknown envelopes.
16149            while next_offset < end_offset {
16150                _next_ordinal_to_read += 1;
16151                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16152                next_offset += envelope_size;
16153            }
16154
16155            Ok(())
16156        }
16157    }
16158
16159    impl ChannelListenerRegistryListenL2capRequest {
16160        #[inline(always)]
16161        fn max_ordinal_present(&self) -> u64 {
16162            if let Some(_) = self.listener {
16163                return 2;
16164            }
16165            if let Some(_) = self.parameters {
16166                return 1;
16167            }
16168            0
16169        }
16170    }
16171
16172    impl fidl::encoding::ResourceTypeMarker for ChannelListenerRegistryListenL2capRequest {
16173        type Borrowed<'a> = &'a mut Self;
16174        fn take_or_borrow<'a>(
16175            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16176        ) -> Self::Borrowed<'a> {
16177            value
16178        }
16179    }
16180
16181    unsafe impl fidl::encoding::TypeMarker for ChannelListenerRegistryListenL2capRequest {
16182        type Owned = Self;
16183
16184        #[inline(always)]
16185        fn inline_align(_context: fidl::encoding::Context) -> usize {
16186            8
16187        }
16188
16189        #[inline(always)]
16190        fn inline_size(_context: fidl::encoding::Context) -> usize {
16191            16
16192        }
16193    }
16194
16195    unsafe impl
16196        fidl::encoding::Encode<
16197            ChannelListenerRegistryListenL2capRequest,
16198            fidl::encoding::DefaultFuchsiaResourceDialect,
16199        > for &mut ChannelListenerRegistryListenL2capRequest
16200    {
16201        unsafe fn encode(
16202            self,
16203            encoder: &mut fidl::encoding::Encoder<
16204                '_,
16205                fidl::encoding::DefaultFuchsiaResourceDialect,
16206            >,
16207            offset: usize,
16208            mut depth: fidl::encoding::Depth,
16209        ) -> fidl::Result<()> {
16210            encoder.debug_check_bounds::<ChannelListenerRegistryListenL2capRequest>(offset);
16211            // Vector header
16212            let max_ordinal: u64 = self.max_ordinal_present();
16213            encoder.write_num(max_ordinal, offset);
16214            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16215            // Calling encoder.out_of_line_offset(0) is not allowed.
16216            if max_ordinal == 0 {
16217                return Ok(());
16218            }
16219            depth.increment()?;
16220            let envelope_size = 8;
16221            let bytes_len = max_ordinal as usize * envelope_size;
16222            #[allow(unused_variables)]
16223            let offset = encoder.out_of_line_offset(bytes_len);
16224            let mut _prev_end_offset: usize = 0;
16225            if 1 > max_ordinal {
16226                return Ok(());
16227            }
16228
16229            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16230            // are envelope_size bytes.
16231            let cur_offset: usize = (1 - 1) * envelope_size;
16232
16233            // Zero reserved fields.
16234            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16235
16236            // Safety:
16237            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16238            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16239            //   envelope_size bytes, there is always sufficient room.
16240            fidl::encoding::encode_in_envelope_optional::<
16241                AcceptedChannelParameters,
16242                fidl::encoding::DefaultFuchsiaResourceDialect,
16243            >(
16244                self.parameters
16245                    .as_ref()
16246                    .map(<AcceptedChannelParameters as fidl::encoding::ValueTypeMarker>::borrow),
16247                encoder,
16248                offset + cur_offset,
16249                depth,
16250            )?;
16251
16252            _prev_end_offset = cur_offset + envelope_size;
16253            if 2 > max_ordinal {
16254                return Ok(());
16255            }
16256
16257            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16258            // are envelope_size bytes.
16259            let cur_offset: usize = (2 - 1) * envelope_size;
16260
16261            // Zero reserved fields.
16262            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16263
16264            // Safety:
16265            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16266            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16267            //   envelope_size bytes, there is always sufficient room.
16268            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
16269            self.listener.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
16270            encoder, offset + cur_offset, depth
16271        )?;
16272
16273            _prev_end_offset = cur_offset + envelope_size;
16274
16275            Ok(())
16276        }
16277    }
16278
16279    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
16280        for ChannelListenerRegistryListenL2capRequest
16281    {
16282        #[inline(always)]
16283        fn new_empty() -> Self {
16284            Self::default()
16285        }
16286
16287        unsafe fn decode(
16288            &mut self,
16289            decoder: &mut fidl::encoding::Decoder<
16290                '_,
16291                fidl::encoding::DefaultFuchsiaResourceDialect,
16292            >,
16293            offset: usize,
16294            mut depth: fidl::encoding::Depth,
16295        ) -> fidl::Result<()> {
16296            decoder.debug_check_bounds::<Self>(offset);
16297            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16298                None => return Err(fidl::Error::NotNullable),
16299                Some(len) => len,
16300            };
16301            // Calling decoder.out_of_line_offset(0) is not allowed.
16302            if len == 0 {
16303                return Ok(());
16304            };
16305            depth.increment()?;
16306            let envelope_size = 8;
16307            let bytes_len = len * envelope_size;
16308            let offset = decoder.out_of_line_offset(bytes_len)?;
16309            // Decode the envelope for each type.
16310            let mut _next_ordinal_to_read = 0;
16311            let mut next_offset = offset;
16312            let end_offset = offset + bytes_len;
16313            _next_ordinal_to_read += 1;
16314            if next_offset >= end_offset {
16315                return Ok(());
16316            }
16317
16318            // Decode unknown envelopes for gaps in ordinals.
16319            while _next_ordinal_to_read < 1 {
16320                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16321                _next_ordinal_to_read += 1;
16322                next_offset += envelope_size;
16323            }
16324
16325            let next_out_of_line = decoder.next_out_of_line();
16326            let handles_before = decoder.remaining_handles();
16327            if let Some((inlined, num_bytes, num_handles)) =
16328                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16329            {
16330                let member_inline_size =
16331                    <AcceptedChannelParameters as fidl::encoding::TypeMarker>::inline_size(
16332                        decoder.context,
16333                    );
16334                if inlined != (member_inline_size <= 4) {
16335                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16336                }
16337                let inner_offset;
16338                let mut inner_depth = depth.clone();
16339                if inlined {
16340                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16341                    inner_offset = next_offset;
16342                } else {
16343                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16344                    inner_depth.increment()?;
16345                }
16346                let val_ref = self.parameters.get_or_insert_with(|| {
16347                    fidl::new_empty!(
16348                        AcceptedChannelParameters,
16349                        fidl::encoding::DefaultFuchsiaResourceDialect
16350                    )
16351                });
16352                fidl::decode!(
16353                    AcceptedChannelParameters,
16354                    fidl::encoding::DefaultFuchsiaResourceDialect,
16355                    val_ref,
16356                    decoder,
16357                    inner_offset,
16358                    inner_depth
16359                )?;
16360                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16361                {
16362                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16363                }
16364                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16365                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16366                }
16367            }
16368
16369            next_offset += envelope_size;
16370            _next_ordinal_to_read += 1;
16371            if next_offset >= end_offset {
16372                return Ok(());
16373            }
16374
16375            // Decode unknown envelopes for gaps in ordinals.
16376            while _next_ordinal_to_read < 2 {
16377                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16378                _next_ordinal_to_read += 1;
16379                next_offset += envelope_size;
16380            }
16381
16382            let next_out_of_line = decoder.next_out_of_line();
16383            let handles_before = decoder.remaining_handles();
16384            if let Some((inlined, num_bytes, num_handles)) =
16385                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16386            {
16387                let member_inline_size = <fidl::encoding::Endpoint<
16388                    fidl::endpoints::ClientEnd<ChannelListenerMarker>,
16389                > as fidl::encoding::TypeMarker>::inline_size(
16390                    decoder.context
16391                );
16392                if inlined != (member_inline_size <= 4) {
16393                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16394                }
16395                let inner_offset;
16396                let mut inner_depth = depth.clone();
16397                if inlined {
16398                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16399                    inner_offset = next_offset;
16400                } else {
16401                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16402                    inner_depth.increment()?;
16403                }
16404                let val_ref = self.listener.get_or_insert_with(|| {
16405                    fidl::new_empty!(
16406                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
16407                        fidl::encoding::DefaultFuchsiaResourceDialect
16408                    )
16409                });
16410                fidl::decode!(
16411                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
16412                    fidl::encoding::DefaultFuchsiaResourceDialect,
16413                    val_ref,
16414                    decoder,
16415                    inner_offset,
16416                    inner_depth
16417                )?;
16418                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16419                {
16420                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16421                }
16422                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16423                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16424                }
16425            }
16426
16427            next_offset += envelope_size;
16428
16429            // Decode the remaining unknown envelopes.
16430            while next_offset < end_offset {
16431                _next_ordinal_to_read += 1;
16432                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16433                next_offset += envelope_size;
16434            }
16435
16436            Ok(())
16437        }
16438    }
16439
16440    impl CisRequestedParameters {
16441        #[inline(always)]
16442        fn max_ordinal_present(&self) -> u64 {
16443            if let Some(_) = self.max_sdu_size_incoming {
16444                return 4;
16445            }
16446            if let Some(_) = self.max_sdu_size_outgoing {
16447                return 3;
16448            }
16449            if let Some(_) = self.connection_stream {
16450                return 2;
16451            }
16452            if let Some(_) = self.cis_id {
16453                return 1;
16454            }
16455            0
16456        }
16457    }
16458
16459    impl fidl::encoding::ResourceTypeMarker for CisRequestedParameters {
16460        type Borrowed<'a> = &'a mut Self;
16461        fn take_or_borrow<'a>(
16462            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16463        ) -> Self::Borrowed<'a> {
16464            value
16465        }
16466    }
16467
16468    unsafe impl fidl::encoding::TypeMarker for CisRequestedParameters {
16469        type Owned = Self;
16470
16471        #[inline(always)]
16472        fn inline_align(_context: fidl::encoding::Context) -> usize {
16473            8
16474        }
16475
16476        #[inline(always)]
16477        fn inline_size(_context: fidl::encoding::Context) -> usize {
16478            16
16479        }
16480    }
16481
16482    unsafe impl
16483        fidl::encoding::Encode<
16484            CisRequestedParameters,
16485            fidl::encoding::DefaultFuchsiaResourceDialect,
16486        > for &mut CisRequestedParameters
16487    {
16488        unsafe fn encode(
16489            self,
16490            encoder: &mut fidl::encoding::Encoder<
16491                '_,
16492                fidl::encoding::DefaultFuchsiaResourceDialect,
16493            >,
16494            offset: usize,
16495            mut depth: fidl::encoding::Depth,
16496        ) -> fidl::Result<()> {
16497            encoder.debug_check_bounds::<CisRequestedParameters>(offset);
16498            // Vector header
16499            let max_ordinal: u64 = self.max_ordinal_present();
16500            encoder.write_num(max_ordinal, offset);
16501            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16502            // Calling encoder.out_of_line_offset(0) is not allowed.
16503            if max_ordinal == 0 {
16504                return Ok(());
16505            }
16506            depth.increment()?;
16507            let envelope_size = 8;
16508            let bytes_len = max_ordinal as usize * envelope_size;
16509            #[allow(unused_variables)]
16510            let offset = encoder.out_of_line_offset(bytes_len);
16511            let mut _prev_end_offset: usize = 0;
16512            if 1 > max_ordinal {
16513                return Ok(());
16514            }
16515
16516            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16517            // are envelope_size bytes.
16518            let cur_offset: usize = (1 - 1) * envelope_size;
16519
16520            // Zero reserved fields.
16521            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16522
16523            // Safety:
16524            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16525            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16526            //   envelope_size bytes, there is always sufficient room.
16527            fidl::encoding::encode_in_envelope_optional::<
16528                u8,
16529                fidl::encoding::DefaultFuchsiaResourceDialect,
16530            >(
16531                self.cis_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
16532                encoder,
16533                offset + cur_offset,
16534                depth,
16535            )?;
16536
16537            _prev_end_offset = cur_offset + envelope_size;
16538            if 2 > max_ordinal {
16539                return Ok(());
16540            }
16541
16542            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16543            // are envelope_size bytes.
16544            let cur_offset: usize = (2 - 1) * envelope_size;
16545
16546            // Zero reserved fields.
16547            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16548
16549            // Safety:
16550            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16551            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16552            //   envelope_size bytes, there is always sufficient room.
16553            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
16554            self.connection_stream.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
16555            encoder, offset + cur_offset, depth
16556        )?;
16557
16558            _prev_end_offset = cur_offset + envelope_size;
16559            if 3 > max_ordinal {
16560                return Ok(());
16561            }
16562
16563            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16564            // are envelope_size bytes.
16565            let cur_offset: usize = (3 - 1) * envelope_size;
16566
16567            // Zero reserved fields.
16568            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16569
16570            // Safety:
16571            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16572            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16573            //   envelope_size bytes, there is always sufficient room.
16574            fidl::encoding::encode_in_envelope_optional::<
16575                u16,
16576                fidl::encoding::DefaultFuchsiaResourceDialect,
16577            >(
16578                self.max_sdu_size_outgoing
16579                    .as_ref()
16580                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
16581                encoder,
16582                offset + cur_offset,
16583                depth,
16584            )?;
16585
16586            _prev_end_offset = cur_offset + envelope_size;
16587            if 4 > max_ordinal {
16588                return Ok(());
16589            }
16590
16591            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16592            // are envelope_size bytes.
16593            let cur_offset: usize = (4 - 1) * envelope_size;
16594
16595            // Zero reserved fields.
16596            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16597
16598            // Safety:
16599            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16600            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16601            //   envelope_size bytes, there is always sufficient room.
16602            fidl::encoding::encode_in_envelope_optional::<
16603                u16,
16604                fidl::encoding::DefaultFuchsiaResourceDialect,
16605            >(
16606                self.max_sdu_size_incoming
16607                    .as_ref()
16608                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
16609                encoder,
16610                offset + cur_offset,
16611                depth,
16612            )?;
16613
16614            _prev_end_offset = cur_offset + envelope_size;
16615
16616            Ok(())
16617        }
16618    }
16619
16620    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
16621        for CisRequestedParameters
16622    {
16623        #[inline(always)]
16624        fn new_empty() -> Self {
16625            Self::default()
16626        }
16627
16628        unsafe fn decode(
16629            &mut self,
16630            decoder: &mut fidl::encoding::Decoder<
16631                '_,
16632                fidl::encoding::DefaultFuchsiaResourceDialect,
16633            >,
16634            offset: usize,
16635            mut depth: fidl::encoding::Depth,
16636        ) -> fidl::Result<()> {
16637            decoder.debug_check_bounds::<Self>(offset);
16638            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16639                None => return Err(fidl::Error::NotNullable),
16640                Some(len) => len,
16641            };
16642            // Calling decoder.out_of_line_offset(0) is not allowed.
16643            if len == 0 {
16644                return Ok(());
16645            };
16646            depth.increment()?;
16647            let envelope_size = 8;
16648            let bytes_len = len * envelope_size;
16649            let offset = decoder.out_of_line_offset(bytes_len)?;
16650            // Decode the envelope for each type.
16651            let mut _next_ordinal_to_read = 0;
16652            let mut next_offset = offset;
16653            let end_offset = offset + bytes_len;
16654            _next_ordinal_to_read += 1;
16655            if next_offset >= end_offset {
16656                return Ok(());
16657            }
16658
16659            // Decode unknown envelopes for gaps in ordinals.
16660            while _next_ordinal_to_read < 1 {
16661                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16662                _next_ordinal_to_read += 1;
16663                next_offset += envelope_size;
16664            }
16665
16666            let next_out_of_line = decoder.next_out_of_line();
16667            let handles_before = decoder.remaining_handles();
16668            if let Some((inlined, num_bytes, num_handles)) =
16669                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16670            {
16671                let member_inline_size =
16672                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16673                if inlined != (member_inline_size <= 4) {
16674                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16675                }
16676                let inner_offset;
16677                let mut inner_depth = depth.clone();
16678                if inlined {
16679                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16680                    inner_offset = next_offset;
16681                } else {
16682                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16683                    inner_depth.increment()?;
16684                }
16685                let val_ref = self.cis_id.get_or_insert_with(|| {
16686                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
16687                });
16688                fidl::decode!(
16689                    u8,
16690                    fidl::encoding::DefaultFuchsiaResourceDialect,
16691                    val_ref,
16692                    decoder,
16693                    inner_offset,
16694                    inner_depth
16695                )?;
16696                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16697                {
16698                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16699                }
16700                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16701                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16702                }
16703            }
16704
16705            next_offset += envelope_size;
16706            _next_ordinal_to_read += 1;
16707            if next_offset >= end_offset {
16708                return Ok(());
16709            }
16710
16711            // Decode unknown envelopes for gaps in ordinals.
16712            while _next_ordinal_to_read < 2 {
16713                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16714                _next_ordinal_to_read += 1;
16715                next_offset += envelope_size;
16716            }
16717
16718            let next_out_of_line = decoder.next_out_of_line();
16719            let handles_before = decoder.remaining_handles();
16720            if let Some((inlined, num_bytes, num_handles)) =
16721                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16722            {
16723                let member_inline_size = <fidl::encoding::Endpoint<
16724                    fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
16725                > as fidl::encoding::TypeMarker>::inline_size(
16726                    decoder.context
16727                );
16728                if inlined != (member_inline_size <= 4) {
16729                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16730                }
16731                let inner_offset;
16732                let mut inner_depth = depth.clone();
16733                if inlined {
16734                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16735                    inner_offset = next_offset;
16736                } else {
16737                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16738                    inner_depth.increment()?;
16739                }
16740                let val_ref = self.connection_stream.get_or_insert_with(|| {
16741                    fidl::new_empty!(
16742                        fidl::encoding::Endpoint<
16743                            fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
16744                        >,
16745                        fidl::encoding::DefaultFuchsiaResourceDialect
16746                    )
16747                });
16748                fidl::decode!(
16749                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
16750                    fidl::encoding::DefaultFuchsiaResourceDialect,
16751                    val_ref,
16752                    decoder,
16753                    inner_offset,
16754                    inner_depth
16755                )?;
16756                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16757                {
16758                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16759                }
16760                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16761                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16762                }
16763            }
16764
16765            next_offset += envelope_size;
16766            _next_ordinal_to_read += 1;
16767            if next_offset >= end_offset {
16768                return Ok(());
16769            }
16770
16771            // Decode unknown envelopes for gaps in ordinals.
16772            while _next_ordinal_to_read < 3 {
16773                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16774                _next_ordinal_to_read += 1;
16775                next_offset += envelope_size;
16776            }
16777
16778            let next_out_of_line = decoder.next_out_of_line();
16779            let handles_before = decoder.remaining_handles();
16780            if let Some((inlined, num_bytes, num_handles)) =
16781                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16782            {
16783                let member_inline_size =
16784                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16785                if inlined != (member_inline_size <= 4) {
16786                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16787                }
16788                let inner_offset;
16789                let mut inner_depth = depth.clone();
16790                if inlined {
16791                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16792                    inner_offset = next_offset;
16793                } else {
16794                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16795                    inner_depth.increment()?;
16796                }
16797                let val_ref = self.max_sdu_size_outgoing.get_or_insert_with(|| {
16798                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
16799                });
16800                fidl::decode!(
16801                    u16,
16802                    fidl::encoding::DefaultFuchsiaResourceDialect,
16803                    val_ref,
16804                    decoder,
16805                    inner_offset,
16806                    inner_depth
16807                )?;
16808                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16809                {
16810                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16811                }
16812                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16813                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16814                }
16815            }
16816
16817            next_offset += envelope_size;
16818            _next_ordinal_to_read += 1;
16819            if next_offset >= end_offset {
16820                return Ok(());
16821            }
16822
16823            // Decode unknown envelopes for gaps in ordinals.
16824            while _next_ordinal_to_read < 4 {
16825                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16826                _next_ordinal_to_read += 1;
16827                next_offset += envelope_size;
16828            }
16829
16830            let next_out_of_line = decoder.next_out_of_line();
16831            let handles_before = decoder.remaining_handles();
16832            if let Some((inlined, num_bytes, num_handles)) =
16833                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16834            {
16835                let member_inline_size =
16836                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16837                if inlined != (member_inline_size <= 4) {
16838                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16839                }
16840                let inner_offset;
16841                let mut inner_depth = depth.clone();
16842                if inlined {
16843                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16844                    inner_offset = next_offset;
16845                } else {
16846                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16847                    inner_depth.increment()?;
16848                }
16849                let val_ref = self.max_sdu_size_incoming.get_or_insert_with(|| {
16850                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
16851                });
16852                fidl::decode!(
16853                    u16,
16854                    fidl::encoding::DefaultFuchsiaResourceDialect,
16855                    val_ref,
16856                    decoder,
16857                    inner_offset,
16858                    inner_depth
16859                )?;
16860                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16861                {
16862                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16863                }
16864                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16865                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16866                }
16867            }
16868
16869            next_offset += envelope_size;
16870
16871            // Decode the remaining unknown envelopes.
16872            while next_offset < end_offset {
16873                _next_ordinal_to_read += 1;
16874                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16875                next_offset += envelope_size;
16876            }
16877
16878            Ok(())
16879        }
16880    }
16881
16882    impl ConnectionAcceptCisRequest {
16883        #[inline(always)]
16884        fn max_ordinal_present(&self) -> u64 {
16885            if let Some(_) = self.connection_stream {
16886                return 3;
16887            }
16888            if let Some(_) = self.cis_id {
16889                return 2;
16890            }
16891            if let Some(_) = self.cig_id {
16892                return 1;
16893            }
16894            0
16895        }
16896    }
16897
16898    impl fidl::encoding::ResourceTypeMarker for ConnectionAcceptCisRequest {
16899        type Borrowed<'a> = &'a mut Self;
16900        fn take_or_borrow<'a>(
16901            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16902        ) -> Self::Borrowed<'a> {
16903            value
16904        }
16905    }
16906
16907    unsafe impl fidl::encoding::TypeMarker for ConnectionAcceptCisRequest {
16908        type Owned = Self;
16909
16910        #[inline(always)]
16911        fn inline_align(_context: fidl::encoding::Context) -> usize {
16912            8
16913        }
16914
16915        #[inline(always)]
16916        fn inline_size(_context: fidl::encoding::Context) -> usize {
16917            16
16918        }
16919    }
16920
16921    unsafe impl
16922        fidl::encoding::Encode<
16923            ConnectionAcceptCisRequest,
16924            fidl::encoding::DefaultFuchsiaResourceDialect,
16925        > for &mut ConnectionAcceptCisRequest
16926    {
16927        unsafe fn encode(
16928            self,
16929            encoder: &mut fidl::encoding::Encoder<
16930                '_,
16931                fidl::encoding::DefaultFuchsiaResourceDialect,
16932            >,
16933            offset: usize,
16934            mut depth: fidl::encoding::Depth,
16935        ) -> fidl::Result<()> {
16936            encoder.debug_check_bounds::<ConnectionAcceptCisRequest>(offset);
16937            // Vector header
16938            let max_ordinal: u64 = self.max_ordinal_present();
16939            encoder.write_num(max_ordinal, offset);
16940            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16941            // Calling encoder.out_of_line_offset(0) is not allowed.
16942            if max_ordinal == 0 {
16943                return Ok(());
16944            }
16945            depth.increment()?;
16946            let envelope_size = 8;
16947            let bytes_len = max_ordinal as usize * envelope_size;
16948            #[allow(unused_variables)]
16949            let offset = encoder.out_of_line_offset(bytes_len);
16950            let mut _prev_end_offset: usize = 0;
16951            if 1 > max_ordinal {
16952                return Ok(());
16953            }
16954
16955            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16956            // are envelope_size bytes.
16957            let cur_offset: usize = (1 - 1) * envelope_size;
16958
16959            // Zero reserved fields.
16960            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16961
16962            // Safety:
16963            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16964            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16965            //   envelope_size bytes, there is always sufficient room.
16966            fidl::encoding::encode_in_envelope_optional::<
16967                u8,
16968                fidl::encoding::DefaultFuchsiaResourceDialect,
16969            >(
16970                self.cig_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
16971                encoder,
16972                offset + cur_offset,
16973                depth,
16974            )?;
16975
16976            _prev_end_offset = cur_offset + envelope_size;
16977            if 2 > max_ordinal {
16978                return Ok(());
16979            }
16980
16981            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16982            // are envelope_size bytes.
16983            let cur_offset: usize = (2 - 1) * envelope_size;
16984
16985            // Zero reserved fields.
16986            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16987
16988            // Safety:
16989            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16990            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16991            //   envelope_size bytes, there is always sufficient room.
16992            fidl::encoding::encode_in_envelope_optional::<
16993                u8,
16994                fidl::encoding::DefaultFuchsiaResourceDialect,
16995            >(
16996                self.cis_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
16997                encoder,
16998                offset + cur_offset,
16999                depth,
17000            )?;
17001
17002            _prev_end_offset = cur_offset + envelope_size;
17003            if 3 > max_ordinal {
17004                return Ok(());
17005            }
17006
17007            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17008            // are envelope_size bytes.
17009            let cur_offset: usize = (3 - 1) * envelope_size;
17010
17011            // Zero reserved fields.
17012            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17013
17014            // Safety:
17015            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17016            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17017            //   envelope_size bytes, there is always sufficient room.
17018            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
17019            self.connection_stream.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
17020            encoder, offset + cur_offset, depth
17021        )?;
17022
17023            _prev_end_offset = cur_offset + envelope_size;
17024
17025            Ok(())
17026        }
17027    }
17028
17029    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
17030        for ConnectionAcceptCisRequest
17031    {
17032        #[inline(always)]
17033        fn new_empty() -> Self {
17034            Self::default()
17035        }
17036
17037        unsafe fn decode(
17038            &mut self,
17039            decoder: &mut fidl::encoding::Decoder<
17040                '_,
17041                fidl::encoding::DefaultFuchsiaResourceDialect,
17042            >,
17043            offset: usize,
17044            mut depth: fidl::encoding::Depth,
17045        ) -> fidl::Result<()> {
17046            decoder.debug_check_bounds::<Self>(offset);
17047            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17048                None => return Err(fidl::Error::NotNullable),
17049                Some(len) => len,
17050            };
17051            // Calling decoder.out_of_line_offset(0) is not allowed.
17052            if len == 0 {
17053                return Ok(());
17054            };
17055            depth.increment()?;
17056            let envelope_size = 8;
17057            let bytes_len = len * envelope_size;
17058            let offset = decoder.out_of_line_offset(bytes_len)?;
17059            // Decode the envelope for each type.
17060            let mut _next_ordinal_to_read = 0;
17061            let mut next_offset = offset;
17062            let end_offset = offset + bytes_len;
17063            _next_ordinal_to_read += 1;
17064            if next_offset >= end_offset {
17065                return Ok(());
17066            }
17067
17068            // Decode unknown envelopes for gaps in ordinals.
17069            while _next_ordinal_to_read < 1 {
17070                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17071                _next_ordinal_to_read += 1;
17072                next_offset += envelope_size;
17073            }
17074
17075            let next_out_of_line = decoder.next_out_of_line();
17076            let handles_before = decoder.remaining_handles();
17077            if let Some((inlined, num_bytes, num_handles)) =
17078                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17079            {
17080                let member_inline_size =
17081                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17082                if inlined != (member_inline_size <= 4) {
17083                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17084                }
17085                let inner_offset;
17086                let mut inner_depth = depth.clone();
17087                if inlined {
17088                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17089                    inner_offset = next_offset;
17090                } else {
17091                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17092                    inner_depth.increment()?;
17093                }
17094                let val_ref = self.cig_id.get_or_insert_with(|| {
17095                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
17096                });
17097                fidl::decode!(
17098                    u8,
17099                    fidl::encoding::DefaultFuchsiaResourceDialect,
17100                    val_ref,
17101                    decoder,
17102                    inner_offset,
17103                    inner_depth
17104                )?;
17105                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17106                {
17107                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17108                }
17109                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17110                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17111                }
17112            }
17113
17114            next_offset += envelope_size;
17115            _next_ordinal_to_read += 1;
17116            if next_offset >= end_offset {
17117                return Ok(());
17118            }
17119
17120            // Decode unknown envelopes for gaps in ordinals.
17121            while _next_ordinal_to_read < 2 {
17122                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17123                _next_ordinal_to_read += 1;
17124                next_offset += envelope_size;
17125            }
17126
17127            let next_out_of_line = decoder.next_out_of_line();
17128            let handles_before = decoder.remaining_handles();
17129            if let Some((inlined, num_bytes, num_handles)) =
17130                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17131            {
17132                let member_inline_size =
17133                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17134                if inlined != (member_inline_size <= 4) {
17135                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17136                }
17137                let inner_offset;
17138                let mut inner_depth = depth.clone();
17139                if inlined {
17140                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17141                    inner_offset = next_offset;
17142                } else {
17143                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17144                    inner_depth.increment()?;
17145                }
17146                let val_ref = self.cis_id.get_or_insert_with(|| {
17147                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
17148                });
17149                fidl::decode!(
17150                    u8,
17151                    fidl::encoding::DefaultFuchsiaResourceDialect,
17152                    val_ref,
17153                    decoder,
17154                    inner_offset,
17155                    inner_depth
17156                )?;
17157                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17158                {
17159                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17160                }
17161                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17162                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17163                }
17164            }
17165
17166            next_offset += envelope_size;
17167            _next_ordinal_to_read += 1;
17168            if next_offset >= end_offset {
17169                return Ok(());
17170            }
17171
17172            // Decode unknown envelopes for gaps in ordinals.
17173            while _next_ordinal_to_read < 3 {
17174                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17175                _next_ordinal_to_read += 1;
17176                next_offset += envelope_size;
17177            }
17178
17179            let next_out_of_line = decoder.next_out_of_line();
17180            let handles_before = decoder.remaining_handles();
17181            if let Some((inlined, num_bytes, num_handles)) =
17182                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17183            {
17184                let member_inline_size = <fidl::encoding::Endpoint<
17185                    fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
17186                > as fidl::encoding::TypeMarker>::inline_size(
17187                    decoder.context
17188                );
17189                if inlined != (member_inline_size <= 4) {
17190                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17191                }
17192                let inner_offset;
17193                let mut inner_depth = depth.clone();
17194                if inlined {
17195                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17196                    inner_offset = next_offset;
17197                } else {
17198                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17199                    inner_depth.increment()?;
17200                }
17201                let val_ref = self.connection_stream.get_or_insert_with(|| {
17202                    fidl::new_empty!(
17203                        fidl::encoding::Endpoint<
17204                            fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
17205                        >,
17206                        fidl::encoding::DefaultFuchsiaResourceDialect
17207                    )
17208                });
17209                fidl::decode!(
17210                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
17211                    fidl::encoding::DefaultFuchsiaResourceDialect,
17212                    val_ref,
17213                    decoder,
17214                    inner_offset,
17215                    inner_depth
17216                )?;
17217                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17218                {
17219                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17220                }
17221                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17222                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17223                }
17224            }
17225
17226            next_offset += envelope_size;
17227
17228            // Decode the remaining unknown envelopes.
17229            while next_offset < end_offset {
17230                _next_ordinal_to_read += 1;
17231                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17232                next_offset += envelope_size;
17233            }
17234
17235            Ok(())
17236        }
17237    }
17238
17239    impl ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
17240        #[inline(always)]
17241        fn max_ordinal_present(&self) -> u64 {
17242            if let Some(_) = self.config {
17243                return 2;
17244            }
17245            if let Some(_) = self.sync {
17246                return 1;
17247            }
17248            0
17249        }
17250    }
17251
17252    impl fidl::encoding::ResourceTypeMarker for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
17253        type Borrowed<'a> = &'a mut Self;
17254        fn take_or_borrow<'a>(
17255            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17256        ) -> Self::Borrowed<'a> {
17257            value
17258        }
17259    }
17260
17261    unsafe impl fidl::encoding::TypeMarker for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
17262        type Owned = Self;
17263
17264        #[inline(always)]
17265        fn inline_align(_context: fidl::encoding::Context) -> usize {
17266            8
17267        }
17268
17269        #[inline(always)]
17270        fn inline_size(_context: fidl::encoding::Context) -> usize {
17271            16
17272        }
17273    }
17274
17275    unsafe impl
17276        fidl::encoding::Encode<
17277            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
17278            fidl::encoding::DefaultFuchsiaResourceDialect,
17279        > for &mut ConnectionAcceptPeriodicAdvertisingSyncTransferRequest
17280    {
17281        unsafe fn encode(
17282            self,
17283            encoder: &mut fidl::encoding::Encoder<
17284                '_,
17285                fidl::encoding::DefaultFuchsiaResourceDialect,
17286            >,
17287            offset: usize,
17288            mut depth: fidl::encoding::Depth,
17289        ) -> fidl::Result<()> {
17290            encoder.debug_check_bounds::<ConnectionAcceptPeriodicAdvertisingSyncTransferRequest>(
17291                offset,
17292            );
17293            // Vector header
17294            let max_ordinal: u64 = self.max_ordinal_present();
17295            encoder.write_num(max_ordinal, offset);
17296            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17297            // Calling encoder.out_of_line_offset(0) is not allowed.
17298            if max_ordinal == 0 {
17299                return Ok(());
17300            }
17301            depth.increment()?;
17302            let envelope_size = 8;
17303            let bytes_len = max_ordinal as usize * envelope_size;
17304            #[allow(unused_variables)]
17305            let offset = encoder.out_of_line_offset(bytes_len);
17306            let mut _prev_end_offset: usize = 0;
17307            if 1 > max_ordinal {
17308                return Ok(());
17309            }
17310
17311            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17312            // are envelope_size bytes.
17313            let cur_offset: usize = (1 - 1) * envelope_size;
17314
17315            // Zero reserved fields.
17316            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17317
17318            // Safety:
17319            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17320            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17321            //   envelope_size bytes, there is always sufficient room.
17322            fidl::encoding::encode_in_envelope_optional::<
17323                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>>,
17324                fidl::encoding::DefaultFuchsiaResourceDialect,
17325            >(
17326                self.sync.as_mut().map(
17327                    <fidl::encoding::Endpoint<
17328                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
17329                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17330                ),
17331                encoder,
17332                offset + cur_offset,
17333                depth,
17334            )?;
17335
17336            _prev_end_offset = cur_offset + envelope_size;
17337            if 2 > max_ordinal {
17338                return Ok(());
17339            }
17340
17341            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17342            // are envelope_size bytes.
17343            let cur_offset: usize = (2 - 1) * envelope_size;
17344
17345            // Zero reserved fields.
17346            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17347
17348            // Safety:
17349            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17350            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17351            //   envelope_size bytes, there is always sufficient room.
17352            fidl::encoding::encode_in_envelope_optional::<PeriodicAdvertisingSyncConfiguration, fidl::encoding::DefaultFuchsiaResourceDialect>(
17353            self.config.as_ref().map(<PeriodicAdvertisingSyncConfiguration as fidl::encoding::ValueTypeMarker>::borrow),
17354            encoder, offset + cur_offset, depth
17355        )?;
17356
17357            _prev_end_offset = cur_offset + envelope_size;
17358
17359            Ok(())
17360        }
17361    }
17362
17363    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
17364        for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest
17365    {
17366        #[inline(always)]
17367        fn new_empty() -> Self {
17368            Self::default()
17369        }
17370
17371        unsafe fn decode(
17372            &mut self,
17373            decoder: &mut fidl::encoding::Decoder<
17374                '_,
17375                fidl::encoding::DefaultFuchsiaResourceDialect,
17376            >,
17377            offset: usize,
17378            mut depth: fidl::encoding::Depth,
17379        ) -> fidl::Result<()> {
17380            decoder.debug_check_bounds::<Self>(offset);
17381            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17382                None => return Err(fidl::Error::NotNullable),
17383                Some(len) => len,
17384            };
17385            // Calling decoder.out_of_line_offset(0) is not allowed.
17386            if len == 0 {
17387                return Ok(());
17388            };
17389            depth.increment()?;
17390            let envelope_size = 8;
17391            let bytes_len = len * envelope_size;
17392            let offset = decoder.out_of_line_offset(bytes_len)?;
17393            // Decode the envelope for each type.
17394            let mut _next_ordinal_to_read = 0;
17395            let mut next_offset = offset;
17396            let end_offset = offset + bytes_len;
17397            _next_ordinal_to_read += 1;
17398            if next_offset >= end_offset {
17399                return Ok(());
17400            }
17401
17402            // Decode unknown envelopes for gaps in ordinals.
17403            while _next_ordinal_to_read < 1 {
17404                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17405                _next_ordinal_to_read += 1;
17406                next_offset += envelope_size;
17407            }
17408
17409            let next_out_of_line = decoder.next_out_of_line();
17410            let handles_before = decoder.remaining_handles();
17411            if let Some((inlined, num_bytes, num_handles)) =
17412                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17413            {
17414                let member_inline_size = <fidl::encoding::Endpoint<
17415                    fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
17416                > as fidl::encoding::TypeMarker>::inline_size(
17417                    decoder.context
17418                );
17419                if inlined != (member_inline_size <= 4) {
17420                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17421                }
17422                let inner_offset;
17423                let mut inner_depth = depth.clone();
17424                if inlined {
17425                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17426                    inner_offset = next_offset;
17427                } else {
17428                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17429                    inner_depth.increment()?;
17430                }
17431                let val_ref = self.sync.get_or_insert_with(|| {
17432                    fidl::new_empty!(
17433                        fidl::encoding::Endpoint<
17434                            fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
17435                        >,
17436                        fidl::encoding::DefaultFuchsiaResourceDialect
17437                    )
17438                });
17439                fidl::decode!(
17440                    fidl::encoding::Endpoint<
17441                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
17442                    >,
17443                    fidl::encoding::DefaultFuchsiaResourceDialect,
17444                    val_ref,
17445                    decoder,
17446                    inner_offset,
17447                    inner_depth
17448                )?;
17449                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17450                {
17451                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17452                }
17453                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17454                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17455                }
17456            }
17457
17458            next_offset += envelope_size;
17459            _next_ordinal_to_read += 1;
17460            if next_offset >= end_offset {
17461                return Ok(());
17462            }
17463
17464            // Decode unknown envelopes for gaps in ordinals.
17465            while _next_ordinal_to_read < 2 {
17466                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17467                _next_ordinal_to_read += 1;
17468                next_offset += envelope_size;
17469            }
17470
17471            let next_out_of_line = decoder.next_out_of_line();
17472            let handles_before = decoder.remaining_handles();
17473            if let Some((inlined, num_bytes, num_handles)) =
17474                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17475            {
17476                let member_inline_size = <PeriodicAdvertisingSyncConfiguration as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17477                if inlined != (member_inline_size <= 4) {
17478                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17479                }
17480                let inner_offset;
17481                let mut inner_depth = depth.clone();
17482                if inlined {
17483                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17484                    inner_offset = next_offset;
17485                } else {
17486                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17487                    inner_depth.increment()?;
17488                }
17489                let val_ref = self.config.get_or_insert_with(|| {
17490                    fidl::new_empty!(
17491                        PeriodicAdvertisingSyncConfiguration,
17492                        fidl::encoding::DefaultFuchsiaResourceDialect
17493                    )
17494                });
17495                fidl::decode!(
17496                    PeriodicAdvertisingSyncConfiguration,
17497                    fidl::encoding::DefaultFuchsiaResourceDialect,
17498                    val_ref,
17499                    decoder,
17500                    inner_offset,
17501                    inner_depth
17502                )?;
17503                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17504                {
17505                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17506                }
17507                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17508                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17509                }
17510            }
17511
17512            next_offset += envelope_size;
17513
17514            // Decode the remaining unknown envelopes.
17515            while next_offset < end_offset {
17516                _next_ordinal_to_read += 1;
17517                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17518                next_offset += envelope_size;
17519            }
17520
17521            Ok(())
17522        }
17523    }
17524
17525    impl ConnectionConnectL2capRequest {
17526        #[inline(always)]
17527        fn max_ordinal_present(&self) -> u64 {
17528            if let Some(_) = self.ext_offload {
17529                return 4;
17530            }
17531            if let Some(_) = self.psm {
17532                return 3;
17533            }
17534            if let Some(_) = self.channel {
17535                return 2;
17536            }
17537            if let Some(_) = self.parameters {
17538                return 1;
17539            }
17540            0
17541        }
17542    }
17543
17544    impl fidl::encoding::ResourceTypeMarker for ConnectionConnectL2capRequest {
17545        type Borrowed<'a> = &'a mut Self;
17546        fn take_or_borrow<'a>(
17547            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17548        ) -> Self::Borrowed<'a> {
17549            value
17550        }
17551    }
17552
17553    unsafe impl fidl::encoding::TypeMarker for ConnectionConnectL2capRequest {
17554        type Owned = Self;
17555
17556        #[inline(always)]
17557        fn inline_align(_context: fidl::encoding::Context) -> usize {
17558            8
17559        }
17560
17561        #[inline(always)]
17562        fn inline_size(_context: fidl::encoding::Context) -> usize {
17563            16
17564        }
17565    }
17566
17567    unsafe impl
17568        fidl::encoding::Encode<
17569            ConnectionConnectL2capRequest,
17570            fidl::encoding::DefaultFuchsiaResourceDialect,
17571        > for &mut ConnectionConnectL2capRequest
17572    {
17573        unsafe fn encode(
17574            self,
17575            encoder: &mut fidl::encoding::Encoder<
17576                '_,
17577                fidl::encoding::DefaultFuchsiaResourceDialect,
17578            >,
17579            offset: usize,
17580            mut depth: fidl::encoding::Depth,
17581        ) -> fidl::Result<()> {
17582            encoder.debug_check_bounds::<ConnectionConnectL2capRequest>(offset);
17583            // Vector header
17584            let max_ordinal: u64 = self.max_ordinal_present();
17585            encoder.write_num(max_ordinal, offset);
17586            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17587            // Calling encoder.out_of_line_offset(0) is not allowed.
17588            if max_ordinal == 0 {
17589                return Ok(());
17590            }
17591            depth.increment()?;
17592            let envelope_size = 8;
17593            let bytes_len = max_ordinal as usize * envelope_size;
17594            #[allow(unused_variables)]
17595            let offset = encoder.out_of_line_offset(bytes_len);
17596            let mut _prev_end_offset: usize = 0;
17597            if 1 > max_ordinal {
17598                return Ok(());
17599            }
17600
17601            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17602            // are envelope_size bytes.
17603            let cur_offset: usize = (1 - 1) * envelope_size;
17604
17605            // Zero reserved fields.
17606            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17607
17608            // Safety:
17609            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17610            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17611            //   envelope_size bytes, there is always sufficient room.
17612            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth::ChannelParameters, fidl::encoding::DefaultFuchsiaResourceDialect>(
17613            self.parameters.as_ref().map(<fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::ValueTypeMarker>::borrow),
17614            encoder, offset + cur_offset, depth
17615        )?;
17616
17617            _prev_end_offset = cur_offset + envelope_size;
17618            if 2 > max_ordinal {
17619                return Ok(());
17620            }
17621
17622            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17623            // are envelope_size bytes.
17624            let cur_offset: usize = (2 - 1) * envelope_size;
17625
17626            // Zero reserved fields.
17627            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17628
17629            // Safety:
17630            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17631            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17632            //   envelope_size bytes, there is always sufficient room.
17633            fidl::encoding::encode_in_envelope_optional::<
17634                fidl::encoding::Endpoint<
17635                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
17636                >,
17637                fidl::encoding::DefaultFuchsiaResourceDialect,
17638            >(
17639                self.channel.as_mut().map(
17640                    <fidl::encoding::Endpoint<
17641                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
17642                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17643                ),
17644                encoder,
17645                offset + cur_offset,
17646                depth,
17647            )?;
17648
17649            _prev_end_offset = cur_offset + envelope_size;
17650            if 3 > max_ordinal {
17651                return Ok(());
17652            }
17653
17654            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17655            // are envelope_size bytes.
17656            let cur_offset: usize = (3 - 1) * envelope_size;
17657
17658            // Zero reserved fields.
17659            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17660
17661            // Safety:
17662            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17663            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17664            //   envelope_size bytes, there is always sufficient room.
17665            fidl::encoding::encode_in_envelope_optional::<
17666                u16,
17667                fidl::encoding::DefaultFuchsiaResourceDialect,
17668            >(
17669                self.psm.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
17670                encoder,
17671                offset + cur_offset,
17672                depth,
17673            )?;
17674
17675            _prev_end_offset = cur_offset + envelope_size;
17676            if 4 > max_ordinal {
17677                return Ok(());
17678            }
17679
17680            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17681            // are envelope_size bytes.
17682            let cur_offset: usize = (4 - 1) * envelope_size;
17683
17684            // Zero reserved fields.
17685            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17686
17687            // Safety:
17688            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17689            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17690            //   envelope_size bytes, there is always sufficient room.
17691            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChannelOffloadExtMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
17692            self.ext_offload.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChannelOffloadExtMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
17693            encoder, offset + cur_offset, depth
17694        )?;
17695
17696            _prev_end_offset = cur_offset + envelope_size;
17697
17698            Ok(())
17699        }
17700    }
17701
17702    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
17703        for ConnectionConnectL2capRequest
17704    {
17705        #[inline(always)]
17706        fn new_empty() -> Self {
17707            Self::default()
17708        }
17709
17710        unsafe fn decode(
17711            &mut self,
17712            decoder: &mut fidl::encoding::Decoder<
17713                '_,
17714                fidl::encoding::DefaultFuchsiaResourceDialect,
17715            >,
17716            offset: usize,
17717            mut depth: fidl::encoding::Depth,
17718        ) -> fidl::Result<()> {
17719            decoder.debug_check_bounds::<Self>(offset);
17720            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17721                None => return Err(fidl::Error::NotNullable),
17722                Some(len) => len,
17723            };
17724            // Calling decoder.out_of_line_offset(0) is not allowed.
17725            if len == 0 {
17726                return Ok(());
17727            };
17728            depth.increment()?;
17729            let envelope_size = 8;
17730            let bytes_len = len * envelope_size;
17731            let offset = decoder.out_of_line_offset(bytes_len)?;
17732            // Decode the envelope for each type.
17733            let mut _next_ordinal_to_read = 0;
17734            let mut next_offset = offset;
17735            let end_offset = offset + bytes_len;
17736            _next_ordinal_to_read += 1;
17737            if next_offset >= end_offset {
17738                return Ok(());
17739            }
17740
17741            // Decode unknown envelopes for gaps in ordinals.
17742            while _next_ordinal_to_read < 1 {
17743                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17744                _next_ordinal_to_read += 1;
17745                next_offset += envelope_size;
17746            }
17747
17748            let next_out_of_line = decoder.next_out_of_line();
17749            let handles_before = decoder.remaining_handles();
17750            if let Some((inlined, num_bytes, num_handles)) =
17751                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17752            {
17753                let member_inline_size = <fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17754                if inlined != (member_inline_size <= 4) {
17755                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17756                }
17757                let inner_offset;
17758                let mut inner_depth = depth.clone();
17759                if inlined {
17760                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17761                    inner_offset = next_offset;
17762                } else {
17763                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17764                    inner_depth.increment()?;
17765                }
17766                let val_ref = self.parameters.get_or_insert_with(|| {
17767                    fidl::new_empty!(
17768                        fidl_fuchsia_bluetooth::ChannelParameters,
17769                        fidl::encoding::DefaultFuchsiaResourceDialect
17770                    )
17771                });
17772                fidl::decode!(
17773                    fidl_fuchsia_bluetooth::ChannelParameters,
17774                    fidl::encoding::DefaultFuchsiaResourceDialect,
17775                    val_ref,
17776                    decoder,
17777                    inner_offset,
17778                    inner_depth
17779                )?;
17780                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17781                {
17782                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17783                }
17784                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17785                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17786                }
17787            }
17788
17789            next_offset += envelope_size;
17790            _next_ordinal_to_read += 1;
17791            if next_offset >= end_offset {
17792                return Ok(());
17793            }
17794
17795            // Decode unknown envelopes for gaps in ordinals.
17796            while _next_ordinal_to_read < 2 {
17797                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17798                _next_ordinal_to_read += 1;
17799                next_offset += envelope_size;
17800            }
17801
17802            let next_out_of_line = decoder.next_out_of_line();
17803            let handles_before = decoder.remaining_handles();
17804            if let Some((inlined, num_bytes, num_handles)) =
17805                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17806            {
17807                let member_inline_size = <fidl::encoding::Endpoint<
17808                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
17809                > as fidl::encoding::TypeMarker>::inline_size(
17810                    decoder.context
17811                );
17812                if inlined != (member_inline_size <= 4) {
17813                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17814                }
17815                let inner_offset;
17816                let mut inner_depth = depth.clone();
17817                if inlined {
17818                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17819                    inner_offset = next_offset;
17820                } else {
17821                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17822                    inner_depth.increment()?;
17823                }
17824                let val_ref = self.channel.get_or_insert_with(|| {
17825                    fidl::new_empty!(
17826                        fidl::encoding::Endpoint<
17827                            fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
17828                        >,
17829                        fidl::encoding::DefaultFuchsiaResourceDialect
17830                    )
17831                });
17832                fidl::decode!(
17833                    fidl::encoding::Endpoint<
17834                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
17835                    >,
17836                    fidl::encoding::DefaultFuchsiaResourceDialect,
17837                    val_ref,
17838                    decoder,
17839                    inner_offset,
17840                    inner_depth
17841                )?;
17842                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17843                {
17844                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17845                }
17846                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17847                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17848                }
17849            }
17850
17851            next_offset += envelope_size;
17852            _next_ordinal_to_read += 1;
17853            if next_offset >= end_offset {
17854                return Ok(());
17855            }
17856
17857            // Decode unknown envelopes for gaps in ordinals.
17858            while _next_ordinal_to_read < 3 {
17859                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17860                _next_ordinal_to_read += 1;
17861                next_offset += envelope_size;
17862            }
17863
17864            let next_out_of_line = decoder.next_out_of_line();
17865            let handles_before = decoder.remaining_handles();
17866            if let Some((inlined, num_bytes, num_handles)) =
17867                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17868            {
17869                let member_inline_size =
17870                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17871                if inlined != (member_inline_size <= 4) {
17872                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17873                }
17874                let inner_offset;
17875                let mut inner_depth = depth.clone();
17876                if inlined {
17877                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17878                    inner_offset = next_offset;
17879                } else {
17880                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17881                    inner_depth.increment()?;
17882                }
17883                let val_ref = self.psm.get_or_insert_with(|| {
17884                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
17885                });
17886                fidl::decode!(
17887                    u16,
17888                    fidl::encoding::DefaultFuchsiaResourceDialect,
17889                    val_ref,
17890                    decoder,
17891                    inner_offset,
17892                    inner_depth
17893                )?;
17894                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17895                {
17896                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17897                }
17898                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17899                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17900                }
17901            }
17902
17903            next_offset += envelope_size;
17904            _next_ordinal_to_read += 1;
17905            if next_offset >= end_offset {
17906                return Ok(());
17907            }
17908
17909            // Decode unknown envelopes for gaps in ordinals.
17910            while _next_ordinal_to_read < 4 {
17911                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17912                _next_ordinal_to_read += 1;
17913                next_offset += envelope_size;
17914            }
17915
17916            let next_out_of_line = decoder.next_out_of_line();
17917            let handles_before = decoder.remaining_handles();
17918            if let Some((inlined, num_bytes, num_handles)) =
17919                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17920            {
17921                let member_inline_size = <fidl::encoding::Endpoint<
17922                    fidl::endpoints::ServerEnd<ChannelOffloadExtMarker>,
17923                > as fidl::encoding::TypeMarker>::inline_size(
17924                    decoder.context
17925                );
17926                if inlined != (member_inline_size <= 4) {
17927                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17928                }
17929                let inner_offset;
17930                let mut inner_depth = depth.clone();
17931                if inlined {
17932                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17933                    inner_offset = next_offset;
17934                } else {
17935                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17936                    inner_depth.increment()?;
17937                }
17938                let val_ref = self.ext_offload.get_or_insert_with(|| {
17939                    fidl::new_empty!(
17940                        fidl::encoding::Endpoint<
17941                            fidl::endpoints::ServerEnd<ChannelOffloadExtMarker>,
17942                        >,
17943                        fidl::encoding::DefaultFuchsiaResourceDialect
17944                    )
17945                });
17946                fidl::decode!(
17947                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChannelOffloadExtMarker>>,
17948                    fidl::encoding::DefaultFuchsiaResourceDialect,
17949                    val_ref,
17950                    decoder,
17951                    inner_offset,
17952                    inner_depth
17953                )?;
17954                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17955                {
17956                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17957                }
17958                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17959                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17960                }
17961            }
17962
17963            next_offset += envelope_size;
17964
17965            // Decode the remaining unknown envelopes.
17966            while next_offset < end_offset {
17967                _next_ordinal_to_read += 1;
17968                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17969                next_offset += envelope_size;
17970            }
17971
17972            Ok(())
17973        }
17974    }
17975}