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 ChannelListenerRegistryListenL2capRequest {
150    /// Accepted parameters for the local side of the channel.
151    pub parameters: Option<AcceptedChannelParameters>,
152    /// The channel listener protocol to open.
153    pub listener: Option<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
154    #[doc(hidden)]
155    pub __source_breaking: fidl::marker::SourceBreaking,
156}
157
158impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
159    for ChannelListenerRegistryListenL2capRequest
160{
161}
162
163#[derive(Debug, Default, PartialEq)]
164pub struct CisRequestedParameters {
165    /// ID selected to uniquely identify a stream within a CIG. All `cis_id`s
166    /// must be distinct within a single creation request.
167    /// Required.
168    pub cis_id: Option<u8>,
169    /// The channel that will be used for operations on the stream.
170    /// Required.
171    pub connection_stream: Option<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
172    /// Maximum SDU size (central => peripheral). This is a function of the
173    /// codec being used. Unidirectional streams should set the unused
174    /// direction to 0.
175    /// Optional. If not provided, a value of 0 will be used (unidirectional)
176    pub max_sdu_size_outgoing: Option<u16>,
177    /// Maximum SDU size (peripheral => central). This is a function of the
178    /// codec being used. Unidirectional streams should set the unused
179    /// direction to 0.
180    /// Optional. If not provided, a value of 0 will be used (unidirectional)
181    pub max_sdu_size_incoming: Option<u16>,
182    #[doc(hidden)]
183    pub __source_breaking: fidl::marker::SourceBreaking,
184}
185
186impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CisRequestedParameters {}
187
188#[derive(Debug, Default, PartialEq)]
189pub struct ConnectionAcceptCisRequest {
190    /// Identifier of the CIG that contains the requested CIS. Required.
191    pub cig_id: Option<u8>,
192    /// Identifier of the requested CIS. Required.
193    pub cis_id: Option<u8>,
194    /// When the stream is established, the server will invoke
195    /// IsochronousStream::OnCisEstablished() on this channel. Required.
196    ///
197    /// If the client end of this channel is closed, requests of the corresponding CIG/CIS
198    /// combination will be rejected until/unless another call is made to AcceptCis() with
199    /// the same CIG/CIS parameters.
200    pub connection_stream: Option<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
201    #[doc(hidden)]
202    pub __source_breaking: fidl::marker::SourceBreaking,
203}
204
205impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
206    for ConnectionAcceptCisRequest
207{
208}
209
210#[derive(Debug, Default, PartialEq)]
211pub struct ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
212    /// When the sync is established, the `PeriodicAdvertisingSync.OnEstablished` event will be
213    /// sent containing the service data received with the transfer. Closing the client end will
214    /// cancel the transfer.
215    pub sync: Option<fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>>,
216    pub config: Option<PeriodicAdvertisingSyncConfiguration>,
217    #[doc(hidden)]
218    pub __source_breaking: fidl::marker::SourceBreaking,
219}
220
221impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
222    for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest
223{
224}
225
226#[derive(Debug, Default, PartialEq)]
227pub struct ConnectionConnectL2capRequest {
228    /// Parameters for the local side of the channel.
229    pub parameters: Option<fidl_fuchsia_bluetooth::ChannelParameters>,
230    /// The channel protocol to open.
231    pub channel: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>>,
232    /// The PSM of the remote side to connect to.
233    pub psm: Option<u16>,
234    #[doc(hidden)]
235    pub __source_breaking: fidl::marker::SourceBreaking,
236}
237
238impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
239    for ConnectionConnectL2capRequest
240{
241}
242
243#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
244pub struct AdvertisedPeripheralMarker;
245
246impl fidl::endpoints::ProtocolMarker for AdvertisedPeripheralMarker {
247    type Proxy = AdvertisedPeripheralProxy;
248    type RequestStream = AdvertisedPeripheralRequestStream;
249    #[cfg(target_os = "fuchsia")]
250    type SynchronousProxy = AdvertisedPeripheralSynchronousProxy;
251
252    const DEBUG_NAME: &'static str = "(anonymous) AdvertisedPeripheral";
253}
254
255pub trait AdvertisedPeripheralProxyInterface: Send + Sync {
256    type OnConnectedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
257    fn r#on_connected(
258        &self,
259        peer: &Peer,
260        connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
261    ) -> Self::OnConnectedResponseFut;
262}
263#[derive(Debug)]
264#[cfg(target_os = "fuchsia")]
265pub struct AdvertisedPeripheralSynchronousProxy {
266    client: fidl::client::sync::Client,
267}
268
269#[cfg(target_os = "fuchsia")]
270impl fidl::endpoints::SynchronousProxy for AdvertisedPeripheralSynchronousProxy {
271    type Proxy = AdvertisedPeripheralProxy;
272    type Protocol = AdvertisedPeripheralMarker;
273
274    fn from_channel(inner: fidl::Channel) -> Self {
275        Self::new(inner)
276    }
277
278    fn into_channel(self) -> fidl::Channel {
279        self.client.into_channel()
280    }
281
282    fn as_channel(&self) -> &fidl::Channel {
283        self.client.as_channel()
284    }
285}
286
287#[cfg(target_os = "fuchsia")]
288impl AdvertisedPeripheralSynchronousProxy {
289    pub fn new(channel: fidl::Channel) -> Self {
290        let protocol_name =
291            <AdvertisedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
292        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
293    }
294
295    pub fn into_channel(self) -> fidl::Channel {
296        self.client.into_channel()
297    }
298
299    /// Waits until an event arrives and returns it. It is safe for other
300    /// threads to make concurrent requests while waiting for an event.
301    pub fn wait_for_event(
302        &self,
303        deadline: zx::MonotonicInstant,
304    ) -> Result<AdvertisedPeripheralEvent, fidl::Error> {
305        AdvertisedPeripheralEvent::decode(self.client.wait_for_event(deadline)?)
306    }
307
308    /// Called when a remote LE central connects to this peripheral when
309    /// connectable advertising is enabled via
310    /// [`fuchsia.bluetooth.le/Peripheral.Advertise`]. When this call is made,
311    /// the system has paused advertising, and will not continue until it
312    /// receives a response.
313    ///
314    /// The returned [`fuchsia.bluetooth.le/Connection`] protocol can be used to
315    /// interact with the peer. It also represents a peripheral's ownership over
316    /// the connection: the client can drop the protocol to request a
317    /// disconnection. Similarly, the protocol is closed by the system to
318    /// indicate that the connection to the peer has been lost.
319    ///
320    /// + request `peer` Information about the central that initiated the
321    ///   connection.
322    /// + request `connection` Represents the connection.
323    /// - response An empty response should be sent to acknowledge the
324    ///   connection and resume advertising (for flow control).
325    pub fn r#on_connected(
326        &self,
327        mut peer: &Peer,
328        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
329        ___deadline: zx::MonotonicInstant,
330    ) -> Result<(), fidl::Error> {
331        let _response = self
332            .client
333            .send_query::<AdvertisedPeripheralOnConnectedRequest, fidl::encoding::EmptyPayload>(
334                (peer, connection),
335                0x607b7716457eb178,
336                fidl::encoding::DynamicFlags::empty(),
337                ___deadline,
338            )?;
339        Ok(_response)
340    }
341}
342
343#[cfg(target_os = "fuchsia")]
344impl From<AdvertisedPeripheralSynchronousProxy> for zx::Handle {
345    fn from(value: AdvertisedPeripheralSynchronousProxy) -> Self {
346        value.into_channel().into()
347    }
348}
349
350#[cfg(target_os = "fuchsia")]
351impl From<fidl::Channel> for AdvertisedPeripheralSynchronousProxy {
352    fn from(value: fidl::Channel) -> Self {
353        Self::new(value)
354    }
355}
356
357#[cfg(target_os = "fuchsia")]
358impl fidl::endpoints::FromClient for AdvertisedPeripheralSynchronousProxy {
359    type Protocol = AdvertisedPeripheralMarker;
360
361    fn from_client(value: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>) -> Self {
362        Self::new(value.into_channel())
363    }
364}
365
366#[derive(Debug, Clone)]
367pub struct AdvertisedPeripheralProxy {
368    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
369}
370
371impl fidl::endpoints::Proxy for AdvertisedPeripheralProxy {
372    type Protocol = AdvertisedPeripheralMarker;
373
374    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
375        Self::new(inner)
376    }
377
378    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
379        self.client.into_channel().map_err(|client| Self { client })
380    }
381
382    fn as_channel(&self) -> &::fidl::AsyncChannel {
383        self.client.as_channel()
384    }
385}
386
387impl AdvertisedPeripheralProxy {
388    /// Create a new Proxy for fuchsia.bluetooth.le/AdvertisedPeripheral.
389    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
390        let protocol_name =
391            <AdvertisedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
392        Self { client: fidl::client::Client::new(channel, protocol_name) }
393    }
394
395    /// Get a Stream of events from the remote end of the protocol.
396    ///
397    /// # Panics
398    ///
399    /// Panics if the event stream was already taken.
400    pub fn take_event_stream(&self) -> AdvertisedPeripheralEventStream {
401        AdvertisedPeripheralEventStream { event_receiver: self.client.take_event_receiver() }
402    }
403
404    /// Called when a remote LE central connects to this peripheral when
405    /// connectable advertising is enabled via
406    /// [`fuchsia.bluetooth.le/Peripheral.Advertise`]. When this call is made,
407    /// the system has paused advertising, and will not continue until it
408    /// receives a response.
409    ///
410    /// The returned [`fuchsia.bluetooth.le/Connection`] protocol can be used to
411    /// interact with the peer. It also represents a peripheral's ownership over
412    /// the connection: the client can drop the protocol to request a
413    /// disconnection. Similarly, the protocol is closed by the system to
414    /// indicate that the connection to the peer has been lost.
415    ///
416    /// + request `peer` Information about the central that initiated the
417    ///   connection.
418    /// + request `connection` Represents the connection.
419    /// - response An empty response should be sent to acknowledge the
420    ///   connection and resume advertising (for flow control).
421    pub fn r#on_connected(
422        &self,
423        mut peer: &Peer,
424        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
425    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
426        AdvertisedPeripheralProxyInterface::r#on_connected(self, peer, connection)
427    }
428}
429
430impl AdvertisedPeripheralProxyInterface for AdvertisedPeripheralProxy {
431    type OnConnectedResponseFut =
432        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
433    fn r#on_connected(
434        &self,
435        mut peer: &Peer,
436        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
437    ) -> Self::OnConnectedResponseFut {
438        fn _decode(
439            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
440        ) -> Result<(), fidl::Error> {
441            let _response = fidl::client::decode_transaction_body::<
442                fidl::encoding::EmptyPayload,
443                fidl::encoding::DefaultFuchsiaResourceDialect,
444                0x607b7716457eb178,
445            >(_buf?)?;
446            Ok(_response)
447        }
448        self.client.send_query_and_decode::<AdvertisedPeripheralOnConnectedRequest, ()>(
449            (peer, connection),
450            0x607b7716457eb178,
451            fidl::encoding::DynamicFlags::empty(),
452            _decode,
453        )
454    }
455}
456
457pub struct AdvertisedPeripheralEventStream {
458    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
459}
460
461impl std::marker::Unpin for AdvertisedPeripheralEventStream {}
462
463impl futures::stream::FusedStream for AdvertisedPeripheralEventStream {
464    fn is_terminated(&self) -> bool {
465        self.event_receiver.is_terminated()
466    }
467}
468
469impl futures::Stream for AdvertisedPeripheralEventStream {
470    type Item = Result<AdvertisedPeripheralEvent, fidl::Error>;
471
472    fn poll_next(
473        mut self: std::pin::Pin<&mut Self>,
474        cx: &mut std::task::Context<'_>,
475    ) -> std::task::Poll<Option<Self::Item>> {
476        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
477            &mut self.event_receiver,
478            cx
479        )?) {
480            Some(buf) => std::task::Poll::Ready(Some(AdvertisedPeripheralEvent::decode(buf))),
481            None => std::task::Poll::Ready(None),
482        }
483    }
484}
485
486#[derive(Debug)]
487pub enum AdvertisedPeripheralEvent {}
488
489impl AdvertisedPeripheralEvent {
490    /// Decodes a message buffer as a [`AdvertisedPeripheralEvent`].
491    fn decode(
492        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
493    ) -> Result<AdvertisedPeripheralEvent, fidl::Error> {
494        let (bytes, _handles) = buf.split_mut();
495        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
496        debug_assert_eq!(tx_header.tx_id, 0);
497        match tx_header.ordinal {
498            _ => Err(fidl::Error::UnknownOrdinal {
499                ordinal: tx_header.ordinal,
500                protocol_name:
501                    <AdvertisedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
502            }),
503        }
504    }
505}
506
507/// A Stream of incoming requests for fuchsia.bluetooth.le/AdvertisedPeripheral.
508pub struct AdvertisedPeripheralRequestStream {
509    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
510    is_terminated: bool,
511}
512
513impl std::marker::Unpin for AdvertisedPeripheralRequestStream {}
514
515impl futures::stream::FusedStream for AdvertisedPeripheralRequestStream {
516    fn is_terminated(&self) -> bool {
517        self.is_terminated
518    }
519}
520
521impl fidl::endpoints::RequestStream for AdvertisedPeripheralRequestStream {
522    type Protocol = AdvertisedPeripheralMarker;
523    type ControlHandle = AdvertisedPeripheralControlHandle;
524
525    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
526        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
527    }
528
529    fn control_handle(&self) -> Self::ControlHandle {
530        AdvertisedPeripheralControlHandle { inner: self.inner.clone() }
531    }
532
533    fn into_inner(
534        self,
535    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
536    {
537        (self.inner, self.is_terminated)
538    }
539
540    fn from_inner(
541        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
542        is_terminated: bool,
543    ) -> Self {
544        Self { inner, is_terminated }
545    }
546}
547
548impl futures::Stream for AdvertisedPeripheralRequestStream {
549    type Item = Result<AdvertisedPeripheralRequest, fidl::Error>;
550
551    fn poll_next(
552        mut self: std::pin::Pin<&mut Self>,
553        cx: &mut std::task::Context<'_>,
554    ) -> std::task::Poll<Option<Self::Item>> {
555        let this = &mut *self;
556        if this.inner.check_shutdown(cx) {
557            this.is_terminated = true;
558            return std::task::Poll::Ready(None);
559        }
560        if this.is_terminated {
561            panic!("polled AdvertisedPeripheralRequestStream after completion");
562        }
563        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
564            |bytes, handles| {
565                match this.inner.channel().read_etc(cx, bytes, handles) {
566                    std::task::Poll::Ready(Ok(())) => {}
567                    std::task::Poll::Pending => return std::task::Poll::Pending,
568                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
569                        this.is_terminated = true;
570                        return std::task::Poll::Ready(None);
571                    }
572                    std::task::Poll::Ready(Err(e)) => {
573                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
574                            e.into(),
575                        ))));
576                    }
577                }
578
579                // A message has been received from the channel
580                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
581
582                std::task::Poll::Ready(Some(match header.ordinal {
583                0x607b7716457eb178 => {
584                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
585                    let mut req = fidl::new_empty!(AdvertisedPeripheralOnConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
586                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AdvertisedPeripheralOnConnectedRequest>(&header, _body_bytes, handles, &mut req)?;
587                    let control_handle = AdvertisedPeripheralControlHandle {
588                        inner: this.inner.clone(),
589                    };
590                    Ok(AdvertisedPeripheralRequest::OnConnected {peer: req.peer,
591connection: req.connection,
592
593                        responder: AdvertisedPeripheralOnConnectedResponder {
594                            control_handle: std::mem::ManuallyDrop::new(control_handle),
595                            tx_id: header.tx_id,
596                        },
597                    })
598                }
599                _ => Err(fidl::Error::UnknownOrdinal {
600                    ordinal: header.ordinal,
601                    protocol_name: <AdvertisedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
602                }),
603            }))
604            },
605        )
606    }
607}
608
609/// Protocol that is valid for the duration of advertising. The caller can close
610/// the protocol to stop advertising. If the system internally stops advertising
611/// for any reason, the protocol will be closed to communicate this to the
612/// client.
613#[derive(Debug)]
614pub enum AdvertisedPeripheralRequest {
615    /// Called when a remote LE central connects to this peripheral when
616    /// connectable advertising is enabled via
617    /// [`fuchsia.bluetooth.le/Peripheral.Advertise`]. When this call is made,
618    /// the system has paused advertising, and will not continue until it
619    /// receives a response.
620    ///
621    /// The returned [`fuchsia.bluetooth.le/Connection`] protocol can be used to
622    /// interact with the peer. It also represents a peripheral's ownership over
623    /// the connection: the client can drop the protocol to request a
624    /// disconnection. Similarly, the protocol is closed by the system to
625    /// indicate that the connection to the peer has been lost.
626    ///
627    /// + request `peer` Information about the central that initiated the
628    ///   connection.
629    /// + request `connection` Represents the connection.
630    /// - response An empty response should be sent to acknowledge the
631    ///   connection and resume advertising (for flow control).
632    OnConnected {
633        peer: Peer,
634        connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
635        responder: AdvertisedPeripheralOnConnectedResponder,
636    },
637}
638
639impl AdvertisedPeripheralRequest {
640    #[allow(irrefutable_let_patterns)]
641    pub fn into_on_connected(
642        self,
643    ) -> Option<(
644        Peer,
645        fidl::endpoints::ClientEnd<ConnectionMarker>,
646        AdvertisedPeripheralOnConnectedResponder,
647    )> {
648        if let AdvertisedPeripheralRequest::OnConnected { peer, connection, responder } = self {
649            Some((peer, connection, responder))
650        } else {
651            None
652        }
653    }
654
655    /// Name of the method defined in FIDL
656    pub fn method_name(&self) -> &'static str {
657        match *self {
658            AdvertisedPeripheralRequest::OnConnected { .. } => "on_connected",
659        }
660    }
661}
662
663#[derive(Debug, Clone)]
664pub struct AdvertisedPeripheralControlHandle {
665    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
666}
667
668impl fidl::endpoints::ControlHandle for AdvertisedPeripheralControlHandle {
669    fn shutdown(&self) {
670        self.inner.shutdown()
671    }
672    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
673        self.inner.shutdown_with_epitaph(status)
674    }
675
676    fn is_closed(&self) -> bool {
677        self.inner.channel().is_closed()
678    }
679    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
680        self.inner.channel().on_closed()
681    }
682
683    #[cfg(target_os = "fuchsia")]
684    fn signal_peer(
685        &self,
686        clear_mask: zx::Signals,
687        set_mask: zx::Signals,
688    ) -> Result<(), zx_status::Status> {
689        use fidl::Peered;
690        self.inner.channel().signal_peer(clear_mask, set_mask)
691    }
692}
693
694impl AdvertisedPeripheralControlHandle {}
695
696#[must_use = "FIDL methods require a response to be sent"]
697#[derive(Debug)]
698pub struct AdvertisedPeripheralOnConnectedResponder {
699    control_handle: std::mem::ManuallyDrop<AdvertisedPeripheralControlHandle>,
700    tx_id: u32,
701}
702
703/// Set the the channel to be shutdown (see [`AdvertisedPeripheralControlHandle::shutdown`])
704/// if the responder is dropped without sending a response, so that the client
705/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
706impl std::ops::Drop for AdvertisedPeripheralOnConnectedResponder {
707    fn drop(&mut self) {
708        self.control_handle.shutdown();
709        // Safety: drops once, never accessed again
710        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
711    }
712}
713
714impl fidl::endpoints::Responder for AdvertisedPeripheralOnConnectedResponder {
715    type ControlHandle = AdvertisedPeripheralControlHandle;
716
717    fn control_handle(&self) -> &AdvertisedPeripheralControlHandle {
718        &self.control_handle
719    }
720
721    fn drop_without_shutdown(mut self) {
722        // Safety: drops once, never accessed again due to mem::forget
723        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
724        // Prevent Drop from running (which would shut down the channel)
725        std::mem::forget(self);
726    }
727}
728
729impl AdvertisedPeripheralOnConnectedResponder {
730    /// Sends a response to the FIDL transaction.
731    ///
732    /// Sets the channel to shutdown if an error occurs.
733    pub fn send(self) -> Result<(), fidl::Error> {
734        let _result = self.send_raw();
735        if _result.is_err() {
736            self.control_handle.shutdown();
737        }
738        self.drop_without_shutdown();
739        _result
740    }
741
742    /// Similar to "send" but does not shutdown the channel if an error occurs.
743    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
744        let _result = self.send_raw();
745        self.drop_without_shutdown();
746        _result
747    }
748
749    fn send_raw(&self) -> Result<(), fidl::Error> {
750        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
751            (),
752            self.tx_id,
753            0x607b7716457eb178,
754            fidl::encoding::DynamicFlags::empty(),
755        )
756    }
757}
758
759#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
760pub struct AdvertisingHandleMarker;
761
762impl fidl::endpoints::ProtocolMarker for AdvertisingHandleMarker {
763    type Proxy = AdvertisingHandleProxy;
764    type RequestStream = AdvertisingHandleRequestStream;
765    #[cfg(target_os = "fuchsia")]
766    type SynchronousProxy = AdvertisingHandleSynchronousProxy;
767
768    const DEBUG_NAME: &'static str = "(anonymous) AdvertisingHandle";
769}
770
771pub trait AdvertisingHandleProxyInterface: Send + Sync {}
772#[derive(Debug)]
773#[cfg(target_os = "fuchsia")]
774pub struct AdvertisingHandleSynchronousProxy {
775    client: fidl::client::sync::Client,
776}
777
778#[cfg(target_os = "fuchsia")]
779impl fidl::endpoints::SynchronousProxy for AdvertisingHandleSynchronousProxy {
780    type Proxy = AdvertisingHandleProxy;
781    type Protocol = AdvertisingHandleMarker;
782
783    fn from_channel(inner: fidl::Channel) -> Self {
784        Self::new(inner)
785    }
786
787    fn into_channel(self) -> fidl::Channel {
788        self.client.into_channel()
789    }
790
791    fn as_channel(&self) -> &fidl::Channel {
792        self.client.as_channel()
793    }
794}
795
796#[cfg(target_os = "fuchsia")]
797impl AdvertisingHandleSynchronousProxy {
798    pub fn new(channel: fidl::Channel) -> Self {
799        let protocol_name =
800            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
801        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
802    }
803
804    pub fn into_channel(self) -> fidl::Channel {
805        self.client.into_channel()
806    }
807
808    /// Waits until an event arrives and returns it. It is safe for other
809    /// threads to make concurrent requests while waiting for an event.
810    pub fn wait_for_event(
811        &self,
812        deadline: zx::MonotonicInstant,
813    ) -> Result<AdvertisingHandleEvent, fidl::Error> {
814        AdvertisingHandleEvent::decode(self.client.wait_for_event(deadline)?)
815    }
816}
817
818#[cfg(target_os = "fuchsia")]
819impl From<AdvertisingHandleSynchronousProxy> for zx::Handle {
820    fn from(value: AdvertisingHandleSynchronousProxy) -> Self {
821        value.into_channel().into()
822    }
823}
824
825#[cfg(target_os = "fuchsia")]
826impl From<fidl::Channel> for AdvertisingHandleSynchronousProxy {
827    fn from(value: fidl::Channel) -> Self {
828        Self::new(value)
829    }
830}
831
832#[cfg(target_os = "fuchsia")]
833impl fidl::endpoints::FromClient for AdvertisingHandleSynchronousProxy {
834    type Protocol = AdvertisingHandleMarker;
835
836    fn from_client(value: fidl::endpoints::ClientEnd<AdvertisingHandleMarker>) -> Self {
837        Self::new(value.into_channel())
838    }
839}
840
841#[derive(Debug, Clone)]
842pub struct AdvertisingHandleProxy {
843    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
844}
845
846impl fidl::endpoints::Proxy for AdvertisingHandleProxy {
847    type Protocol = AdvertisingHandleMarker;
848
849    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
850        Self::new(inner)
851    }
852
853    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
854        self.client.into_channel().map_err(|client| Self { client })
855    }
856
857    fn as_channel(&self) -> &::fidl::AsyncChannel {
858        self.client.as_channel()
859    }
860}
861
862impl AdvertisingHandleProxy {
863    /// Create a new Proxy for fuchsia.bluetooth.le/AdvertisingHandle.
864    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
865        let protocol_name =
866            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
867        Self { client: fidl::client::Client::new(channel, protocol_name) }
868    }
869
870    /// Get a Stream of events from the remote end of the protocol.
871    ///
872    /// # Panics
873    ///
874    /// Panics if the event stream was already taken.
875    pub fn take_event_stream(&self) -> AdvertisingHandleEventStream {
876        AdvertisingHandleEventStream { event_receiver: self.client.take_event_receiver() }
877    }
878}
879
880impl AdvertisingHandleProxyInterface for AdvertisingHandleProxy {}
881
882pub struct AdvertisingHandleEventStream {
883    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
884}
885
886impl std::marker::Unpin for AdvertisingHandleEventStream {}
887
888impl futures::stream::FusedStream for AdvertisingHandleEventStream {
889    fn is_terminated(&self) -> bool {
890        self.event_receiver.is_terminated()
891    }
892}
893
894impl futures::Stream for AdvertisingHandleEventStream {
895    type Item = Result<AdvertisingHandleEvent, fidl::Error>;
896
897    fn poll_next(
898        mut self: std::pin::Pin<&mut Self>,
899        cx: &mut std::task::Context<'_>,
900    ) -> std::task::Poll<Option<Self::Item>> {
901        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
902            &mut self.event_receiver,
903            cx
904        )?) {
905            Some(buf) => std::task::Poll::Ready(Some(AdvertisingHandleEvent::decode(buf))),
906            None => std::task::Poll::Ready(None),
907        }
908    }
909}
910
911#[derive(Debug)]
912pub enum AdvertisingHandleEvent {}
913
914impl AdvertisingHandleEvent {
915    /// Decodes a message buffer as a [`AdvertisingHandleEvent`].
916    fn decode(
917        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
918    ) -> Result<AdvertisingHandleEvent, fidl::Error> {
919        let (bytes, _handles) = buf.split_mut();
920        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
921        debug_assert_eq!(tx_header.tx_id, 0);
922        match tx_header.ordinal {
923            _ => Err(fidl::Error::UnknownOrdinal {
924                ordinal: tx_header.ordinal,
925                protocol_name:
926                    <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
927            }),
928        }
929    }
930}
931
932/// A Stream of incoming requests for fuchsia.bluetooth.le/AdvertisingHandle.
933pub struct AdvertisingHandleRequestStream {
934    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
935    is_terminated: bool,
936}
937
938impl std::marker::Unpin for AdvertisingHandleRequestStream {}
939
940impl futures::stream::FusedStream for AdvertisingHandleRequestStream {
941    fn is_terminated(&self) -> bool {
942        self.is_terminated
943    }
944}
945
946impl fidl::endpoints::RequestStream for AdvertisingHandleRequestStream {
947    type Protocol = AdvertisingHandleMarker;
948    type ControlHandle = AdvertisingHandleControlHandle;
949
950    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
951        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
952    }
953
954    fn control_handle(&self) -> Self::ControlHandle {
955        AdvertisingHandleControlHandle { inner: self.inner.clone() }
956    }
957
958    fn into_inner(
959        self,
960    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
961    {
962        (self.inner, self.is_terminated)
963    }
964
965    fn from_inner(
966        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
967        is_terminated: bool,
968    ) -> Self {
969        Self { inner, is_terminated }
970    }
971}
972
973impl futures::Stream for AdvertisingHandleRequestStream {
974    type Item = Result<AdvertisingHandleRequest, fidl::Error>;
975
976    fn poll_next(
977        mut self: std::pin::Pin<&mut Self>,
978        cx: &mut std::task::Context<'_>,
979    ) -> std::task::Poll<Option<Self::Item>> {
980        let this = &mut *self;
981        if this.inner.check_shutdown(cx) {
982            this.is_terminated = true;
983            return std::task::Poll::Ready(None);
984        }
985        if this.is_terminated {
986            panic!("polled AdvertisingHandleRequestStream after completion");
987        }
988        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
989            |bytes, handles| {
990                match this.inner.channel().read_etc(cx, bytes, handles) {
991                    std::task::Poll::Ready(Ok(())) => {}
992                    std::task::Poll::Pending => return std::task::Poll::Pending,
993                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
994                        this.is_terminated = true;
995                        return std::task::Poll::Ready(None);
996                    }
997                    std::task::Poll::Ready(Err(e)) => {
998                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
999                            e.into(),
1000                        ))));
1001                    }
1002                }
1003
1004                // A message has been received from the channel
1005                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1006
1007                std::task::Poll::Ready(Some(match header.ordinal {
1008                    _ => Err(fidl::Error::UnknownOrdinal {
1009                        ordinal: header.ordinal,
1010                        protocol_name:
1011                            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1012                    }),
1013                }))
1014            },
1015        )
1016    }
1017}
1018
1019/// Capability that is valid for the duration of advertising. The caller can close the handle to
1020/// stop advertising. If the system internally stops advertising for any reason, the handle will be
1021/// closed to communicate this to the client.
1022#[derive(Debug)]
1023pub enum AdvertisingHandleRequest {}
1024
1025impl AdvertisingHandleRequest {
1026    /// Name of the method defined in FIDL
1027    pub fn method_name(&self) -> &'static str {
1028        match *self {}
1029    }
1030}
1031
1032#[derive(Debug, Clone)]
1033pub struct AdvertisingHandleControlHandle {
1034    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1035}
1036
1037impl fidl::endpoints::ControlHandle for AdvertisingHandleControlHandle {
1038    fn shutdown(&self) {
1039        self.inner.shutdown()
1040    }
1041    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1042        self.inner.shutdown_with_epitaph(status)
1043    }
1044
1045    fn is_closed(&self) -> bool {
1046        self.inner.channel().is_closed()
1047    }
1048    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1049        self.inner.channel().on_closed()
1050    }
1051
1052    #[cfg(target_os = "fuchsia")]
1053    fn signal_peer(
1054        &self,
1055        clear_mask: zx::Signals,
1056        set_mask: zx::Signals,
1057    ) -> Result<(), zx_status::Status> {
1058        use fidl::Peered;
1059        self.inner.channel().signal_peer(clear_mask, set_mask)
1060    }
1061}
1062
1063impl AdvertisingHandleControlHandle {}
1064
1065#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1066pub struct CentralMarker;
1067
1068impl fidl::endpoints::ProtocolMarker for CentralMarker {
1069    type Proxy = CentralProxy;
1070    type RequestStream = CentralRequestStream;
1071    #[cfg(target_os = "fuchsia")]
1072    type SynchronousProxy = CentralSynchronousProxy;
1073
1074    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.Central";
1075}
1076impl fidl::endpoints::DiscoverableProtocolMarker for CentralMarker {}
1077pub type CentralCreateConnectedIsochronousGroupResult =
1078    Result<CentralCreateConnectedIsochronousGroupResponse, CreateCigError>;
1079
1080pub trait CentralProxyInterface: Send + Sync {
1081    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
1082        + Send;
1083    fn r#listen_l2cap(
1084        &self,
1085        payload: ChannelListenerRegistryListenL2capRequest,
1086    ) -> Self::ListenL2capResponseFut;
1087    type ScanResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1088    fn r#scan(
1089        &self,
1090        options: &ScanOptions,
1091        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1092    ) -> Self::ScanResponseFut;
1093    fn r#connect(
1094        &self,
1095        id: &fidl_fuchsia_bluetooth::PeerId,
1096        options: &ConnectionOptions,
1097        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1098    ) -> Result<(), fidl::Error>;
1099    fn r#sync_to_periodic_advertising(
1100        &self,
1101        payload: CentralSyncToPeriodicAdvertisingRequest,
1102    ) -> Result<(), fidl::Error>;
1103    type CreateConnectedIsochronousGroupResponseFut: std::future::Future<
1104            Output = Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error>,
1105        > + Send;
1106    fn r#create_connected_isochronous_group(
1107        &self,
1108        payload: CentralCreateConnectedIsochronousGroupRequest,
1109    ) -> Self::CreateConnectedIsochronousGroupResponseFut;
1110    type GetPeripheralsResponseFut: std::future::Future<Output = Result<Vec<RemoteDevice>, fidl::Error>>
1111        + Send;
1112    fn r#get_peripherals(
1113        &self,
1114        service_uuids: Option<&[String]>,
1115    ) -> Self::GetPeripheralsResponseFut;
1116    type GetPeripheralResponseFut: std::future::Future<Output = Result<Option<Box<RemoteDevice>>, fidl::Error>>
1117        + Send;
1118    fn r#get_peripheral(&self, identifier: &str) -> Self::GetPeripheralResponseFut;
1119    type StartScanResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1120        + Send;
1121    fn r#start_scan(&self, filter: Option<&ScanFilter>) -> Self::StartScanResponseFut;
1122    fn r#stop_scan(&self) -> Result<(), fidl::Error>;
1123    type ConnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1124        + Send;
1125    fn r#connect_peripheral(
1126        &self,
1127        identifier: &str,
1128        options: &ConnectionOptions,
1129        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1130    ) -> Self::ConnectPeripheralResponseFut;
1131    type DisconnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1132        + Send;
1133    fn r#disconnect_peripheral(&self, identifier: &str) -> Self::DisconnectPeripheralResponseFut;
1134}
1135#[derive(Debug)]
1136#[cfg(target_os = "fuchsia")]
1137pub struct CentralSynchronousProxy {
1138    client: fidl::client::sync::Client,
1139}
1140
1141#[cfg(target_os = "fuchsia")]
1142impl fidl::endpoints::SynchronousProxy for CentralSynchronousProxy {
1143    type Proxy = CentralProxy;
1144    type Protocol = CentralMarker;
1145
1146    fn from_channel(inner: fidl::Channel) -> Self {
1147        Self::new(inner)
1148    }
1149
1150    fn into_channel(self) -> fidl::Channel {
1151        self.client.into_channel()
1152    }
1153
1154    fn as_channel(&self) -> &fidl::Channel {
1155        self.client.as_channel()
1156    }
1157}
1158
1159#[cfg(target_os = "fuchsia")]
1160impl CentralSynchronousProxy {
1161    pub fn new(channel: fidl::Channel) -> Self {
1162        let protocol_name = <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1163        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1164    }
1165
1166    pub fn into_channel(self) -> fidl::Channel {
1167        self.client.into_channel()
1168    }
1169
1170    /// Waits until an event arrives and returns it. It is safe for other
1171    /// threads to make concurrent requests while waiting for an event.
1172    pub fn wait_for_event(
1173        &self,
1174        deadline: zx::MonotonicInstant,
1175    ) -> Result<CentralEvent, fidl::Error> {
1176        CentralEvent::decode(self.client.wait_for_event(deadline)?)
1177    }
1178
1179    /// Register a listener for incoming channels. The registry will assign a
1180    /// PSM value that is unique for the local device, as well as open a
1181    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
1182    /// event that all PSMs have been assigned, this call will fail with
1183    /// `ZX_ERR_NO_RESOURCES`.
1184    ///
1185    /// Note that the method of service discovery or advertising is defined by
1186    /// the service or protocol, so it is the responsibility of the caller to
1187    /// communicate the assigned PSM to any clients.
1188    pub fn r#listen_l2cap(
1189        &self,
1190        mut payload: ChannelListenerRegistryListenL2capRequest,
1191        ___deadline: zx::MonotonicInstant,
1192    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
1193        let _response = self.client.send_query::<
1194            ChannelListenerRegistryListenL2capRequest,
1195            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
1196        >(
1197            &mut payload,
1198            0x39c6e9001d102338,
1199            fidl::encoding::DynamicFlags::empty(),
1200            ___deadline,
1201        )?;
1202        Ok(_response.map(|x| x))
1203    }
1204
1205    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
1206    /// initiated, then `result_watcher` will be closed with an epitaph.
1207    ///
1208    /// A Central client is allowed to have only one active scan at a time.
1209    /// Accordingly, only one Scan request can be outstanding at a time.
1210    /// Additional calls to Scan will fail.
1211    ///
1212    /// The lifetime of the scan session is tied to the `result_watcher`
1213    /// protocol provided. The scan will be stopped if the channel is closed.
1214    ///
1215    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
1216    /// can be used to watch for scan results.
1217    ///
1218    /// + request `options` Options used to configure the scan session.
1219    /// + request `result_watcher` Protocol that remains valid for the duration
1220    ///   of this scan session.
1221    /// - response An empty response will be sent to acknowledge the scan has
1222    ///   stopped.
1223    ///
1224    /// The following epitaphs may be sent by the server on error:
1225    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
1226    ///   protocol is only allowed 1 active scan.
1227    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
1228    ///   `ScanOptions` documentation.
1229    /// * error `INTERNAL`: An internal error occurred and a scan could not be
1230    ///   started.
1231    pub fn r#scan(
1232        &self,
1233        mut options: &ScanOptions,
1234        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1235        ___deadline: zx::MonotonicInstant,
1236    ) -> Result<(), fidl::Error> {
1237        let _response =
1238            self.client.send_query::<CentralScanRequest, fidl::encoding::EmptyPayload>(
1239                (options, result_watcher),
1240                0x41f7121798dfe15f,
1241                fidl::encoding::DynamicFlags::empty(),
1242                ___deadline,
1243            )?;
1244        Ok(_response)
1245    }
1246
1247    /// Connect to the peer with the given identifier.
1248    ///
1249    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
1250    /// client's interest on the LE connection to the peer. Closing the channel
1251    /// removes interest, but may not result in disconnection if another client
1252    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
1253    ///
1254    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
1255    /// system if the connection to the peer is lost or an error occurs.
1256    ///
1257    /// The following epitaphs may be sent by the server on error:
1258    /// + `INVALID_ARGS`: Some of the parameters are invalid.
1259    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
1260    ///                    Connection should be used.
1261    /// + `NOT_CONNECTED`: A connection could not be established.
1262    /// + `CONNECTION_RESET`: The peer disconnected.
1263    ///
1264    /// + request `id` Identifier of the peer to initiate a connection to.
1265    /// + request `options` Options used to configure the connection.
1266    /// + request `handle` Handle that remains valid for the duration of this
1267    ///   connection.
1268    pub fn r#connect(
1269        &self,
1270        mut id: &fidl_fuchsia_bluetooth::PeerId,
1271        mut options: &ConnectionOptions,
1272        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1273    ) -> Result<(), fidl::Error> {
1274        self.client.send::<CentralConnectRequest>(
1275            (id, options, handle),
1276            0x31a3065f2a6913c4,
1277            fidl::encoding::DynamicFlags::empty(),
1278        )
1279    }
1280
1281    /// Synchronize to a periodic advertising train. Reports will be delivered via the
1282    /// `PeriodicAdvertisingSync` protocol.
1283    pub fn r#sync_to_periodic_advertising(
1284        &self,
1285        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1286    ) -> Result<(), fidl::Error> {
1287        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
1288            &mut payload,
1289            0x1db6df126a00c5b9,
1290            fidl::encoding::DynamicFlags::empty(),
1291        )
1292    }
1293
1294    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
1295    /// operation is only valid when operating in the Central role for a connection.
1296    ///
1297    /// If the Central channel is closed before the CIG is explicitly removed, the group will
1298    /// be removed and disconnected.
1299    ///
1300    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
1301    /// id allocated by the host.
1302    pub fn r#create_connected_isochronous_group(
1303        &self,
1304        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1305        ___deadline: zx::MonotonicInstant,
1306    ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
1307        let _response = self
1308            .client
1309            .send_query::<CentralCreateConnectedIsochronousGroupRequest, fidl::encoding::ResultType<
1310                CentralCreateConnectedIsochronousGroupResponse,
1311                CreateCigError,
1312            >>(
1313                &mut payload,
1314                0x60323e70ae22e13,
1315                fidl::encoding::DynamicFlags::empty(),
1316                ___deadline,
1317            )?;
1318        Ok(_response.map(|x| x))
1319    }
1320
1321    /// Returns the list of peripherals that are known to the system from previous scan, connection,
1322    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
1323    /// be present on the peripheral.
1324    ///
1325    /// This method only returns peripherals (i.e. connectable devices).
1326    pub fn r#get_peripherals(
1327        &self,
1328        mut service_uuids: Option<&[String]>,
1329        ___deadline: zx::MonotonicInstant,
1330    ) -> Result<Vec<RemoteDevice>, fidl::Error> {
1331        let _response =
1332            self.client.send_query::<CentralGetPeripheralsRequest, CentralGetPeripheralsResponse>(
1333                (service_uuids,),
1334                0x37ba777499c683a8,
1335                fidl::encoding::DynamicFlags::empty(),
1336                ___deadline,
1337            )?;
1338        Ok(_response.peripherals)
1339    }
1340
1341    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
1342    ///
1343    /// Returns information about a single peripheral that is known to the system from previous scan,
1344    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
1345    /// `identifier` is not recognized.
1346    pub fn r#get_peripheral(
1347        &self,
1348        mut identifier: &str,
1349        ___deadline: zx::MonotonicInstant,
1350    ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
1351        let _response =
1352            self.client.send_query::<CentralGetPeripheralRequest, CentralGetPeripheralResponse>(
1353                (identifier,),
1354                0x97f5a2f2d9c13da,
1355                fidl::encoding::DynamicFlags::empty(),
1356                ___deadline,
1357            )?;
1358        Ok(_response.peripheral)
1359    }
1360
1361    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
1362    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
1363    /// `filter` will replace the existing session's filter.
1364    ///
1365    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
1366    /// will be notified for all discoverable devices that are found. This is not recommended; clients
1367    /// should generally filter results by at least one of `filter.service_uuids`,
1368    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
1369    pub fn r#start_scan(
1370        &self,
1371        mut filter: Option<&ScanFilter>,
1372        ___deadline: zx::MonotonicInstant,
1373    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1374        let _response =
1375            self.client.send_query::<CentralStartScanRequest, CentralStartScanResponse>(
1376                (filter,),
1377                0xeb4cf0cd0e1132b,
1378                fidl::encoding::DynamicFlags::empty(),
1379                ___deadline,
1380            )?;
1381        Ok(_response.status)
1382    }
1383
1384    /// Terminate a previously started scan session.
1385    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1386        self.client.send::<fidl::encoding::EmptyPayload>(
1387            (),
1388            0x5f79ee6a0bb037a0,
1389            fidl::encoding::DynamicFlags::empty(),
1390        )
1391    }
1392
1393    /// Creates a connection to the peripheral device with the given identifier.
1394    /// Returns the status of the operation in `status`.
1395    ///
1396    /// On success, `gatt_client` will be bound and can be used for GATT client
1397    /// role procedures. On failure, `gatt_client` will be closed and `status` will
1398    /// indicate an error.
1399    pub fn r#connect_peripheral(
1400        &self,
1401        mut identifier: &str,
1402        mut options: &ConnectionOptions,
1403        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1404        ___deadline: zx::MonotonicInstant,
1405    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1406        let _response = self
1407            .client
1408            .send_query::<CentralConnectPeripheralRequest, CentralConnectPeripheralResponse>(
1409                (identifier, options, gatt_client),
1410                0x714d6c32d066d75a,
1411                fidl::encoding::DynamicFlags::empty(),
1412                ___deadline,
1413            )?;
1414        Ok(_response.status)
1415    }
1416
1417    /// Disconnects this Central's connection to the peripheral with the given identifier.
1418    pub fn r#disconnect_peripheral(
1419        &self,
1420        mut identifier: &str,
1421        ___deadline: zx::MonotonicInstant,
1422    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1423        let _response = self
1424            .client
1425            .send_query::<CentralDisconnectPeripheralRequest, CentralDisconnectPeripheralResponse>(
1426                (identifier,),
1427                0xa9430da197362fd,
1428                fidl::encoding::DynamicFlags::empty(),
1429                ___deadline,
1430            )?;
1431        Ok(_response.status)
1432    }
1433}
1434
1435#[cfg(target_os = "fuchsia")]
1436impl From<CentralSynchronousProxy> for zx::Handle {
1437    fn from(value: CentralSynchronousProxy) -> Self {
1438        value.into_channel().into()
1439    }
1440}
1441
1442#[cfg(target_os = "fuchsia")]
1443impl From<fidl::Channel> for CentralSynchronousProxy {
1444    fn from(value: fidl::Channel) -> Self {
1445        Self::new(value)
1446    }
1447}
1448
1449#[cfg(target_os = "fuchsia")]
1450impl fidl::endpoints::FromClient for CentralSynchronousProxy {
1451    type Protocol = CentralMarker;
1452
1453    fn from_client(value: fidl::endpoints::ClientEnd<CentralMarker>) -> Self {
1454        Self::new(value.into_channel())
1455    }
1456}
1457
1458#[derive(Debug, Clone)]
1459pub struct CentralProxy {
1460    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1461}
1462
1463impl fidl::endpoints::Proxy for CentralProxy {
1464    type Protocol = CentralMarker;
1465
1466    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1467        Self::new(inner)
1468    }
1469
1470    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1471        self.client.into_channel().map_err(|client| Self { client })
1472    }
1473
1474    fn as_channel(&self) -> &::fidl::AsyncChannel {
1475        self.client.as_channel()
1476    }
1477}
1478
1479impl CentralProxy {
1480    /// Create a new Proxy for fuchsia.bluetooth.le/Central.
1481    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1482        let protocol_name = <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1483        Self { client: fidl::client::Client::new(channel, protocol_name) }
1484    }
1485
1486    /// Get a Stream of events from the remote end of the protocol.
1487    ///
1488    /// # Panics
1489    ///
1490    /// Panics if the event stream was already taken.
1491    pub fn take_event_stream(&self) -> CentralEventStream {
1492        CentralEventStream { event_receiver: self.client.take_event_receiver() }
1493    }
1494
1495    /// Register a listener for incoming channels. The registry will assign a
1496    /// PSM value that is unique for the local device, as well as open a
1497    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
1498    /// event that all PSMs have been assigned, this call will fail with
1499    /// `ZX_ERR_NO_RESOURCES`.
1500    ///
1501    /// Note that the method of service discovery or advertising is defined by
1502    /// the service or protocol, so it is the responsibility of the caller to
1503    /// communicate the assigned PSM to any clients.
1504    pub fn r#listen_l2cap(
1505        &self,
1506        mut payload: ChannelListenerRegistryListenL2capRequest,
1507    ) -> fidl::client::QueryResponseFut<
1508        ChannelListenerRegistryListenL2capResult,
1509        fidl::encoding::DefaultFuchsiaResourceDialect,
1510    > {
1511        CentralProxyInterface::r#listen_l2cap(self, payload)
1512    }
1513
1514    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
1515    /// initiated, then `result_watcher` will be closed with an epitaph.
1516    ///
1517    /// A Central client is allowed to have only one active scan at a time.
1518    /// Accordingly, only one Scan request can be outstanding at a time.
1519    /// Additional calls to Scan will fail.
1520    ///
1521    /// The lifetime of the scan session is tied to the `result_watcher`
1522    /// protocol provided. The scan will be stopped if the channel is closed.
1523    ///
1524    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
1525    /// can be used to watch for scan results.
1526    ///
1527    /// + request `options` Options used to configure the scan session.
1528    /// + request `result_watcher` Protocol that remains valid for the duration
1529    ///   of this scan session.
1530    /// - response An empty response will be sent to acknowledge the scan has
1531    ///   stopped.
1532    ///
1533    /// The following epitaphs may be sent by the server on error:
1534    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
1535    ///   protocol is only allowed 1 active scan.
1536    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
1537    ///   `ScanOptions` documentation.
1538    /// * error `INTERNAL`: An internal error occurred and a scan could not be
1539    ///   started.
1540    pub fn r#scan(
1541        &self,
1542        mut options: &ScanOptions,
1543        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1544    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1545        CentralProxyInterface::r#scan(self, options, result_watcher)
1546    }
1547
1548    /// Connect to the peer with the given identifier.
1549    ///
1550    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
1551    /// client's interest on the LE connection to the peer. Closing the channel
1552    /// removes interest, but may not result in disconnection if another client
1553    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
1554    ///
1555    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
1556    /// system if the connection to the peer is lost or an error occurs.
1557    ///
1558    /// The following epitaphs may be sent by the server on error:
1559    /// + `INVALID_ARGS`: Some of the parameters are invalid.
1560    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
1561    ///                    Connection should be used.
1562    /// + `NOT_CONNECTED`: A connection could not be established.
1563    /// + `CONNECTION_RESET`: The peer disconnected.
1564    ///
1565    /// + request `id` Identifier of the peer to initiate a connection to.
1566    /// + request `options` Options used to configure the connection.
1567    /// + request `handle` Handle that remains valid for the duration of this
1568    ///   connection.
1569    pub fn r#connect(
1570        &self,
1571        mut id: &fidl_fuchsia_bluetooth::PeerId,
1572        mut options: &ConnectionOptions,
1573        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1574    ) -> Result<(), fidl::Error> {
1575        CentralProxyInterface::r#connect(self, id, options, handle)
1576    }
1577
1578    /// Synchronize to a periodic advertising train. Reports will be delivered via the
1579    /// `PeriodicAdvertisingSync` protocol.
1580    pub fn r#sync_to_periodic_advertising(
1581        &self,
1582        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1583    ) -> Result<(), fidl::Error> {
1584        CentralProxyInterface::r#sync_to_periodic_advertising(self, payload)
1585    }
1586
1587    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
1588    /// operation is only valid when operating in the Central role for a connection.
1589    ///
1590    /// If the Central channel is closed before the CIG is explicitly removed, the group will
1591    /// be removed and disconnected.
1592    ///
1593    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
1594    /// id allocated by the host.
1595    pub fn r#create_connected_isochronous_group(
1596        &self,
1597        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1598    ) -> fidl::client::QueryResponseFut<
1599        CentralCreateConnectedIsochronousGroupResult,
1600        fidl::encoding::DefaultFuchsiaResourceDialect,
1601    > {
1602        CentralProxyInterface::r#create_connected_isochronous_group(self, payload)
1603    }
1604
1605    /// Returns the list of peripherals that are known to the system from previous scan, connection,
1606    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
1607    /// be present on the peripheral.
1608    ///
1609    /// This method only returns peripherals (i.e. connectable devices).
1610    pub fn r#get_peripherals(
1611        &self,
1612        mut service_uuids: Option<&[String]>,
1613    ) -> fidl::client::QueryResponseFut<
1614        Vec<RemoteDevice>,
1615        fidl::encoding::DefaultFuchsiaResourceDialect,
1616    > {
1617        CentralProxyInterface::r#get_peripherals(self, service_uuids)
1618    }
1619
1620    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
1621    ///
1622    /// Returns information about a single peripheral that is known to the system from previous scan,
1623    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
1624    /// `identifier` is not recognized.
1625    pub fn r#get_peripheral(
1626        &self,
1627        mut identifier: &str,
1628    ) -> fidl::client::QueryResponseFut<
1629        Option<Box<RemoteDevice>>,
1630        fidl::encoding::DefaultFuchsiaResourceDialect,
1631    > {
1632        CentralProxyInterface::r#get_peripheral(self, identifier)
1633    }
1634
1635    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
1636    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
1637    /// `filter` will replace the existing session's filter.
1638    ///
1639    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
1640    /// will be notified for all discoverable devices that are found. This is not recommended; clients
1641    /// should generally filter results by at least one of `filter.service_uuids`,
1642    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
1643    pub fn r#start_scan(
1644        &self,
1645        mut filter: Option<&ScanFilter>,
1646    ) -> fidl::client::QueryResponseFut<
1647        fidl_fuchsia_bluetooth::Status,
1648        fidl::encoding::DefaultFuchsiaResourceDialect,
1649    > {
1650        CentralProxyInterface::r#start_scan(self, filter)
1651    }
1652
1653    /// Terminate a previously started scan session.
1654    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1655        CentralProxyInterface::r#stop_scan(self)
1656    }
1657
1658    /// Creates a connection to the peripheral device with the given identifier.
1659    /// Returns the status of the operation in `status`.
1660    ///
1661    /// On success, `gatt_client` will be bound and can be used for GATT client
1662    /// role procedures. On failure, `gatt_client` will be closed and `status` will
1663    /// indicate an error.
1664    pub fn r#connect_peripheral(
1665        &self,
1666        mut identifier: &str,
1667        mut options: &ConnectionOptions,
1668        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1669    ) -> fidl::client::QueryResponseFut<
1670        fidl_fuchsia_bluetooth::Status,
1671        fidl::encoding::DefaultFuchsiaResourceDialect,
1672    > {
1673        CentralProxyInterface::r#connect_peripheral(self, identifier, options, gatt_client)
1674    }
1675
1676    /// Disconnects this Central's connection to the peripheral with the given identifier.
1677    pub fn r#disconnect_peripheral(
1678        &self,
1679        mut identifier: &str,
1680    ) -> fidl::client::QueryResponseFut<
1681        fidl_fuchsia_bluetooth::Status,
1682        fidl::encoding::DefaultFuchsiaResourceDialect,
1683    > {
1684        CentralProxyInterface::r#disconnect_peripheral(self, identifier)
1685    }
1686}
1687
1688impl CentralProxyInterface for CentralProxy {
1689    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
1690        ChannelListenerRegistryListenL2capResult,
1691        fidl::encoding::DefaultFuchsiaResourceDialect,
1692    >;
1693    fn r#listen_l2cap(
1694        &self,
1695        mut payload: ChannelListenerRegistryListenL2capRequest,
1696    ) -> Self::ListenL2capResponseFut {
1697        fn _decode(
1698            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1699        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
1700            let _response = fidl::client::decode_transaction_body::<
1701                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
1702                fidl::encoding::DefaultFuchsiaResourceDialect,
1703                0x39c6e9001d102338,
1704            >(_buf?)?;
1705            Ok(_response.map(|x| x))
1706        }
1707        self.client.send_query_and_decode::<
1708            ChannelListenerRegistryListenL2capRequest,
1709            ChannelListenerRegistryListenL2capResult,
1710        >(
1711            &mut payload,
1712            0x39c6e9001d102338,
1713            fidl::encoding::DynamicFlags::empty(),
1714            _decode,
1715        )
1716    }
1717
1718    type ScanResponseFut =
1719        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1720    fn r#scan(
1721        &self,
1722        mut options: &ScanOptions,
1723        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1724    ) -> Self::ScanResponseFut {
1725        fn _decode(
1726            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1727        ) -> Result<(), fidl::Error> {
1728            let _response = fidl::client::decode_transaction_body::<
1729                fidl::encoding::EmptyPayload,
1730                fidl::encoding::DefaultFuchsiaResourceDialect,
1731                0x41f7121798dfe15f,
1732            >(_buf?)?;
1733            Ok(_response)
1734        }
1735        self.client.send_query_and_decode::<CentralScanRequest, ()>(
1736            (options, result_watcher),
1737            0x41f7121798dfe15f,
1738            fidl::encoding::DynamicFlags::empty(),
1739            _decode,
1740        )
1741    }
1742
1743    fn r#connect(
1744        &self,
1745        mut id: &fidl_fuchsia_bluetooth::PeerId,
1746        mut options: &ConnectionOptions,
1747        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1748    ) -> Result<(), fidl::Error> {
1749        self.client.send::<CentralConnectRequest>(
1750            (id, options, handle),
1751            0x31a3065f2a6913c4,
1752            fidl::encoding::DynamicFlags::empty(),
1753        )
1754    }
1755
1756    fn r#sync_to_periodic_advertising(
1757        &self,
1758        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1759    ) -> Result<(), fidl::Error> {
1760        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
1761            &mut payload,
1762            0x1db6df126a00c5b9,
1763            fidl::encoding::DynamicFlags::empty(),
1764        )
1765    }
1766
1767    type CreateConnectedIsochronousGroupResponseFut = fidl::client::QueryResponseFut<
1768        CentralCreateConnectedIsochronousGroupResult,
1769        fidl::encoding::DefaultFuchsiaResourceDialect,
1770    >;
1771    fn r#create_connected_isochronous_group(
1772        &self,
1773        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1774    ) -> Self::CreateConnectedIsochronousGroupResponseFut {
1775        fn _decode(
1776            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1777        ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
1778            let _response = fidl::client::decode_transaction_body::<
1779                fidl::encoding::ResultType<
1780                    CentralCreateConnectedIsochronousGroupResponse,
1781                    CreateCigError,
1782                >,
1783                fidl::encoding::DefaultFuchsiaResourceDialect,
1784                0x60323e70ae22e13,
1785            >(_buf?)?;
1786            Ok(_response.map(|x| x))
1787        }
1788        self.client.send_query_and_decode::<
1789            CentralCreateConnectedIsochronousGroupRequest,
1790            CentralCreateConnectedIsochronousGroupResult,
1791        >(
1792            &mut payload,
1793            0x60323e70ae22e13,
1794            fidl::encoding::DynamicFlags::empty(),
1795            _decode,
1796        )
1797    }
1798
1799    type GetPeripheralsResponseFut = fidl::client::QueryResponseFut<
1800        Vec<RemoteDevice>,
1801        fidl::encoding::DefaultFuchsiaResourceDialect,
1802    >;
1803    fn r#get_peripherals(
1804        &self,
1805        mut service_uuids: Option<&[String]>,
1806    ) -> Self::GetPeripheralsResponseFut {
1807        fn _decode(
1808            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1809        ) -> Result<Vec<RemoteDevice>, fidl::Error> {
1810            let _response = fidl::client::decode_transaction_body::<
1811                CentralGetPeripheralsResponse,
1812                fidl::encoding::DefaultFuchsiaResourceDialect,
1813                0x37ba777499c683a8,
1814            >(_buf?)?;
1815            Ok(_response.peripherals)
1816        }
1817        self.client.send_query_and_decode::<CentralGetPeripheralsRequest, Vec<RemoteDevice>>(
1818            (service_uuids,),
1819            0x37ba777499c683a8,
1820            fidl::encoding::DynamicFlags::empty(),
1821            _decode,
1822        )
1823    }
1824
1825    type GetPeripheralResponseFut = fidl::client::QueryResponseFut<
1826        Option<Box<RemoteDevice>>,
1827        fidl::encoding::DefaultFuchsiaResourceDialect,
1828    >;
1829    fn r#get_peripheral(&self, mut identifier: &str) -> Self::GetPeripheralResponseFut {
1830        fn _decode(
1831            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1832        ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
1833            let _response = fidl::client::decode_transaction_body::<
1834                CentralGetPeripheralResponse,
1835                fidl::encoding::DefaultFuchsiaResourceDialect,
1836                0x97f5a2f2d9c13da,
1837            >(_buf?)?;
1838            Ok(_response.peripheral)
1839        }
1840        self.client.send_query_and_decode::<CentralGetPeripheralRequest, Option<Box<RemoteDevice>>>(
1841            (identifier,),
1842            0x97f5a2f2d9c13da,
1843            fidl::encoding::DynamicFlags::empty(),
1844            _decode,
1845        )
1846    }
1847
1848    type StartScanResponseFut = fidl::client::QueryResponseFut<
1849        fidl_fuchsia_bluetooth::Status,
1850        fidl::encoding::DefaultFuchsiaResourceDialect,
1851    >;
1852    fn r#start_scan(&self, mut filter: Option<&ScanFilter>) -> Self::StartScanResponseFut {
1853        fn _decode(
1854            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1855        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1856            let _response = fidl::client::decode_transaction_body::<
1857                CentralStartScanResponse,
1858                fidl::encoding::DefaultFuchsiaResourceDialect,
1859                0xeb4cf0cd0e1132b,
1860            >(_buf?)?;
1861            Ok(_response.status)
1862        }
1863        self.client
1864            .send_query_and_decode::<CentralStartScanRequest, fidl_fuchsia_bluetooth::Status>(
1865                (filter,),
1866                0xeb4cf0cd0e1132b,
1867                fidl::encoding::DynamicFlags::empty(),
1868                _decode,
1869            )
1870    }
1871
1872    fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1873        self.client.send::<fidl::encoding::EmptyPayload>(
1874            (),
1875            0x5f79ee6a0bb037a0,
1876            fidl::encoding::DynamicFlags::empty(),
1877        )
1878    }
1879
1880    type ConnectPeripheralResponseFut = fidl::client::QueryResponseFut<
1881        fidl_fuchsia_bluetooth::Status,
1882        fidl::encoding::DefaultFuchsiaResourceDialect,
1883    >;
1884    fn r#connect_peripheral(
1885        &self,
1886        mut identifier: &str,
1887        mut options: &ConnectionOptions,
1888        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1889    ) -> Self::ConnectPeripheralResponseFut {
1890        fn _decode(
1891            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1892        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1893            let _response = fidl::client::decode_transaction_body::<
1894                CentralConnectPeripheralResponse,
1895                fidl::encoding::DefaultFuchsiaResourceDialect,
1896                0x714d6c32d066d75a,
1897            >(_buf?)?;
1898            Ok(_response.status)
1899        }
1900        self.client.send_query_and_decode::<
1901            CentralConnectPeripheralRequest,
1902            fidl_fuchsia_bluetooth::Status,
1903        >(
1904            (identifier, options, gatt_client,),
1905            0x714d6c32d066d75a,
1906            fidl::encoding::DynamicFlags::empty(),
1907            _decode,
1908        )
1909    }
1910
1911    type DisconnectPeripheralResponseFut = fidl::client::QueryResponseFut<
1912        fidl_fuchsia_bluetooth::Status,
1913        fidl::encoding::DefaultFuchsiaResourceDialect,
1914    >;
1915    fn r#disconnect_peripheral(
1916        &self,
1917        mut identifier: &str,
1918    ) -> Self::DisconnectPeripheralResponseFut {
1919        fn _decode(
1920            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1921        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1922            let _response = fidl::client::decode_transaction_body::<
1923                CentralDisconnectPeripheralResponse,
1924                fidl::encoding::DefaultFuchsiaResourceDialect,
1925                0xa9430da197362fd,
1926            >(_buf?)?;
1927            Ok(_response.status)
1928        }
1929        self.client.send_query_and_decode::<
1930            CentralDisconnectPeripheralRequest,
1931            fidl_fuchsia_bluetooth::Status,
1932        >(
1933            (identifier,),
1934            0xa9430da197362fd,
1935            fidl::encoding::DynamicFlags::empty(),
1936            _decode,
1937        )
1938    }
1939}
1940
1941pub struct CentralEventStream {
1942    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1943}
1944
1945impl std::marker::Unpin for CentralEventStream {}
1946
1947impl futures::stream::FusedStream for CentralEventStream {
1948    fn is_terminated(&self) -> bool {
1949        self.event_receiver.is_terminated()
1950    }
1951}
1952
1953impl futures::Stream for CentralEventStream {
1954    type Item = Result<CentralEvent, fidl::Error>;
1955
1956    fn poll_next(
1957        mut self: std::pin::Pin<&mut Self>,
1958        cx: &mut std::task::Context<'_>,
1959    ) -> std::task::Poll<Option<Self::Item>> {
1960        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1961            &mut self.event_receiver,
1962            cx
1963        )?) {
1964            Some(buf) => std::task::Poll::Ready(Some(CentralEvent::decode(buf))),
1965            None => std::task::Poll::Ready(None),
1966        }
1967    }
1968}
1969
1970#[derive(Debug)]
1971pub enum CentralEvent {
1972    OnScanStateChanged { scanning: bool },
1973    OnDeviceDiscovered { device: RemoteDevice },
1974    OnPeripheralDisconnected { identifier: String },
1975}
1976
1977impl CentralEvent {
1978    #[allow(irrefutable_let_patterns)]
1979    pub fn into_on_scan_state_changed(self) -> Option<bool> {
1980        if let CentralEvent::OnScanStateChanged { scanning } = self {
1981            Some((scanning))
1982        } else {
1983            None
1984        }
1985    }
1986    #[allow(irrefutable_let_patterns)]
1987    pub fn into_on_device_discovered(self) -> Option<RemoteDevice> {
1988        if let CentralEvent::OnDeviceDiscovered { device } = self { Some((device)) } else { None }
1989    }
1990    #[allow(irrefutable_let_patterns)]
1991    pub fn into_on_peripheral_disconnected(self) -> Option<String> {
1992        if let CentralEvent::OnPeripheralDisconnected { identifier } = self {
1993            Some((identifier))
1994        } else {
1995            None
1996        }
1997    }
1998
1999    /// Decodes a message buffer as a [`CentralEvent`].
2000    fn decode(
2001        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2002    ) -> Result<CentralEvent, fidl::Error> {
2003        let (bytes, _handles) = buf.split_mut();
2004        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2005        debug_assert_eq!(tx_header.tx_id, 0);
2006        match tx_header.ordinal {
2007            0x5f8edc23cad04d3f => {
2008                let mut out = fidl::new_empty!(
2009                    CentralOnScanStateChangedRequest,
2010                    fidl::encoding::DefaultFuchsiaResourceDialect
2011                );
2012                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnScanStateChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2013                Ok((CentralEvent::OnScanStateChanged { scanning: out.scanning }))
2014            }
2015            0x708dadf20d66db6 => {
2016                let mut out = fidl::new_empty!(
2017                    CentralOnDeviceDiscoveredRequest,
2018                    fidl::encoding::DefaultFuchsiaResourceDialect
2019                );
2020                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnDeviceDiscoveredRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2021                Ok((CentralEvent::OnDeviceDiscovered { device: out.device }))
2022            }
2023            0x4e4c6b979b2126df => {
2024                let mut out = fidl::new_empty!(
2025                    CentralOnPeripheralDisconnectedRequest,
2026                    fidl::encoding::DefaultFuchsiaResourceDialect
2027                );
2028                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnPeripheralDisconnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2029                Ok((CentralEvent::OnPeripheralDisconnected { identifier: out.identifier }))
2030            }
2031            _ => Err(fidl::Error::UnknownOrdinal {
2032                ordinal: tx_header.ordinal,
2033                protocol_name: <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2034            }),
2035        }
2036    }
2037}
2038
2039/// A Stream of incoming requests for fuchsia.bluetooth.le/Central.
2040pub struct CentralRequestStream {
2041    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2042    is_terminated: bool,
2043}
2044
2045impl std::marker::Unpin for CentralRequestStream {}
2046
2047impl futures::stream::FusedStream for CentralRequestStream {
2048    fn is_terminated(&self) -> bool {
2049        self.is_terminated
2050    }
2051}
2052
2053impl fidl::endpoints::RequestStream for CentralRequestStream {
2054    type Protocol = CentralMarker;
2055    type ControlHandle = CentralControlHandle;
2056
2057    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2058        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2059    }
2060
2061    fn control_handle(&self) -> Self::ControlHandle {
2062        CentralControlHandle { inner: self.inner.clone() }
2063    }
2064
2065    fn into_inner(
2066        self,
2067    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2068    {
2069        (self.inner, self.is_terminated)
2070    }
2071
2072    fn from_inner(
2073        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2074        is_terminated: bool,
2075    ) -> Self {
2076        Self { inner, is_terminated }
2077    }
2078}
2079
2080impl futures::Stream for CentralRequestStream {
2081    type Item = Result<CentralRequest, fidl::Error>;
2082
2083    fn poll_next(
2084        mut self: std::pin::Pin<&mut Self>,
2085        cx: &mut std::task::Context<'_>,
2086    ) -> std::task::Poll<Option<Self::Item>> {
2087        let this = &mut *self;
2088        if this.inner.check_shutdown(cx) {
2089            this.is_terminated = true;
2090            return std::task::Poll::Ready(None);
2091        }
2092        if this.is_terminated {
2093            panic!("polled CentralRequestStream after completion");
2094        }
2095        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2096            |bytes, handles| {
2097                match this.inner.channel().read_etc(cx, bytes, handles) {
2098                    std::task::Poll::Ready(Ok(())) => {}
2099                    std::task::Poll::Pending => return std::task::Poll::Pending,
2100                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2101                        this.is_terminated = true;
2102                        return std::task::Poll::Ready(None);
2103                    }
2104                    std::task::Poll::Ready(Err(e)) => {
2105                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2106                            e.into(),
2107                        ))));
2108                    }
2109                }
2110
2111                // A message has been received from the channel
2112                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2113
2114                std::task::Poll::Ready(Some(match header.ordinal {
2115                    0x39c6e9001d102338 => {
2116                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2117                        let mut req = fidl::new_empty!(
2118                            ChannelListenerRegistryListenL2capRequest,
2119                            fidl::encoding::DefaultFuchsiaResourceDialect
2120                        );
2121                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
2122                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2123                        Ok(CentralRequest::ListenL2cap {
2124                            payload: req,
2125                            responder: CentralListenL2capResponder {
2126                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2127                                tx_id: header.tx_id,
2128                            },
2129                        })
2130                    }
2131                    0x41f7121798dfe15f => {
2132                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2133                        let mut req = fidl::new_empty!(
2134                            CentralScanRequest,
2135                            fidl::encoding::DefaultFuchsiaResourceDialect
2136                        );
2137                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralScanRequest>(&header, _body_bytes, handles, &mut req)?;
2138                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2139                        Ok(CentralRequest::Scan {
2140                            options: req.options,
2141                            result_watcher: req.result_watcher,
2142
2143                            responder: CentralScanResponder {
2144                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2145                                tx_id: header.tx_id,
2146                            },
2147                        })
2148                    }
2149                    0x31a3065f2a6913c4 => {
2150                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2151                        let mut req = fidl::new_empty!(
2152                            CentralConnectRequest,
2153                            fidl::encoding::DefaultFuchsiaResourceDialect
2154                        );
2155                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectRequest>(&header, _body_bytes, handles, &mut req)?;
2156                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2157                        Ok(CentralRequest::Connect {
2158                            id: req.id,
2159                            options: req.options,
2160                            handle: req.handle,
2161
2162                            control_handle,
2163                        })
2164                    }
2165                    0x1db6df126a00c5b9 => {
2166                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2167                        let mut req = fidl::new_empty!(
2168                            CentralSyncToPeriodicAdvertisingRequest,
2169                            fidl::encoding::DefaultFuchsiaResourceDialect
2170                        );
2171                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralSyncToPeriodicAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
2172                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2173                        Ok(CentralRequest::SyncToPeriodicAdvertising {
2174                            payload: req,
2175                            control_handle,
2176                        })
2177                    }
2178                    0x60323e70ae22e13 => {
2179                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2180                        let mut req = fidl::new_empty!(
2181                            CentralCreateConnectedIsochronousGroupRequest,
2182                            fidl::encoding::DefaultFuchsiaResourceDialect
2183                        );
2184                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralCreateConnectedIsochronousGroupRequest>(&header, _body_bytes, handles, &mut req)?;
2185                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2186                        Ok(CentralRequest::CreateConnectedIsochronousGroup {
2187                            payload: req,
2188                            responder: CentralCreateConnectedIsochronousGroupResponder {
2189                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2190                                tx_id: header.tx_id,
2191                            },
2192                        })
2193                    }
2194                    0x37ba777499c683a8 => {
2195                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2196                        let mut req = fidl::new_empty!(
2197                            CentralGetPeripheralsRequest,
2198                            fidl::encoding::DefaultFuchsiaResourceDialect
2199                        );
2200                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralsRequest>(&header, _body_bytes, handles, &mut req)?;
2201                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2202                        Ok(CentralRequest::GetPeripherals {
2203                            service_uuids: req.service_uuids,
2204
2205                            responder: CentralGetPeripheralsResponder {
2206                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2207                                tx_id: header.tx_id,
2208                            },
2209                        })
2210                    }
2211                    0x97f5a2f2d9c13da => {
2212                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2213                        let mut req = fidl::new_empty!(
2214                            CentralGetPeripheralRequest,
2215                            fidl::encoding::DefaultFuchsiaResourceDialect
2216                        );
2217                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2218                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2219                        Ok(CentralRequest::GetPeripheral {
2220                            identifier: req.identifier,
2221
2222                            responder: CentralGetPeripheralResponder {
2223                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2224                                tx_id: header.tx_id,
2225                            },
2226                        })
2227                    }
2228                    0xeb4cf0cd0e1132b => {
2229                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2230                        let mut req = fidl::new_empty!(
2231                            CentralStartScanRequest,
2232                            fidl::encoding::DefaultFuchsiaResourceDialect
2233                        );
2234                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralStartScanRequest>(&header, _body_bytes, handles, &mut req)?;
2235                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2236                        Ok(CentralRequest::StartScan {
2237                            filter: req.filter,
2238
2239                            responder: CentralStartScanResponder {
2240                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2241                                tx_id: header.tx_id,
2242                            },
2243                        })
2244                    }
2245                    0x5f79ee6a0bb037a0 => {
2246                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2247                        let mut req = fidl::new_empty!(
2248                            fidl::encoding::EmptyPayload,
2249                            fidl::encoding::DefaultFuchsiaResourceDialect
2250                        );
2251                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2252                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2253                        Ok(CentralRequest::StopScan { control_handle })
2254                    }
2255                    0x714d6c32d066d75a => {
2256                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2257                        let mut req = fidl::new_empty!(
2258                            CentralConnectPeripheralRequest,
2259                            fidl::encoding::DefaultFuchsiaResourceDialect
2260                        );
2261                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2262                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2263                        Ok(CentralRequest::ConnectPeripheral {
2264                            identifier: req.identifier,
2265                            options: req.options,
2266                            gatt_client: req.gatt_client,
2267
2268                            responder: CentralConnectPeripheralResponder {
2269                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2270                                tx_id: header.tx_id,
2271                            },
2272                        })
2273                    }
2274                    0xa9430da197362fd => {
2275                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2276                        let mut req = fidl::new_empty!(
2277                            CentralDisconnectPeripheralRequest,
2278                            fidl::encoding::DefaultFuchsiaResourceDialect
2279                        );
2280                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralDisconnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2281                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2282                        Ok(CentralRequest::DisconnectPeripheral {
2283                            identifier: req.identifier,
2284
2285                            responder: CentralDisconnectPeripheralResponder {
2286                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2287                                tx_id: header.tx_id,
2288                            },
2289                        })
2290                    }
2291                    _ => Err(fidl::Error::UnknownOrdinal {
2292                        ordinal: header.ordinal,
2293                        protocol_name:
2294                            <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2295                    }),
2296                }))
2297            },
2298        )
2299    }
2300}
2301
2302#[derive(Debug)]
2303pub enum CentralRequest {
2304    /// Register a listener for incoming channels. The registry will assign a
2305    /// PSM value that is unique for the local device, as well as open a
2306    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
2307    /// event that all PSMs have been assigned, this call will fail with
2308    /// `ZX_ERR_NO_RESOURCES`.
2309    ///
2310    /// Note that the method of service discovery or advertising is defined by
2311    /// the service or protocol, so it is the responsibility of the caller to
2312    /// communicate the assigned PSM to any clients.
2313    ListenL2cap {
2314        payload: ChannelListenerRegistryListenL2capRequest,
2315        responder: CentralListenL2capResponder,
2316    },
2317    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
2318    /// initiated, then `result_watcher` will be closed with an epitaph.
2319    ///
2320    /// A Central client is allowed to have only one active scan at a time.
2321    /// Accordingly, only one Scan request can be outstanding at a time.
2322    /// Additional calls to Scan will fail.
2323    ///
2324    /// The lifetime of the scan session is tied to the `result_watcher`
2325    /// protocol provided. The scan will be stopped if the channel is closed.
2326    ///
2327    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
2328    /// can be used to watch for scan results.
2329    ///
2330    /// + request `options` Options used to configure the scan session.
2331    /// + request `result_watcher` Protocol that remains valid for the duration
2332    ///   of this scan session.
2333    /// - response An empty response will be sent to acknowledge the scan has
2334    ///   stopped.
2335    ///
2336    /// The following epitaphs may be sent by the server on error:
2337    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
2338    ///   protocol is only allowed 1 active scan.
2339    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
2340    ///   `ScanOptions` documentation.
2341    /// * error `INTERNAL`: An internal error occurred and a scan could not be
2342    ///   started.
2343    Scan {
2344        options: ScanOptions,
2345        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
2346        responder: CentralScanResponder,
2347    },
2348    /// Connect to the peer with the given identifier.
2349    ///
2350    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
2351    /// client's interest on the LE connection to the peer. Closing the channel
2352    /// removes interest, but may not result in disconnection if another client
2353    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
2354    ///
2355    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
2356    /// system if the connection to the peer is lost or an error occurs.
2357    ///
2358    /// The following epitaphs may be sent by the server on error:
2359    /// + `INVALID_ARGS`: Some of the parameters are invalid.
2360    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
2361    ///                    Connection should be used.
2362    /// + `NOT_CONNECTED`: A connection could not be established.
2363    /// + `CONNECTION_RESET`: The peer disconnected.
2364    ///
2365    /// + request `id` Identifier of the peer to initiate a connection to.
2366    /// + request `options` Options used to configure the connection.
2367    /// + request `handle` Handle that remains valid for the duration of this
2368    ///   connection.
2369    Connect {
2370        id: fidl_fuchsia_bluetooth::PeerId,
2371        options: ConnectionOptions,
2372        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
2373        control_handle: CentralControlHandle,
2374    },
2375    /// Synchronize to a periodic advertising train. Reports will be delivered via the
2376    /// `PeriodicAdvertisingSync` protocol.
2377    SyncToPeriodicAdvertising {
2378        payload: CentralSyncToPeriodicAdvertisingRequest,
2379        control_handle: CentralControlHandle,
2380    },
2381    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
2382    /// operation is only valid when operating in the Central role for a connection.
2383    ///
2384    /// If the Central channel is closed before the CIG is explicitly removed, the group will
2385    /// be removed and disconnected.
2386    ///
2387    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
2388    /// id allocated by the host.
2389    CreateConnectedIsochronousGroup {
2390        payload: CentralCreateConnectedIsochronousGroupRequest,
2391        responder: CentralCreateConnectedIsochronousGroupResponder,
2392    },
2393    /// Returns the list of peripherals that are known to the system from previous scan, connection,
2394    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
2395    /// be present on the peripheral.
2396    ///
2397    /// This method only returns peripherals (i.e. connectable devices).
2398    GetPeripherals { service_uuids: Option<Vec<String>>, responder: CentralGetPeripheralsResponder },
2399    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
2400    ///
2401    /// Returns information about a single peripheral that is known to the system from previous scan,
2402    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
2403    /// `identifier` is not recognized.
2404    GetPeripheral { identifier: String, responder: CentralGetPeripheralResponder },
2405    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
2406    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
2407    /// `filter` will replace the existing session's filter.
2408    ///
2409    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
2410    /// will be notified for all discoverable devices that are found. This is not recommended; clients
2411    /// should generally filter results by at least one of `filter.service_uuids`,
2412    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
2413    StartScan { filter: Option<Box<ScanFilter>>, responder: CentralStartScanResponder },
2414    /// Terminate a previously started scan session.
2415    StopScan { control_handle: CentralControlHandle },
2416    /// Creates a connection to the peripheral device with the given identifier.
2417    /// Returns the status of the operation in `status`.
2418    ///
2419    /// On success, `gatt_client` will be bound and can be used for GATT client
2420    /// role procedures. On failure, `gatt_client` will be closed and `status` will
2421    /// indicate an error.
2422    ConnectPeripheral {
2423        identifier: String,
2424        options: ConnectionOptions,
2425        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
2426        responder: CentralConnectPeripheralResponder,
2427    },
2428    /// Disconnects this Central's connection to the peripheral with the given identifier.
2429    DisconnectPeripheral { identifier: String, responder: CentralDisconnectPeripheralResponder },
2430}
2431
2432impl CentralRequest {
2433    #[allow(irrefutable_let_patterns)]
2434    pub fn into_listen_l2cap(
2435        self,
2436    ) -> Option<(ChannelListenerRegistryListenL2capRequest, CentralListenL2capResponder)> {
2437        if let CentralRequest::ListenL2cap { payload, responder } = self {
2438            Some((payload, responder))
2439        } else {
2440            None
2441        }
2442    }
2443
2444    #[allow(irrefutable_let_patterns)]
2445    pub fn into_scan(
2446        self,
2447    ) -> Option<(
2448        ScanOptions,
2449        fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
2450        CentralScanResponder,
2451    )> {
2452        if let CentralRequest::Scan { options, result_watcher, responder } = self {
2453            Some((options, result_watcher, responder))
2454        } else {
2455            None
2456        }
2457    }
2458
2459    #[allow(irrefutable_let_patterns)]
2460    pub fn into_connect(
2461        self,
2462    ) -> Option<(
2463        fidl_fuchsia_bluetooth::PeerId,
2464        ConnectionOptions,
2465        fidl::endpoints::ServerEnd<ConnectionMarker>,
2466        CentralControlHandle,
2467    )> {
2468        if let CentralRequest::Connect { id, options, handle, control_handle } = self {
2469            Some((id, options, handle, control_handle))
2470        } else {
2471            None
2472        }
2473    }
2474
2475    #[allow(irrefutable_let_patterns)]
2476    pub fn into_sync_to_periodic_advertising(
2477        self,
2478    ) -> Option<(CentralSyncToPeriodicAdvertisingRequest, CentralControlHandle)> {
2479        if let CentralRequest::SyncToPeriodicAdvertising { payload, control_handle } = self {
2480            Some((payload, control_handle))
2481        } else {
2482            None
2483        }
2484    }
2485
2486    #[allow(irrefutable_let_patterns)]
2487    pub fn into_create_connected_isochronous_group(
2488        self,
2489    ) -> Option<(
2490        CentralCreateConnectedIsochronousGroupRequest,
2491        CentralCreateConnectedIsochronousGroupResponder,
2492    )> {
2493        if let CentralRequest::CreateConnectedIsochronousGroup { payload, responder } = self {
2494            Some((payload, responder))
2495        } else {
2496            None
2497        }
2498    }
2499
2500    #[allow(irrefutable_let_patterns)]
2501    pub fn into_get_peripherals(
2502        self,
2503    ) -> Option<(Option<Vec<String>>, CentralGetPeripheralsResponder)> {
2504        if let CentralRequest::GetPeripherals { service_uuids, responder } = self {
2505            Some((service_uuids, responder))
2506        } else {
2507            None
2508        }
2509    }
2510
2511    #[allow(irrefutable_let_patterns)]
2512    pub fn into_get_peripheral(self) -> Option<(String, CentralGetPeripheralResponder)> {
2513        if let CentralRequest::GetPeripheral { identifier, responder } = self {
2514            Some((identifier, responder))
2515        } else {
2516            None
2517        }
2518    }
2519
2520    #[allow(irrefutable_let_patterns)]
2521    pub fn into_start_scan(self) -> Option<(Option<Box<ScanFilter>>, CentralStartScanResponder)> {
2522        if let CentralRequest::StartScan { filter, responder } = self {
2523            Some((filter, responder))
2524        } else {
2525            None
2526        }
2527    }
2528
2529    #[allow(irrefutable_let_patterns)]
2530    pub fn into_stop_scan(self) -> Option<(CentralControlHandle)> {
2531        if let CentralRequest::StopScan { control_handle } = self {
2532            Some((control_handle))
2533        } else {
2534            None
2535        }
2536    }
2537
2538    #[allow(irrefutable_let_patterns)]
2539    pub fn into_connect_peripheral(
2540        self,
2541    ) -> Option<(
2542        String,
2543        ConnectionOptions,
2544        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
2545        CentralConnectPeripheralResponder,
2546    )> {
2547        if let CentralRequest::ConnectPeripheral { identifier, options, gatt_client, responder } =
2548            self
2549        {
2550            Some((identifier, options, gatt_client, responder))
2551        } else {
2552            None
2553        }
2554    }
2555
2556    #[allow(irrefutable_let_patterns)]
2557    pub fn into_disconnect_peripheral(
2558        self,
2559    ) -> Option<(String, CentralDisconnectPeripheralResponder)> {
2560        if let CentralRequest::DisconnectPeripheral { identifier, responder } = self {
2561            Some((identifier, responder))
2562        } else {
2563            None
2564        }
2565    }
2566
2567    /// Name of the method defined in FIDL
2568    pub fn method_name(&self) -> &'static str {
2569        match *self {
2570            CentralRequest::ListenL2cap { .. } => "listen_l2cap",
2571            CentralRequest::Scan { .. } => "scan",
2572            CentralRequest::Connect { .. } => "connect",
2573            CentralRequest::SyncToPeriodicAdvertising { .. } => "sync_to_periodic_advertising",
2574            CentralRequest::CreateConnectedIsochronousGroup { .. } => {
2575                "create_connected_isochronous_group"
2576            }
2577            CentralRequest::GetPeripherals { .. } => "get_peripherals",
2578            CentralRequest::GetPeripheral { .. } => "get_peripheral",
2579            CentralRequest::StartScan { .. } => "start_scan",
2580            CentralRequest::StopScan { .. } => "stop_scan",
2581            CentralRequest::ConnectPeripheral { .. } => "connect_peripheral",
2582            CentralRequest::DisconnectPeripheral { .. } => "disconnect_peripheral",
2583        }
2584    }
2585}
2586
2587#[derive(Debug, Clone)]
2588pub struct CentralControlHandle {
2589    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2590}
2591
2592impl fidl::endpoints::ControlHandle for CentralControlHandle {
2593    fn shutdown(&self) {
2594        self.inner.shutdown()
2595    }
2596    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2597        self.inner.shutdown_with_epitaph(status)
2598    }
2599
2600    fn is_closed(&self) -> bool {
2601        self.inner.channel().is_closed()
2602    }
2603    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2604        self.inner.channel().on_closed()
2605    }
2606
2607    #[cfg(target_os = "fuchsia")]
2608    fn signal_peer(
2609        &self,
2610        clear_mask: zx::Signals,
2611        set_mask: zx::Signals,
2612    ) -> Result<(), zx_status::Status> {
2613        use fidl::Peered;
2614        self.inner.channel().signal_peer(clear_mask, set_mask)
2615    }
2616}
2617
2618impl CentralControlHandle {
2619    pub fn send_on_scan_state_changed(&self, mut scanning: bool) -> Result<(), fidl::Error> {
2620        self.inner.send::<CentralOnScanStateChangedRequest>(
2621            (scanning,),
2622            0,
2623            0x5f8edc23cad04d3f,
2624            fidl::encoding::DynamicFlags::empty(),
2625        )
2626    }
2627
2628    pub fn send_on_device_discovered(&self, mut device: &RemoteDevice) -> Result<(), fidl::Error> {
2629        self.inner.send::<CentralOnDeviceDiscoveredRequest>(
2630            (device,),
2631            0,
2632            0x708dadf20d66db6,
2633            fidl::encoding::DynamicFlags::empty(),
2634        )
2635    }
2636
2637    pub fn send_on_peripheral_disconnected(&self, mut identifier: &str) -> Result<(), fidl::Error> {
2638        self.inner.send::<CentralOnPeripheralDisconnectedRequest>(
2639            (identifier,),
2640            0,
2641            0x4e4c6b979b2126df,
2642            fidl::encoding::DynamicFlags::empty(),
2643        )
2644    }
2645}
2646
2647#[must_use = "FIDL methods require a response to be sent"]
2648#[derive(Debug)]
2649pub struct CentralListenL2capResponder {
2650    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2651    tx_id: u32,
2652}
2653
2654/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2655/// if the responder is dropped without sending a response, so that the client
2656/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2657impl std::ops::Drop for CentralListenL2capResponder {
2658    fn drop(&mut self) {
2659        self.control_handle.shutdown();
2660        // Safety: drops once, never accessed again
2661        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2662    }
2663}
2664
2665impl fidl::endpoints::Responder for CentralListenL2capResponder {
2666    type ControlHandle = CentralControlHandle;
2667
2668    fn control_handle(&self) -> &CentralControlHandle {
2669        &self.control_handle
2670    }
2671
2672    fn drop_without_shutdown(mut self) {
2673        // Safety: drops once, never accessed again due to mem::forget
2674        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2675        // Prevent Drop from running (which would shut down the channel)
2676        std::mem::forget(self);
2677    }
2678}
2679
2680impl CentralListenL2capResponder {
2681    /// Sends a response to the FIDL transaction.
2682    ///
2683    /// Sets the channel to shutdown if an error occurs.
2684    pub fn send(
2685        self,
2686        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2687    ) -> Result<(), fidl::Error> {
2688        let _result = self.send_raw(result);
2689        if _result.is_err() {
2690            self.control_handle.shutdown();
2691        }
2692        self.drop_without_shutdown();
2693        _result
2694    }
2695
2696    /// Similar to "send" but does not shutdown the channel if an error occurs.
2697    pub fn send_no_shutdown_on_err(
2698        self,
2699        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2700    ) -> Result<(), fidl::Error> {
2701        let _result = self.send_raw(result);
2702        self.drop_without_shutdown();
2703        _result
2704    }
2705
2706    fn send_raw(
2707        &self,
2708        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2709    ) -> Result<(), fidl::Error> {
2710        self.control_handle.inner.send::<fidl::encoding::ResultType<
2711            ChannelListenerRegistryListenL2capResponse,
2712            i32,
2713        >>(
2714            result,
2715            self.tx_id,
2716            0x39c6e9001d102338,
2717            fidl::encoding::DynamicFlags::empty(),
2718        )
2719    }
2720}
2721
2722#[must_use = "FIDL methods require a response to be sent"]
2723#[derive(Debug)]
2724pub struct CentralScanResponder {
2725    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2726    tx_id: u32,
2727}
2728
2729/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2730/// if the responder is dropped without sending a response, so that the client
2731/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2732impl std::ops::Drop for CentralScanResponder {
2733    fn drop(&mut self) {
2734        self.control_handle.shutdown();
2735        // Safety: drops once, never accessed again
2736        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2737    }
2738}
2739
2740impl fidl::endpoints::Responder for CentralScanResponder {
2741    type ControlHandle = CentralControlHandle;
2742
2743    fn control_handle(&self) -> &CentralControlHandle {
2744        &self.control_handle
2745    }
2746
2747    fn drop_without_shutdown(mut self) {
2748        // Safety: drops once, never accessed again due to mem::forget
2749        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2750        // Prevent Drop from running (which would shut down the channel)
2751        std::mem::forget(self);
2752    }
2753}
2754
2755impl CentralScanResponder {
2756    /// Sends a response to the FIDL transaction.
2757    ///
2758    /// Sets the channel to shutdown if an error occurs.
2759    pub fn send(self) -> Result<(), fidl::Error> {
2760        let _result = self.send_raw();
2761        if _result.is_err() {
2762            self.control_handle.shutdown();
2763        }
2764        self.drop_without_shutdown();
2765        _result
2766    }
2767
2768    /// Similar to "send" but does not shutdown the channel if an error occurs.
2769    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2770        let _result = self.send_raw();
2771        self.drop_without_shutdown();
2772        _result
2773    }
2774
2775    fn send_raw(&self) -> Result<(), fidl::Error> {
2776        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2777            (),
2778            self.tx_id,
2779            0x41f7121798dfe15f,
2780            fidl::encoding::DynamicFlags::empty(),
2781        )
2782    }
2783}
2784
2785#[must_use = "FIDL methods require a response to be sent"]
2786#[derive(Debug)]
2787pub struct CentralCreateConnectedIsochronousGroupResponder {
2788    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2789    tx_id: u32,
2790}
2791
2792/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2793/// if the responder is dropped without sending a response, so that the client
2794/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2795impl std::ops::Drop for CentralCreateConnectedIsochronousGroupResponder {
2796    fn drop(&mut self) {
2797        self.control_handle.shutdown();
2798        // Safety: drops once, never accessed again
2799        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2800    }
2801}
2802
2803impl fidl::endpoints::Responder for CentralCreateConnectedIsochronousGroupResponder {
2804    type ControlHandle = CentralControlHandle;
2805
2806    fn control_handle(&self) -> &CentralControlHandle {
2807        &self.control_handle
2808    }
2809
2810    fn drop_without_shutdown(mut self) {
2811        // Safety: drops once, never accessed again due to mem::forget
2812        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2813        // Prevent Drop from running (which would shut down the channel)
2814        std::mem::forget(self);
2815    }
2816}
2817
2818impl CentralCreateConnectedIsochronousGroupResponder {
2819    /// Sends a response to the FIDL transaction.
2820    ///
2821    /// Sets the channel to shutdown if an error occurs.
2822    pub fn send(
2823        self,
2824        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2825    ) -> Result<(), fidl::Error> {
2826        let _result = self.send_raw(result);
2827        if _result.is_err() {
2828            self.control_handle.shutdown();
2829        }
2830        self.drop_without_shutdown();
2831        _result
2832    }
2833
2834    /// Similar to "send" but does not shutdown the channel if an error occurs.
2835    pub fn send_no_shutdown_on_err(
2836        self,
2837        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2838    ) -> Result<(), fidl::Error> {
2839        let _result = self.send_raw(result);
2840        self.drop_without_shutdown();
2841        _result
2842    }
2843
2844    fn send_raw(
2845        &self,
2846        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2847    ) -> Result<(), fidl::Error> {
2848        self.control_handle.inner.send::<fidl::encoding::ResultType<
2849            CentralCreateConnectedIsochronousGroupResponse,
2850            CreateCigError,
2851        >>(
2852            result,
2853            self.tx_id,
2854            0x60323e70ae22e13,
2855            fidl::encoding::DynamicFlags::empty(),
2856        )
2857    }
2858}
2859
2860#[must_use = "FIDL methods require a response to be sent"]
2861#[derive(Debug)]
2862pub struct CentralGetPeripheralsResponder {
2863    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2864    tx_id: u32,
2865}
2866
2867/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2868/// if the responder is dropped without sending a response, so that the client
2869/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2870impl std::ops::Drop for CentralGetPeripheralsResponder {
2871    fn drop(&mut self) {
2872        self.control_handle.shutdown();
2873        // Safety: drops once, never accessed again
2874        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2875    }
2876}
2877
2878impl fidl::endpoints::Responder for CentralGetPeripheralsResponder {
2879    type ControlHandle = CentralControlHandle;
2880
2881    fn control_handle(&self) -> &CentralControlHandle {
2882        &self.control_handle
2883    }
2884
2885    fn drop_without_shutdown(mut self) {
2886        // Safety: drops once, never accessed again due to mem::forget
2887        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2888        // Prevent Drop from running (which would shut down the channel)
2889        std::mem::forget(self);
2890    }
2891}
2892
2893impl CentralGetPeripheralsResponder {
2894    /// Sends a response to the FIDL transaction.
2895    ///
2896    /// Sets the channel to shutdown if an error occurs.
2897    pub fn send(self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
2898        let _result = self.send_raw(peripherals);
2899        if _result.is_err() {
2900            self.control_handle.shutdown();
2901        }
2902        self.drop_without_shutdown();
2903        _result
2904    }
2905
2906    /// Similar to "send" but does not shutdown the channel if an error occurs.
2907    pub fn send_no_shutdown_on_err(
2908        self,
2909        mut peripherals: &[RemoteDevice],
2910    ) -> Result<(), fidl::Error> {
2911        let _result = self.send_raw(peripherals);
2912        self.drop_without_shutdown();
2913        _result
2914    }
2915
2916    fn send_raw(&self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
2917        self.control_handle.inner.send::<CentralGetPeripheralsResponse>(
2918            (peripherals,),
2919            self.tx_id,
2920            0x37ba777499c683a8,
2921            fidl::encoding::DynamicFlags::empty(),
2922        )
2923    }
2924}
2925
2926#[must_use = "FIDL methods require a response to be sent"]
2927#[derive(Debug)]
2928pub struct CentralGetPeripheralResponder {
2929    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2930    tx_id: u32,
2931}
2932
2933/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2934/// if the responder is dropped without sending a response, so that the client
2935/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2936impl std::ops::Drop for CentralGetPeripheralResponder {
2937    fn drop(&mut self) {
2938        self.control_handle.shutdown();
2939        // Safety: drops once, never accessed again
2940        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2941    }
2942}
2943
2944impl fidl::endpoints::Responder for CentralGetPeripheralResponder {
2945    type ControlHandle = CentralControlHandle;
2946
2947    fn control_handle(&self) -> &CentralControlHandle {
2948        &self.control_handle
2949    }
2950
2951    fn drop_without_shutdown(mut self) {
2952        // Safety: drops once, never accessed again due to mem::forget
2953        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2954        // Prevent Drop from running (which would shut down the channel)
2955        std::mem::forget(self);
2956    }
2957}
2958
2959impl CentralGetPeripheralResponder {
2960    /// Sends a response to the FIDL transaction.
2961    ///
2962    /// Sets the channel to shutdown if an error occurs.
2963    pub fn send(self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
2964        let _result = self.send_raw(peripheral);
2965        if _result.is_err() {
2966            self.control_handle.shutdown();
2967        }
2968        self.drop_without_shutdown();
2969        _result
2970    }
2971
2972    /// Similar to "send" but does not shutdown the channel if an error occurs.
2973    pub fn send_no_shutdown_on_err(
2974        self,
2975        mut peripheral: Option<&RemoteDevice>,
2976    ) -> Result<(), fidl::Error> {
2977        let _result = self.send_raw(peripheral);
2978        self.drop_without_shutdown();
2979        _result
2980    }
2981
2982    fn send_raw(&self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
2983        self.control_handle.inner.send::<CentralGetPeripheralResponse>(
2984            (peripheral,),
2985            self.tx_id,
2986            0x97f5a2f2d9c13da,
2987            fidl::encoding::DynamicFlags::empty(),
2988        )
2989    }
2990}
2991
2992#[must_use = "FIDL methods require a response to be sent"]
2993#[derive(Debug)]
2994pub struct CentralStartScanResponder {
2995    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2996    tx_id: u32,
2997}
2998
2999/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3000/// if the responder is dropped without sending a response, so that the client
3001/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3002impl std::ops::Drop for CentralStartScanResponder {
3003    fn drop(&mut self) {
3004        self.control_handle.shutdown();
3005        // Safety: drops once, never accessed again
3006        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3007    }
3008}
3009
3010impl fidl::endpoints::Responder for CentralStartScanResponder {
3011    type ControlHandle = CentralControlHandle;
3012
3013    fn control_handle(&self) -> &CentralControlHandle {
3014        &self.control_handle
3015    }
3016
3017    fn drop_without_shutdown(mut self) {
3018        // Safety: drops once, never accessed again due to mem::forget
3019        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3020        // Prevent Drop from running (which would shut down the channel)
3021        std::mem::forget(self);
3022    }
3023}
3024
3025impl CentralStartScanResponder {
3026    /// Sends a response to the FIDL transaction.
3027    ///
3028    /// Sets the channel to shutdown if an error occurs.
3029    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3030        let _result = self.send_raw(status);
3031        if _result.is_err() {
3032            self.control_handle.shutdown();
3033        }
3034        self.drop_without_shutdown();
3035        _result
3036    }
3037
3038    /// Similar to "send" but does not shutdown the channel if an error occurs.
3039    pub fn send_no_shutdown_on_err(
3040        self,
3041        mut status: &fidl_fuchsia_bluetooth::Status,
3042    ) -> Result<(), fidl::Error> {
3043        let _result = self.send_raw(status);
3044        self.drop_without_shutdown();
3045        _result
3046    }
3047
3048    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3049        self.control_handle.inner.send::<CentralStartScanResponse>(
3050            (status,),
3051            self.tx_id,
3052            0xeb4cf0cd0e1132b,
3053            fidl::encoding::DynamicFlags::empty(),
3054        )
3055    }
3056}
3057
3058#[must_use = "FIDL methods require a response to be sent"]
3059#[derive(Debug)]
3060pub struct CentralConnectPeripheralResponder {
3061    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
3062    tx_id: u32,
3063}
3064
3065/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3066/// if the responder is dropped without sending a response, so that the client
3067/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3068impl std::ops::Drop for CentralConnectPeripheralResponder {
3069    fn drop(&mut self) {
3070        self.control_handle.shutdown();
3071        // Safety: drops once, never accessed again
3072        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3073    }
3074}
3075
3076impl fidl::endpoints::Responder for CentralConnectPeripheralResponder {
3077    type ControlHandle = CentralControlHandle;
3078
3079    fn control_handle(&self) -> &CentralControlHandle {
3080        &self.control_handle
3081    }
3082
3083    fn drop_without_shutdown(mut self) {
3084        // Safety: drops once, never accessed again due to mem::forget
3085        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3086        // Prevent Drop from running (which would shut down the channel)
3087        std::mem::forget(self);
3088    }
3089}
3090
3091impl CentralConnectPeripheralResponder {
3092    /// Sends a response to the FIDL transaction.
3093    ///
3094    /// Sets the channel to shutdown if an error occurs.
3095    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3096        let _result = self.send_raw(status);
3097        if _result.is_err() {
3098            self.control_handle.shutdown();
3099        }
3100        self.drop_without_shutdown();
3101        _result
3102    }
3103
3104    /// Similar to "send" but does not shutdown the channel if an error occurs.
3105    pub fn send_no_shutdown_on_err(
3106        self,
3107        mut status: &fidl_fuchsia_bluetooth::Status,
3108    ) -> Result<(), fidl::Error> {
3109        let _result = self.send_raw(status);
3110        self.drop_without_shutdown();
3111        _result
3112    }
3113
3114    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3115        self.control_handle.inner.send::<CentralConnectPeripheralResponse>(
3116            (status,),
3117            self.tx_id,
3118            0x714d6c32d066d75a,
3119            fidl::encoding::DynamicFlags::empty(),
3120        )
3121    }
3122}
3123
3124#[must_use = "FIDL methods require a response to be sent"]
3125#[derive(Debug)]
3126pub struct CentralDisconnectPeripheralResponder {
3127    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
3128    tx_id: u32,
3129}
3130
3131/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3132/// if the responder is dropped without sending a response, so that the client
3133/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3134impl std::ops::Drop for CentralDisconnectPeripheralResponder {
3135    fn drop(&mut self) {
3136        self.control_handle.shutdown();
3137        // Safety: drops once, never accessed again
3138        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3139    }
3140}
3141
3142impl fidl::endpoints::Responder for CentralDisconnectPeripheralResponder {
3143    type ControlHandle = CentralControlHandle;
3144
3145    fn control_handle(&self) -> &CentralControlHandle {
3146        &self.control_handle
3147    }
3148
3149    fn drop_without_shutdown(mut self) {
3150        // Safety: drops once, never accessed again due to mem::forget
3151        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3152        // Prevent Drop from running (which would shut down the channel)
3153        std::mem::forget(self);
3154    }
3155}
3156
3157impl CentralDisconnectPeripheralResponder {
3158    /// Sends a response to the FIDL transaction.
3159    ///
3160    /// Sets the channel to shutdown if an error occurs.
3161    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3162        let _result = self.send_raw(status);
3163        if _result.is_err() {
3164            self.control_handle.shutdown();
3165        }
3166        self.drop_without_shutdown();
3167        _result
3168    }
3169
3170    /// Similar to "send" but does not shutdown the channel if an error occurs.
3171    pub fn send_no_shutdown_on_err(
3172        self,
3173        mut status: &fidl_fuchsia_bluetooth::Status,
3174    ) -> Result<(), fidl::Error> {
3175        let _result = self.send_raw(status);
3176        self.drop_without_shutdown();
3177        _result
3178    }
3179
3180    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3181        self.control_handle.inner.send::<CentralDisconnectPeripheralResponse>(
3182            (status,),
3183            self.tx_id,
3184            0xa9430da197362fd,
3185            fidl::encoding::DynamicFlags::empty(),
3186        )
3187    }
3188}
3189
3190#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3191pub struct ChannelListenerMarker;
3192
3193impl fidl::endpoints::ProtocolMarker for ChannelListenerMarker {
3194    type Proxy = ChannelListenerProxy;
3195    type RequestStream = ChannelListenerRequestStream;
3196    #[cfg(target_os = "fuchsia")]
3197    type SynchronousProxy = ChannelListenerSynchronousProxy;
3198
3199    const DEBUG_NAME: &'static str = "(anonymous) ChannelListener";
3200}
3201
3202pub trait ChannelListenerProxyInterface: Send + Sync {
3203    type AcceptResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3204    fn r#accept(
3205        &self,
3206        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3207    ) -> Self::AcceptResponseFut;
3208}
3209#[derive(Debug)]
3210#[cfg(target_os = "fuchsia")]
3211pub struct ChannelListenerSynchronousProxy {
3212    client: fidl::client::sync::Client,
3213}
3214
3215#[cfg(target_os = "fuchsia")]
3216impl fidl::endpoints::SynchronousProxy for ChannelListenerSynchronousProxy {
3217    type Proxy = ChannelListenerProxy;
3218    type Protocol = ChannelListenerMarker;
3219
3220    fn from_channel(inner: fidl::Channel) -> Self {
3221        Self::new(inner)
3222    }
3223
3224    fn into_channel(self) -> fidl::Channel {
3225        self.client.into_channel()
3226    }
3227
3228    fn as_channel(&self) -> &fidl::Channel {
3229        self.client.as_channel()
3230    }
3231}
3232
3233#[cfg(target_os = "fuchsia")]
3234impl ChannelListenerSynchronousProxy {
3235    pub fn new(channel: fidl::Channel) -> Self {
3236        let protocol_name = <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3237        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3238    }
3239
3240    pub fn into_channel(self) -> fidl::Channel {
3241        self.client.into_channel()
3242    }
3243
3244    /// Waits until an event arrives and returns it. It is safe for other
3245    /// threads to make concurrent requests while waiting for an event.
3246    pub fn wait_for_event(
3247        &self,
3248        deadline: zx::MonotonicInstant,
3249    ) -> Result<ChannelListenerEvent, fidl::Error> {
3250        ChannelListenerEvent::decode(self.client.wait_for_event(deadline)?)
3251    }
3252
3253    pub fn r#accept(
3254        &self,
3255        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3256        ___deadline: zx::MonotonicInstant,
3257    ) -> Result<(), fidl::Error> {
3258        let _response = self.client.send_query::<
3259            ChannelListenerAcceptRequest,
3260            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3261        >(
3262            (channel,),
3263            0x6f535bd36b20fc7b,
3264            fidl::encoding::DynamicFlags::FLEXIBLE,
3265            ___deadline,
3266        )?
3267        .into_result::<ChannelListenerMarker>("accept")?;
3268        Ok(_response)
3269    }
3270}
3271
3272#[cfg(target_os = "fuchsia")]
3273impl From<ChannelListenerSynchronousProxy> for zx::Handle {
3274    fn from(value: ChannelListenerSynchronousProxy) -> Self {
3275        value.into_channel().into()
3276    }
3277}
3278
3279#[cfg(target_os = "fuchsia")]
3280impl From<fidl::Channel> for ChannelListenerSynchronousProxy {
3281    fn from(value: fidl::Channel) -> Self {
3282        Self::new(value)
3283    }
3284}
3285
3286#[cfg(target_os = "fuchsia")]
3287impl fidl::endpoints::FromClient for ChannelListenerSynchronousProxy {
3288    type Protocol = ChannelListenerMarker;
3289
3290    fn from_client(value: fidl::endpoints::ClientEnd<ChannelListenerMarker>) -> Self {
3291        Self::new(value.into_channel())
3292    }
3293}
3294
3295#[derive(Debug, Clone)]
3296pub struct ChannelListenerProxy {
3297    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3298}
3299
3300impl fidl::endpoints::Proxy for ChannelListenerProxy {
3301    type Protocol = ChannelListenerMarker;
3302
3303    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3304        Self::new(inner)
3305    }
3306
3307    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3308        self.client.into_channel().map_err(|client| Self { client })
3309    }
3310
3311    fn as_channel(&self) -> &::fidl::AsyncChannel {
3312        self.client.as_channel()
3313    }
3314}
3315
3316impl ChannelListenerProxy {
3317    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelListener.
3318    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3319        let protocol_name = <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3320        Self { client: fidl::client::Client::new(channel, protocol_name) }
3321    }
3322
3323    /// Get a Stream of events from the remote end of the protocol.
3324    ///
3325    /// # Panics
3326    ///
3327    /// Panics if the event stream was already taken.
3328    pub fn take_event_stream(&self) -> ChannelListenerEventStream {
3329        ChannelListenerEventStream { event_receiver: self.client.take_event_receiver() }
3330    }
3331
3332    pub fn r#accept(
3333        &self,
3334        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3335    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3336        ChannelListenerProxyInterface::r#accept(self, channel)
3337    }
3338}
3339
3340impl ChannelListenerProxyInterface for ChannelListenerProxy {
3341    type AcceptResponseFut =
3342        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3343    fn r#accept(
3344        &self,
3345        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3346    ) -> Self::AcceptResponseFut {
3347        fn _decode(
3348            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3349        ) -> Result<(), fidl::Error> {
3350            let _response = fidl::client::decode_transaction_body::<
3351                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3352                fidl::encoding::DefaultFuchsiaResourceDialect,
3353                0x6f535bd36b20fc7b,
3354            >(_buf?)?
3355            .into_result::<ChannelListenerMarker>("accept")?;
3356            Ok(_response)
3357        }
3358        self.client.send_query_and_decode::<ChannelListenerAcceptRequest, ()>(
3359            (channel,),
3360            0x6f535bd36b20fc7b,
3361            fidl::encoding::DynamicFlags::FLEXIBLE,
3362            _decode,
3363        )
3364    }
3365}
3366
3367pub struct ChannelListenerEventStream {
3368    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3369}
3370
3371impl std::marker::Unpin for ChannelListenerEventStream {}
3372
3373impl futures::stream::FusedStream for ChannelListenerEventStream {
3374    fn is_terminated(&self) -> bool {
3375        self.event_receiver.is_terminated()
3376    }
3377}
3378
3379impl futures::Stream for ChannelListenerEventStream {
3380    type Item = Result<ChannelListenerEvent, fidl::Error>;
3381
3382    fn poll_next(
3383        mut self: std::pin::Pin<&mut Self>,
3384        cx: &mut std::task::Context<'_>,
3385    ) -> std::task::Poll<Option<Self::Item>> {
3386        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3387            &mut self.event_receiver,
3388            cx
3389        )?) {
3390            Some(buf) => std::task::Poll::Ready(Some(ChannelListenerEvent::decode(buf))),
3391            None => std::task::Poll::Ready(None),
3392        }
3393    }
3394}
3395
3396#[derive(Debug)]
3397pub enum ChannelListenerEvent {
3398    #[non_exhaustive]
3399    _UnknownEvent {
3400        /// Ordinal of the event that was sent.
3401        ordinal: u64,
3402    },
3403}
3404
3405impl ChannelListenerEvent {
3406    /// Decodes a message buffer as a [`ChannelListenerEvent`].
3407    fn decode(
3408        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3409    ) -> Result<ChannelListenerEvent, fidl::Error> {
3410        let (bytes, _handles) = buf.split_mut();
3411        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3412        debug_assert_eq!(tx_header.tx_id, 0);
3413        match tx_header.ordinal {
3414            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3415                Ok(ChannelListenerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3416            }
3417            _ => Err(fidl::Error::UnknownOrdinal {
3418                ordinal: tx_header.ordinal,
3419                protocol_name:
3420                    <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3421            }),
3422        }
3423    }
3424}
3425
3426/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelListener.
3427pub struct ChannelListenerRequestStream {
3428    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3429    is_terminated: bool,
3430}
3431
3432impl std::marker::Unpin for ChannelListenerRequestStream {}
3433
3434impl futures::stream::FusedStream for ChannelListenerRequestStream {
3435    fn is_terminated(&self) -> bool {
3436        self.is_terminated
3437    }
3438}
3439
3440impl fidl::endpoints::RequestStream for ChannelListenerRequestStream {
3441    type Protocol = ChannelListenerMarker;
3442    type ControlHandle = ChannelListenerControlHandle;
3443
3444    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3445        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3446    }
3447
3448    fn control_handle(&self) -> Self::ControlHandle {
3449        ChannelListenerControlHandle { inner: self.inner.clone() }
3450    }
3451
3452    fn into_inner(
3453        self,
3454    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3455    {
3456        (self.inner, self.is_terminated)
3457    }
3458
3459    fn from_inner(
3460        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3461        is_terminated: bool,
3462    ) -> Self {
3463        Self { inner, is_terminated }
3464    }
3465}
3466
3467impl futures::Stream for ChannelListenerRequestStream {
3468    type Item = Result<ChannelListenerRequest, fidl::Error>;
3469
3470    fn poll_next(
3471        mut self: std::pin::Pin<&mut Self>,
3472        cx: &mut std::task::Context<'_>,
3473    ) -> std::task::Poll<Option<Self::Item>> {
3474        let this = &mut *self;
3475        if this.inner.check_shutdown(cx) {
3476            this.is_terminated = true;
3477            return std::task::Poll::Ready(None);
3478        }
3479        if this.is_terminated {
3480            panic!("polled ChannelListenerRequestStream after completion");
3481        }
3482        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3483            |bytes, handles| {
3484                match this.inner.channel().read_etc(cx, bytes, handles) {
3485                    std::task::Poll::Ready(Ok(())) => {}
3486                    std::task::Poll::Pending => return std::task::Poll::Pending,
3487                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3488                        this.is_terminated = true;
3489                        return std::task::Poll::Ready(None);
3490                    }
3491                    std::task::Poll::Ready(Err(e)) => {
3492                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3493                            e.into(),
3494                        ))));
3495                    }
3496                }
3497
3498                // A message has been received from the channel
3499                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3500
3501                std::task::Poll::Ready(Some(match header.ordinal {
3502                    0x6f535bd36b20fc7b => {
3503                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3504                        let mut req = fidl::new_empty!(
3505                            ChannelListenerAcceptRequest,
3506                            fidl::encoding::DefaultFuchsiaResourceDialect
3507                        );
3508                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
3509                        let control_handle =
3510                            ChannelListenerControlHandle { inner: this.inner.clone() };
3511                        Ok(ChannelListenerRequest::Accept {
3512                            channel: req.channel,
3513
3514                            responder: ChannelListenerAcceptResponder {
3515                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3516                                tx_id: header.tx_id,
3517                            },
3518                        })
3519                    }
3520                    _ if header.tx_id == 0
3521                        && header
3522                            .dynamic_flags()
3523                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3524                    {
3525                        Ok(ChannelListenerRequest::_UnknownMethod {
3526                            ordinal: header.ordinal,
3527                            control_handle: ChannelListenerControlHandle {
3528                                inner: this.inner.clone(),
3529                            },
3530                            method_type: fidl::MethodType::OneWay,
3531                        })
3532                    }
3533                    _ if header
3534                        .dynamic_flags()
3535                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3536                    {
3537                        this.inner.send_framework_err(
3538                            fidl::encoding::FrameworkErr::UnknownMethod,
3539                            header.tx_id,
3540                            header.ordinal,
3541                            header.dynamic_flags(),
3542                            (bytes, handles),
3543                        )?;
3544                        Ok(ChannelListenerRequest::_UnknownMethod {
3545                            ordinal: header.ordinal,
3546                            control_handle: ChannelListenerControlHandle {
3547                                inner: this.inner.clone(),
3548                            },
3549                            method_type: fidl::MethodType::TwoWay,
3550                        })
3551                    }
3552                    _ => Err(fidl::Error::UnknownOrdinal {
3553                        ordinal: header.ordinal,
3554                        protocol_name:
3555                            <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3556                    }),
3557                }))
3558            },
3559        )
3560    }
3561}
3562
3563/// Represents a service or protocol that accepts incoming channel requests.
3564/// Incoming channel requests for the associated PSM will be connected via this
3565/// protocol. Closing this protocol will also cease accepting any incoming
3566/// channel requests, but existing established channels will not be affected.
3567/// Additionally, once this protocol is closed the implementation is free to
3568/// reuse the PSM that was previously assigned for this instance.
3569#[derive(Debug)]
3570pub enum ChannelListenerRequest {
3571    Accept {
3572        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3573        responder: ChannelListenerAcceptResponder,
3574    },
3575    /// An interaction was received which does not match any known method.
3576    #[non_exhaustive]
3577    _UnknownMethod {
3578        /// Ordinal of the method that was called.
3579        ordinal: u64,
3580        control_handle: ChannelListenerControlHandle,
3581        method_type: fidl::MethodType,
3582    },
3583}
3584
3585impl ChannelListenerRequest {
3586    #[allow(irrefutable_let_patterns)]
3587    pub fn into_accept(
3588        self,
3589    ) -> Option<(
3590        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3591        ChannelListenerAcceptResponder,
3592    )> {
3593        if let ChannelListenerRequest::Accept { channel, responder } = self {
3594            Some((channel, responder))
3595        } else {
3596            None
3597        }
3598    }
3599
3600    /// Name of the method defined in FIDL
3601    pub fn method_name(&self) -> &'static str {
3602        match *self {
3603            ChannelListenerRequest::Accept { .. } => "accept",
3604            ChannelListenerRequest::_UnknownMethod {
3605                method_type: fidl::MethodType::OneWay,
3606                ..
3607            } => "unknown one-way method",
3608            ChannelListenerRequest::_UnknownMethod {
3609                method_type: fidl::MethodType::TwoWay,
3610                ..
3611            } => "unknown two-way method",
3612        }
3613    }
3614}
3615
3616#[derive(Debug, Clone)]
3617pub struct ChannelListenerControlHandle {
3618    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3619}
3620
3621impl fidl::endpoints::ControlHandle for ChannelListenerControlHandle {
3622    fn shutdown(&self) {
3623        self.inner.shutdown()
3624    }
3625    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3626        self.inner.shutdown_with_epitaph(status)
3627    }
3628
3629    fn is_closed(&self) -> bool {
3630        self.inner.channel().is_closed()
3631    }
3632    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3633        self.inner.channel().on_closed()
3634    }
3635
3636    #[cfg(target_os = "fuchsia")]
3637    fn signal_peer(
3638        &self,
3639        clear_mask: zx::Signals,
3640        set_mask: zx::Signals,
3641    ) -> Result<(), zx_status::Status> {
3642        use fidl::Peered;
3643        self.inner.channel().signal_peer(clear_mask, set_mask)
3644    }
3645}
3646
3647impl ChannelListenerControlHandle {}
3648
3649#[must_use = "FIDL methods require a response to be sent"]
3650#[derive(Debug)]
3651pub struct ChannelListenerAcceptResponder {
3652    control_handle: std::mem::ManuallyDrop<ChannelListenerControlHandle>,
3653    tx_id: u32,
3654}
3655
3656/// Set the the channel to be shutdown (see [`ChannelListenerControlHandle::shutdown`])
3657/// if the responder is dropped without sending a response, so that the client
3658/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3659impl std::ops::Drop for ChannelListenerAcceptResponder {
3660    fn drop(&mut self) {
3661        self.control_handle.shutdown();
3662        // Safety: drops once, never accessed again
3663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3664    }
3665}
3666
3667impl fidl::endpoints::Responder for ChannelListenerAcceptResponder {
3668    type ControlHandle = ChannelListenerControlHandle;
3669
3670    fn control_handle(&self) -> &ChannelListenerControlHandle {
3671        &self.control_handle
3672    }
3673
3674    fn drop_without_shutdown(mut self) {
3675        // Safety: drops once, never accessed again due to mem::forget
3676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3677        // Prevent Drop from running (which would shut down the channel)
3678        std::mem::forget(self);
3679    }
3680}
3681
3682impl ChannelListenerAcceptResponder {
3683    /// Sends a response to the FIDL transaction.
3684    ///
3685    /// Sets the channel to shutdown if an error occurs.
3686    pub fn send(self) -> Result<(), fidl::Error> {
3687        let _result = self.send_raw();
3688        if _result.is_err() {
3689            self.control_handle.shutdown();
3690        }
3691        self.drop_without_shutdown();
3692        _result
3693    }
3694
3695    /// Similar to "send" but does not shutdown the channel if an error occurs.
3696    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3697        let _result = self.send_raw();
3698        self.drop_without_shutdown();
3699        _result
3700    }
3701
3702    fn send_raw(&self) -> Result<(), fidl::Error> {
3703        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3704            fidl::encoding::Flexible::new(()),
3705            self.tx_id,
3706            0x6f535bd36b20fc7b,
3707            fidl::encoding::DynamicFlags::FLEXIBLE,
3708        )
3709    }
3710}
3711
3712#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3713pub struct ChannelListenerRegistryMarker;
3714
3715impl fidl::endpoints::ProtocolMarker for ChannelListenerRegistryMarker {
3716    type Proxy = ChannelListenerRegistryProxy;
3717    type RequestStream = ChannelListenerRegistryRequestStream;
3718    #[cfg(target_os = "fuchsia")]
3719    type SynchronousProxy = ChannelListenerRegistrySynchronousProxy;
3720
3721    const DEBUG_NAME: &'static str = "(anonymous) ChannelListenerRegistry";
3722}
3723pub type ChannelListenerRegistryListenL2capResult =
3724    Result<ChannelListenerRegistryListenL2capResponse, i32>;
3725
3726pub trait ChannelListenerRegistryProxyInterface: Send + Sync {
3727    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
3728        + Send;
3729    fn r#listen_l2cap(
3730        &self,
3731        payload: ChannelListenerRegistryListenL2capRequest,
3732    ) -> Self::ListenL2capResponseFut;
3733}
3734#[derive(Debug)]
3735#[cfg(target_os = "fuchsia")]
3736pub struct ChannelListenerRegistrySynchronousProxy {
3737    client: fidl::client::sync::Client,
3738}
3739
3740#[cfg(target_os = "fuchsia")]
3741impl fidl::endpoints::SynchronousProxy for ChannelListenerRegistrySynchronousProxy {
3742    type Proxy = ChannelListenerRegistryProxy;
3743    type Protocol = ChannelListenerRegistryMarker;
3744
3745    fn from_channel(inner: fidl::Channel) -> Self {
3746        Self::new(inner)
3747    }
3748
3749    fn into_channel(self) -> fidl::Channel {
3750        self.client.into_channel()
3751    }
3752
3753    fn as_channel(&self) -> &fidl::Channel {
3754        self.client.as_channel()
3755    }
3756}
3757
3758#[cfg(target_os = "fuchsia")]
3759impl ChannelListenerRegistrySynchronousProxy {
3760    pub fn new(channel: fidl::Channel) -> Self {
3761        let protocol_name =
3762            <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3763        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3764    }
3765
3766    pub fn into_channel(self) -> fidl::Channel {
3767        self.client.into_channel()
3768    }
3769
3770    /// Waits until an event arrives and returns it. It is safe for other
3771    /// threads to make concurrent requests while waiting for an event.
3772    pub fn wait_for_event(
3773        &self,
3774        deadline: zx::MonotonicInstant,
3775    ) -> Result<ChannelListenerRegistryEvent, fidl::Error> {
3776        ChannelListenerRegistryEvent::decode(self.client.wait_for_event(deadline)?)
3777    }
3778
3779    /// Register a listener for incoming channels. The registry will assign a
3780    /// PSM value that is unique for the local device, as well as open a
3781    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
3782    /// event that all PSMs have been assigned, this call will fail with
3783    /// `ZX_ERR_NO_RESOURCES`.
3784    ///
3785    /// Note that the method of service discovery or advertising is defined by
3786    /// the service or protocol, so it is the responsibility of the caller to
3787    /// communicate the assigned PSM to any clients.
3788    pub fn r#listen_l2cap(
3789        &self,
3790        mut payload: ChannelListenerRegistryListenL2capRequest,
3791        ___deadline: zx::MonotonicInstant,
3792    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
3793        let _response = self.client.send_query::<
3794            ChannelListenerRegistryListenL2capRequest,
3795            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
3796        >(
3797            &mut payload,
3798            0x39c6e9001d102338,
3799            fidl::encoding::DynamicFlags::empty(),
3800            ___deadline,
3801        )?;
3802        Ok(_response.map(|x| x))
3803    }
3804}
3805
3806#[cfg(target_os = "fuchsia")]
3807impl From<ChannelListenerRegistrySynchronousProxy> for zx::Handle {
3808    fn from(value: ChannelListenerRegistrySynchronousProxy) -> Self {
3809        value.into_channel().into()
3810    }
3811}
3812
3813#[cfg(target_os = "fuchsia")]
3814impl From<fidl::Channel> for ChannelListenerRegistrySynchronousProxy {
3815    fn from(value: fidl::Channel) -> Self {
3816        Self::new(value)
3817    }
3818}
3819
3820#[cfg(target_os = "fuchsia")]
3821impl fidl::endpoints::FromClient for ChannelListenerRegistrySynchronousProxy {
3822    type Protocol = ChannelListenerRegistryMarker;
3823
3824    fn from_client(value: fidl::endpoints::ClientEnd<ChannelListenerRegistryMarker>) -> Self {
3825        Self::new(value.into_channel())
3826    }
3827}
3828
3829#[derive(Debug, Clone)]
3830pub struct ChannelListenerRegistryProxy {
3831    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3832}
3833
3834impl fidl::endpoints::Proxy for ChannelListenerRegistryProxy {
3835    type Protocol = ChannelListenerRegistryMarker;
3836
3837    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3838        Self::new(inner)
3839    }
3840
3841    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3842        self.client.into_channel().map_err(|client| Self { client })
3843    }
3844
3845    fn as_channel(&self) -> &::fidl::AsyncChannel {
3846        self.client.as_channel()
3847    }
3848}
3849
3850impl ChannelListenerRegistryProxy {
3851    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelListenerRegistry.
3852    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3853        let protocol_name =
3854            <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3855        Self { client: fidl::client::Client::new(channel, protocol_name) }
3856    }
3857
3858    /// Get a Stream of events from the remote end of the protocol.
3859    ///
3860    /// # Panics
3861    ///
3862    /// Panics if the event stream was already taken.
3863    pub fn take_event_stream(&self) -> ChannelListenerRegistryEventStream {
3864        ChannelListenerRegistryEventStream { event_receiver: self.client.take_event_receiver() }
3865    }
3866
3867    /// Register a listener for incoming channels. The registry will assign a
3868    /// PSM value that is unique for the local device, as well as open a
3869    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
3870    /// event that all PSMs have been assigned, this call will fail with
3871    /// `ZX_ERR_NO_RESOURCES`.
3872    ///
3873    /// Note that the method of service discovery or advertising is defined by
3874    /// the service or protocol, so it is the responsibility of the caller to
3875    /// communicate the assigned PSM to any clients.
3876    pub fn r#listen_l2cap(
3877        &self,
3878        mut payload: ChannelListenerRegistryListenL2capRequest,
3879    ) -> fidl::client::QueryResponseFut<
3880        ChannelListenerRegistryListenL2capResult,
3881        fidl::encoding::DefaultFuchsiaResourceDialect,
3882    > {
3883        ChannelListenerRegistryProxyInterface::r#listen_l2cap(self, payload)
3884    }
3885}
3886
3887impl ChannelListenerRegistryProxyInterface for ChannelListenerRegistryProxy {
3888    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
3889        ChannelListenerRegistryListenL2capResult,
3890        fidl::encoding::DefaultFuchsiaResourceDialect,
3891    >;
3892    fn r#listen_l2cap(
3893        &self,
3894        mut payload: ChannelListenerRegistryListenL2capRequest,
3895    ) -> Self::ListenL2capResponseFut {
3896        fn _decode(
3897            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3898        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
3899            let _response = fidl::client::decode_transaction_body::<
3900                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
3901                fidl::encoding::DefaultFuchsiaResourceDialect,
3902                0x39c6e9001d102338,
3903            >(_buf?)?;
3904            Ok(_response.map(|x| x))
3905        }
3906        self.client.send_query_and_decode::<
3907            ChannelListenerRegistryListenL2capRequest,
3908            ChannelListenerRegistryListenL2capResult,
3909        >(
3910            &mut payload,
3911            0x39c6e9001d102338,
3912            fidl::encoding::DynamicFlags::empty(),
3913            _decode,
3914        )
3915    }
3916}
3917
3918pub struct ChannelListenerRegistryEventStream {
3919    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3920}
3921
3922impl std::marker::Unpin for ChannelListenerRegistryEventStream {}
3923
3924impl futures::stream::FusedStream for ChannelListenerRegistryEventStream {
3925    fn is_terminated(&self) -> bool {
3926        self.event_receiver.is_terminated()
3927    }
3928}
3929
3930impl futures::Stream for ChannelListenerRegistryEventStream {
3931    type Item = Result<ChannelListenerRegistryEvent, fidl::Error>;
3932
3933    fn poll_next(
3934        mut self: std::pin::Pin<&mut Self>,
3935        cx: &mut std::task::Context<'_>,
3936    ) -> std::task::Poll<Option<Self::Item>> {
3937        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3938            &mut self.event_receiver,
3939            cx
3940        )?) {
3941            Some(buf) => std::task::Poll::Ready(Some(ChannelListenerRegistryEvent::decode(buf))),
3942            None => std::task::Poll::Ready(None),
3943        }
3944    }
3945}
3946
3947#[derive(Debug)]
3948pub enum ChannelListenerRegistryEvent {}
3949
3950impl ChannelListenerRegistryEvent {
3951    /// Decodes a message buffer as a [`ChannelListenerRegistryEvent`].
3952    fn decode(
3953        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3954    ) -> Result<ChannelListenerRegistryEvent, fidl::Error> {
3955        let (bytes, _handles) = buf.split_mut();
3956        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3957        debug_assert_eq!(tx_header.tx_id, 0);
3958        match tx_header.ordinal {
3959            _ => Err(fidl::Error::UnknownOrdinal {
3960                ordinal: tx_header.ordinal,
3961                protocol_name:
3962                    <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3963            }),
3964        }
3965    }
3966}
3967
3968/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelListenerRegistry.
3969pub struct ChannelListenerRegistryRequestStream {
3970    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3971    is_terminated: bool,
3972}
3973
3974impl std::marker::Unpin for ChannelListenerRegistryRequestStream {}
3975
3976impl futures::stream::FusedStream for ChannelListenerRegistryRequestStream {
3977    fn is_terminated(&self) -> bool {
3978        self.is_terminated
3979    }
3980}
3981
3982impl fidl::endpoints::RequestStream for ChannelListenerRegistryRequestStream {
3983    type Protocol = ChannelListenerRegistryMarker;
3984    type ControlHandle = ChannelListenerRegistryControlHandle;
3985
3986    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3987        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3988    }
3989
3990    fn control_handle(&self) -> Self::ControlHandle {
3991        ChannelListenerRegistryControlHandle { inner: self.inner.clone() }
3992    }
3993
3994    fn into_inner(
3995        self,
3996    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3997    {
3998        (self.inner, self.is_terminated)
3999    }
4000
4001    fn from_inner(
4002        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4003        is_terminated: bool,
4004    ) -> Self {
4005        Self { inner, is_terminated }
4006    }
4007}
4008
4009impl futures::Stream for ChannelListenerRegistryRequestStream {
4010    type Item = Result<ChannelListenerRegistryRequest, fidl::Error>;
4011
4012    fn poll_next(
4013        mut self: std::pin::Pin<&mut Self>,
4014        cx: &mut std::task::Context<'_>,
4015    ) -> std::task::Poll<Option<Self::Item>> {
4016        let this = &mut *self;
4017        if this.inner.check_shutdown(cx) {
4018            this.is_terminated = true;
4019            return std::task::Poll::Ready(None);
4020        }
4021        if this.is_terminated {
4022            panic!("polled ChannelListenerRegistryRequestStream after completion");
4023        }
4024        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4025            |bytes, handles| {
4026                match this.inner.channel().read_etc(cx, bytes, handles) {
4027                    std::task::Poll::Ready(Ok(())) => {}
4028                    std::task::Poll::Pending => return std::task::Poll::Pending,
4029                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4030                        this.is_terminated = true;
4031                        return std::task::Poll::Ready(None);
4032                    }
4033                    std::task::Poll::Ready(Err(e)) => {
4034                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4035                            e.into(),
4036                        ))));
4037                    }
4038                }
4039
4040                // A message has been received from the channel
4041                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4042
4043                std::task::Poll::Ready(Some(match header.ordinal {
4044                0x39c6e9001d102338 => {
4045                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4046                    let mut req = fidl::new_empty!(ChannelListenerRegistryListenL2capRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4047                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
4048                    let control_handle = ChannelListenerRegistryControlHandle {
4049                        inner: this.inner.clone(),
4050                    };
4051                    Ok(ChannelListenerRegistryRequest::ListenL2cap {payload: req,
4052                        responder: ChannelListenerRegistryListenL2capResponder {
4053                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4054                            tx_id: header.tx_id,
4055                        },
4056                    })
4057                }
4058                _ => Err(fidl::Error::UnknownOrdinal {
4059                    ordinal: header.ordinal,
4060                    protocol_name: <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4061                }),
4062            }))
4063            },
4064        )
4065    }
4066}
4067
4068/// Represents the ability to register and accept incoming connections on
4069/// connection oriented channels.
4070#[derive(Debug)]
4071pub enum ChannelListenerRegistryRequest {
4072    /// Register a listener for incoming channels. The registry will assign a
4073    /// PSM value that is unique for the local device, as well as open a
4074    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
4075    /// event that all PSMs have been assigned, this call will fail with
4076    /// `ZX_ERR_NO_RESOURCES`.
4077    ///
4078    /// Note that the method of service discovery or advertising is defined by
4079    /// the service or protocol, so it is the responsibility of the caller to
4080    /// communicate the assigned PSM to any clients.
4081    ListenL2cap {
4082        payload: ChannelListenerRegistryListenL2capRequest,
4083        responder: ChannelListenerRegistryListenL2capResponder,
4084    },
4085}
4086
4087impl ChannelListenerRegistryRequest {
4088    #[allow(irrefutable_let_patterns)]
4089    pub fn into_listen_l2cap(
4090        self,
4091    ) -> Option<(
4092        ChannelListenerRegistryListenL2capRequest,
4093        ChannelListenerRegistryListenL2capResponder,
4094    )> {
4095        if let ChannelListenerRegistryRequest::ListenL2cap { payload, responder } = self {
4096            Some((payload, responder))
4097        } else {
4098            None
4099        }
4100    }
4101
4102    /// Name of the method defined in FIDL
4103    pub fn method_name(&self) -> &'static str {
4104        match *self {
4105            ChannelListenerRegistryRequest::ListenL2cap { .. } => "listen_l2cap",
4106        }
4107    }
4108}
4109
4110#[derive(Debug, Clone)]
4111pub struct ChannelListenerRegistryControlHandle {
4112    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4113}
4114
4115impl fidl::endpoints::ControlHandle for ChannelListenerRegistryControlHandle {
4116    fn shutdown(&self) {
4117        self.inner.shutdown()
4118    }
4119    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4120        self.inner.shutdown_with_epitaph(status)
4121    }
4122
4123    fn is_closed(&self) -> bool {
4124        self.inner.channel().is_closed()
4125    }
4126    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4127        self.inner.channel().on_closed()
4128    }
4129
4130    #[cfg(target_os = "fuchsia")]
4131    fn signal_peer(
4132        &self,
4133        clear_mask: zx::Signals,
4134        set_mask: zx::Signals,
4135    ) -> Result<(), zx_status::Status> {
4136        use fidl::Peered;
4137        self.inner.channel().signal_peer(clear_mask, set_mask)
4138    }
4139}
4140
4141impl ChannelListenerRegistryControlHandle {}
4142
4143#[must_use = "FIDL methods require a response to be sent"]
4144#[derive(Debug)]
4145pub struct ChannelListenerRegistryListenL2capResponder {
4146    control_handle: std::mem::ManuallyDrop<ChannelListenerRegistryControlHandle>,
4147    tx_id: u32,
4148}
4149
4150/// Set the the channel to be shutdown (see [`ChannelListenerRegistryControlHandle::shutdown`])
4151/// if the responder is dropped without sending a response, so that the client
4152/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4153impl std::ops::Drop for ChannelListenerRegistryListenL2capResponder {
4154    fn drop(&mut self) {
4155        self.control_handle.shutdown();
4156        // Safety: drops once, never accessed again
4157        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4158    }
4159}
4160
4161impl fidl::endpoints::Responder for ChannelListenerRegistryListenL2capResponder {
4162    type ControlHandle = ChannelListenerRegistryControlHandle;
4163
4164    fn control_handle(&self) -> &ChannelListenerRegistryControlHandle {
4165        &self.control_handle
4166    }
4167
4168    fn drop_without_shutdown(mut self) {
4169        // Safety: drops once, never accessed again due to mem::forget
4170        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4171        // Prevent Drop from running (which would shut down the channel)
4172        std::mem::forget(self);
4173    }
4174}
4175
4176impl ChannelListenerRegistryListenL2capResponder {
4177    /// Sends a response to the FIDL transaction.
4178    ///
4179    /// Sets the channel to shutdown if an error occurs.
4180    pub fn send(
4181        self,
4182        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4183    ) -> Result<(), fidl::Error> {
4184        let _result = self.send_raw(result);
4185        if _result.is_err() {
4186            self.control_handle.shutdown();
4187        }
4188        self.drop_without_shutdown();
4189        _result
4190    }
4191
4192    /// Similar to "send" but does not shutdown the channel if an error occurs.
4193    pub fn send_no_shutdown_on_err(
4194        self,
4195        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4196    ) -> Result<(), fidl::Error> {
4197        let _result = self.send_raw(result);
4198        self.drop_without_shutdown();
4199        _result
4200    }
4201
4202    fn send_raw(
4203        &self,
4204        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4205    ) -> Result<(), fidl::Error> {
4206        self.control_handle.inner.send::<fidl::encoding::ResultType<
4207            ChannelListenerRegistryListenL2capResponse,
4208            i32,
4209        >>(
4210            result,
4211            self.tx_id,
4212            0x39c6e9001d102338,
4213            fidl::encoding::DynamicFlags::empty(),
4214        )
4215    }
4216}
4217
4218#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4219pub struct CodecDelayMarker;
4220
4221impl fidl::endpoints::ProtocolMarker for CodecDelayMarker {
4222    type Proxy = CodecDelayProxy;
4223    type RequestStream = CodecDelayRequestStream;
4224    #[cfg(target_os = "fuchsia")]
4225    type SynchronousProxy = CodecDelaySynchronousProxy;
4226
4227    const DEBUG_NAME: &'static str = "(anonymous) CodecDelay";
4228}
4229pub type CodecDelayGetCodecLocalDelayRangeResult =
4230    Result<CodecDelayGetCodecLocalDelayRangeResponse, i32>;
4231
4232pub trait CodecDelayProxyInterface: Send + Sync {
4233    type GetCodecLocalDelayRangeResponseFut: std::future::Future<Output = Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error>>
4234        + Send;
4235    fn r#get_codec_local_delay_range(
4236        &self,
4237        payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4238    ) -> Self::GetCodecLocalDelayRangeResponseFut;
4239}
4240#[derive(Debug)]
4241#[cfg(target_os = "fuchsia")]
4242pub struct CodecDelaySynchronousProxy {
4243    client: fidl::client::sync::Client,
4244}
4245
4246#[cfg(target_os = "fuchsia")]
4247impl fidl::endpoints::SynchronousProxy for CodecDelaySynchronousProxy {
4248    type Proxy = CodecDelayProxy;
4249    type Protocol = CodecDelayMarker;
4250
4251    fn from_channel(inner: fidl::Channel) -> Self {
4252        Self::new(inner)
4253    }
4254
4255    fn into_channel(self) -> fidl::Channel {
4256        self.client.into_channel()
4257    }
4258
4259    fn as_channel(&self) -> &fidl::Channel {
4260        self.client.as_channel()
4261    }
4262}
4263
4264#[cfg(target_os = "fuchsia")]
4265impl CodecDelaySynchronousProxy {
4266    pub fn new(channel: fidl::Channel) -> Self {
4267        let protocol_name = <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4268        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4269    }
4270
4271    pub fn into_channel(self) -> fidl::Channel {
4272        self.client.into_channel()
4273    }
4274
4275    /// Waits until an event arrives and returns it. It is safe for other
4276    /// threads to make concurrent requests while waiting for an event.
4277    pub fn wait_for_event(
4278        &self,
4279        deadline: zx::MonotonicInstant,
4280    ) -> Result<CodecDelayEvent, fidl::Error> {
4281        CodecDelayEvent::decode(self.client.wait_for_event(deadline)?)
4282    }
4283
4284    /// Retrieve the range of controller delay for the codec specified with the provided stream
4285    /// attributes.
4286    ///
4287    /// On success, returns the minimum and maximum allowed delay.
4288    ///
4289    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
4290    /// Returns ZX_ERR_INTERNAL for all other failures.
4291    pub fn r#get_codec_local_delay_range(
4292        &self,
4293        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4294        ___deadline: zx::MonotonicInstant,
4295    ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
4296        let _response = self.client.send_query::<
4297            CodecDelayGetCodecLocalDelayRangeRequest,
4298            fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4299        >(
4300            payload,
4301            0x1cf34fdeed80b4d,
4302            fidl::encoding::DynamicFlags::empty(),
4303            ___deadline,
4304        )?;
4305        Ok(_response.map(|x| x))
4306    }
4307}
4308
4309#[cfg(target_os = "fuchsia")]
4310impl From<CodecDelaySynchronousProxy> for zx::Handle {
4311    fn from(value: CodecDelaySynchronousProxy) -> Self {
4312        value.into_channel().into()
4313    }
4314}
4315
4316#[cfg(target_os = "fuchsia")]
4317impl From<fidl::Channel> for CodecDelaySynchronousProxy {
4318    fn from(value: fidl::Channel) -> Self {
4319        Self::new(value)
4320    }
4321}
4322
4323#[cfg(target_os = "fuchsia")]
4324impl fidl::endpoints::FromClient for CodecDelaySynchronousProxy {
4325    type Protocol = CodecDelayMarker;
4326
4327    fn from_client(value: fidl::endpoints::ClientEnd<CodecDelayMarker>) -> Self {
4328        Self::new(value.into_channel())
4329    }
4330}
4331
4332#[derive(Debug, Clone)]
4333pub struct CodecDelayProxy {
4334    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4335}
4336
4337impl fidl::endpoints::Proxy for CodecDelayProxy {
4338    type Protocol = CodecDelayMarker;
4339
4340    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4341        Self::new(inner)
4342    }
4343
4344    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4345        self.client.into_channel().map_err(|client| Self { client })
4346    }
4347
4348    fn as_channel(&self) -> &::fidl::AsyncChannel {
4349        self.client.as_channel()
4350    }
4351}
4352
4353impl CodecDelayProxy {
4354    /// Create a new Proxy for fuchsia.bluetooth.le/CodecDelay.
4355    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4356        let protocol_name = <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4357        Self { client: fidl::client::Client::new(channel, protocol_name) }
4358    }
4359
4360    /// Get a Stream of events from the remote end of the protocol.
4361    ///
4362    /// # Panics
4363    ///
4364    /// Panics if the event stream was already taken.
4365    pub fn take_event_stream(&self) -> CodecDelayEventStream {
4366        CodecDelayEventStream { event_receiver: self.client.take_event_receiver() }
4367    }
4368
4369    /// Retrieve the range of controller delay for the codec specified with the provided stream
4370    /// attributes.
4371    ///
4372    /// On success, returns the minimum and maximum allowed delay.
4373    ///
4374    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
4375    /// Returns ZX_ERR_INTERNAL for all other failures.
4376    pub fn r#get_codec_local_delay_range(
4377        &self,
4378        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4379    ) -> fidl::client::QueryResponseFut<
4380        CodecDelayGetCodecLocalDelayRangeResult,
4381        fidl::encoding::DefaultFuchsiaResourceDialect,
4382    > {
4383        CodecDelayProxyInterface::r#get_codec_local_delay_range(self, payload)
4384    }
4385}
4386
4387impl CodecDelayProxyInterface for CodecDelayProxy {
4388    type GetCodecLocalDelayRangeResponseFut = fidl::client::QueryResponseFut<
4389        CodecDelayGetCodecLocalDelayRangeResult,
4390        fidl::encoding::DefaultFuchsiaResourceDialect,
4391    >;
4392    fn r#get_codec_local_delay_range(
4393        &self,
4394        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4395    ) -> Self::GetCodecLocalDelayRangeResponseFut {
4396        fn _decode(
4397            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4398        ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
4399            let _response = fidl::client::decode_transaction_body::<
4400                fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4401                fidl::encoding::DefaultFuchsiaResourceDialect,
4402                0x1cf34fdeed80b4d,
4403            >(_buf?)?;
4404            Ok(_response.map(|x| x))
4405        }
4406        self.client.send_query_and_decode::<
4407            CodecDelayGetCodecLocalDelayRangeRequest,
4408            CodecDelayGetCodecLocalDelayRangeResult,
4409        >(
4410            payload,
4411            0x1cf34fdeed80b4d,
4412            fidl::encoding::DynamicFlags::empty(),
4413            _decode,
4414        )
4415    }
4416}
4417
4418pub struct CodecDelayEventStream {
4419    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4420}
4421
4422impl std::marker::Unpin for CodecDelayEventStream {}
4423
4424impl futures::stream::FusedStream for CodecDelayEventStream {
4425    fn is_terminated(&self) -> bool {
4426        self.event_receiver.is_terminated()
4427    }
4428}
4429
4430impl futures::Stream for CodecDelayEventStream {
4431    type Item = Result<CodecDelayEvent, fidl::Error>;
4432
4433    fn poll_next(
4434        mut self: std::pin::Pin<&mut Self>,
4435        cx: &mut std::task::Context<'_>,
4436    ) -> std::task::Poll<Option<Self::Item>> {
4437        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4438            &mut self.event_receiver,
4439            cx
4440        )?) {
4441            Some(buf) => std::task::Poll::Ready(Some(CodecDelayEvent::decode(buf))),
4442            None => std::task::Poll::Ready(None),
4443        }
4444    }
4445}
4446
4447#[derive(Debug)]
4448pub enum CodecDelayEvent {}
4449
4450impl CodecDelayEvent {
4451    /// Decodes a message buffer as a [`CodecDelayEvent`].
4452    fn decode(
4453        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4454    ) -> Result<CodecDelayEvent, fidl::Error> {
4455        let (bytes, _handles) = buf.split_mut();
4456        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4457        debug_assert_eq!(tx_header.tx_id, 0);
4458        match tx_header.ordinal {
4459            _ => Err(fidl::Error::UnknownOrdinal {
4460                ordinal: tx_header.ordinal,
4461                protocol_name: <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4462            }),
4463        }
4464    }
4465}
4466
4467/// A Stream of incoming requests for fuchsia.bluetooth.le/CodecDelay.
4468pub struct CodecDelayRequestStream {
4469    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4470    is_terminated: bool,
4471}
4472
4473impl std::marker::Unpin for CodecDelayRequestStream {}
4474
4475impl futures::stream::FusedStream for CodecDelayRequestStream {
4476    fn is_terminated(&self) -> bool {
4477        self.is_terminated
4478    }
4479}
4480
4481impl fidl::endpoints::RequestStream for CodecDelayRequestStream {
4482    type Protocol = CodecDelayMarker;
4483    type ControlHandle = CodecDelayControlHandle;
4484
4485    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4486        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4487    }
4488
4489    fn control_handle(&self) -> Self::ControlHandle {
4490        CodecDelayControlHandle { inner: self.inner.clone() }
4491    }
4492
4493    fn into_inner(
4494        self,
4495    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4496    {
4497        (self.inner, self.is_terminated)
4498    }
4499
4500    fn from_inner(
4501        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4502        is_terminated: bool,
4503    ) -> Self {
4504        Self { inner, is_terminated }
4505    }
4506}
4507
4508impl futures::Stream for CodecDelayRequestStream {
4509    type Item = Result<CodecDelayRequest, fidl::Error>;
4510
4511    fn poll_next(
4512        mut self: std::pin::Pin<&mut Self>,
4513        cx: &mut std::task::Context<'_>,
4514    ) -> std::task::Poll<Option<Self::Item>> {
4515        let this = &mut *self;
4516        if this.inner.check_shutdown(cx) {
4517            this.is_terminated = true;
4518            return std::task::Poll::Ready(None);
4519        }
4520        if this.is_terminated {
4521            panic!("polled CodecDelayRequestStream after completion");
4522        }
4523        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4524            |bytes, handles| {
4525                match this.inner.channel().read_etc(cx, bytes, handles) {
4526                    std::task::Poll::Ready(Ok(())) => {}
4527                    std::task::Poll::Pending => return std::task::Poll::Pending,
4528                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4529                        this.is_terminated = true;
4530                        return std::task::Poll::Ready(None);
4531                    }
4532                    std::task::Poll::Ready(Err(e)) => {
4533                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4534                            e.into(),
4535                        ))));
4536                    }
4537                }
4538
4539                // A message has been received from the channel
4540                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4541
4542                std::task::Poll::Ready(Some(match header.ordinal {
4543                    0x1cf34fdeed80b4d => {
4544                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4545                        let mut req = fidl::new_empty!(
4546                            CodecDelayGetCodecLocalDelayRangeRequest,
4547                            fidl::encoding::DefaultFuchsiaResourceDialect
4548                        );
4549                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecDelayGetCodecLocalDelayRangeRequest>(&header, _body_bytes, handles, &mut req)?;
4550                        let control_handle = CodecDelayControlHandle { inner: this.inner.clone() };
4551                        Ok(CodecDelayRequest::GetCodecLocalDelayRange {
4552                            payload: req,
4553                            responder: CodecDelayGetCodecLocalDelayRangeResponder {
4554                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4555                                tx_id: header.tx_id,
4556                            },
4557                        })
4558                    }
4559                    _ => Err(fidl::Error::UnknownOrdinal {
4560                        ordinal: header.ordinal,
4561                        protocol_name:
4562                            <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4563                    }),
4564                }))
4565            },
4566        )
4567    }
4568}
4569
4570/// This protocol allows us to retrieve controller local delay values. It is not intended to be
4571/// used stand-alone, but to be composed into protocols that need access to this information.
4572#[derive(Debug)]
4573pub enum CodecDelayRequest {
4574    /// Retrieve the range of controller delay for the codec specified with the provided stream
4575    /// attributes.
4576    ///
4577    /// On success, returns the minimum and maximum allowed delay.
4578    ///
4579    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
4580    /// Returns ZX_ERR_INTERNAL for all other failures.
4581    GetCodecLocalDelayRange {
4582        payload: CodecDelayGetCodecLocalDelayRangeRequest,
4583        responder: CodecDelayGetCodecLocalDelayRangeResponder,
4584    },
4585}
4586
4587impl CodecDelayRequest {
4588    #[allow(irrefutable_let_patterns)]
4589    pub fn into_get_codec_local_delay_range(
4590        self,
4591    ) -> Option<(
4592        CodecDelayGetCodecLocalDelayRangeRequest,
4593        CodecDelayGetCodecLocalDelayRangeResponder,
4594    )> {
4595        if let CodecDelayRequest::GetCodecLocalDelayRange { payload, responder } = self {
4596            Some((payload, responder))
4597        } else {
4598            None
4599        }
4600    }
4601
4602    /// Name of the method defined in FIDL
4603    pub fn method_name(&self) -> &'static str {
4604        match *self {
4605            CodecDelayRequest::GetCodecLocalDelayRange { .. } => "get_codec_local_delay_range",
4606        }
4607    }
4608}
4609
4610#[derive(Debug, Clone)]
4611pub struct CodecDelayControlHandle {
4612    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4613}
4614
4615impl fidl::endpoints::ControlHandle for CodecDelayControlHandle {
4616    fn shutdown(&self) {
4617        self.inner.shutdown()
4618    }
4619    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4620        self.inner.shutdown_with_epitaph(status)
4621    }
4622
4623    fn is_closed(&self) -> bool {
4624        self.inner.channel().is_closed()
4625    }
4626    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4627        self.inner.channel().on_closed()
4628    }
4629
4630    #[cfg(target_os = "fuchsia")]
4631    fn signal_peer(
4632        &self,
4633        clear_mask: zx::Signals,
4634        set_mask: zx::Signals,
4635    ) -> Result<(), zx_status::Status> {
4636        use fidl::Peered;
4637        self.inner.channel().signal_peer(clear_mask, set_mask)
4638    }
4639}
4640
4641impl CodecDelayControlHandle {}
4642
4643#[must_use = "FIDL methods require a response to be sent"]
4644#[derive(Debug)]
4645pub struct CodecDelayGetCodecLocalDelayRangeResponder {
4646    control_handle: std::mem::ManuallyDrop<CodecDelayControlHandle>,
4647    tx_id: u32,
4648}
4649
4650/// Set the the channel to be shutdown (see [`CodecDelayControlHandle::shutdown`])
4651/// if the responder is dropped without sending a response, so that the client
4652/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4653impl std::ops::Drop for CodecDelayGetCodecLocalDelayRangeResponder {
4654    fn drop(&mut self) {
4655        self.control_handle.shutdown();
4656        // Safety: drops once, never accessed again
4657        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4658    }
4659}
4660
4661impl fidl::endpoints::Responder for CodecDelayGetCodecLocalDelayRangeResponder {
4662    type ControlHandle = CodecDelayControlHandle;
4663
4664    fn control_handle(&self) -> &CodecDelayControlHandle {
4665        &self.control_handle
4666    }
4667
4668    fn drop_without_shutdown(mut self) {
4669        // Safety: drops once, never accessed again due to mem::forget
4670        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4671        // Prevent Drop from running (which would shut down the channel)
4672        std::mem::forget(self);
4673    }
4674}
4675
4676impl CodecDelayGetCodecLocalDelayRangeResponder {
4677    /// Sends a response to the FIDL transaction.
4678    ///
4679    /// Sets the channel to shutdown if an error occurs.
4680    pub fn send(
4681        self,
4682        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4683    ) -> Result<(), fidl::Error> {
4684        let _result = self.send_raw(result);
4685        if _result.is_err() {
4686            self.control_handle.shutdown();
4687        }
4688        self.drop_without_shutdown();
4689        _result
4690    }
4691
4692    /// Similar to "send" but does not shutdown the channel if an error occurs.
4693    pub fn send_no_shutdown_on_err(
4694        self,
4695        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4696    ) -> Result<(), fidl::Error> {
4697        let _result = self.send_raw(result);
4698        self.drop_without_shutdown();
4699        _result
4700    }
4701
4702    fn send_raw(
4703        &self,
4704        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4705    ) -> Result<(), fidl::Error> {
4706        self.control_handle.inner.send::<fidl::encoding::ResultType<
4707            CodecDelayGetCodecLocalDelayRangeResponse,
4708            i32,
4709        >>(
4710            result,
4711            self.tx_id,
4712            0x1cf34fdeed80b4d,
4713            fidl::encoding::DynamicFlags::empty(),
4714        )
4715    }
4716}
4717
4718#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4719pub struct ConnectedIsochronousGroupMarker;
4720
4721impl fidl::endpoints::ProtocolMarker for ConnectedIsochronousGroupMarker {
4722    type Proxy = ConnectedIsochronousGroupProxy;
4723    type RequestStream = ConnectedIsochronousGroupRequestStream;
4724    #[cfg(target_os = "fuchsia")]
4725    type SynchronousProxy = ConnectedIsochronousGroupSynchronousProxy;
4726
4727    const DEBUG_NAME: &'static str = "(anonymous) ConnectedIsochronousGroup";
4728}
4729pub type ConnectedIsochronousGroupEstablishStreamsResult = Result<(), EstablishStreamsError>;
4730
4731pub trait ConnectedIsochronousGroupProxyInterface: Send + Sync {
4732    type EstablishStreamsResponseFut: std::future::Future<
4733            Output = Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error>,
4734        > + Send;
4735    fn r#establish_streams(
4736        &self,
4737        payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4738    ) -> Self::EstablishStreamsResponseFut;
4739    fn r#remove(&self) -> Result<(), fidl::Error>;
4740}
4741#[derive(Debug)]
4742#[cfg(target_os = "fuchsia")]
4743pub struct ConnectedIsochronousGroupSynchronousProxy {
4744    client: fidl::client::sync::Client,
4745}
4746
4747#[cfg(target_os = "fuchsia")]
4748impl fidl::endpoints::SynchronousProxy for ConnectedIsochronousGroupSynchronousProxy {
4749    type Proxy = ConnectedIsochronousGroupProxy;
4750    type Protocol = ConnectedIsochronousGroupMarker;
4751
4752    fn from_channel(inner: fidl::Channel) -> Self {
4753        Self::new(inner)
4754    }
4755
4756    fn into_channel(self) -> fidl::Channel {
4757        self.client.into_channel()
4758    }
4759
4760    fn as_channel(&self) -> &fidl::Channel {
4761        self.client.as_channel()
4762    }
4763}
4764
4765#[cfg(target_os = "fuchsia")]
4766impl ConnectedIsochronousGroupSynchronousProxy {
4767    pub fn new(channel: fidl::Channel) -> Self {
4768        let protocol_name =
4769            <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4770        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4771    }
4772
4773    pub fn into_channel(self) -> fidl::Channel {
4774        self.client.into_channel()
4775    }
4776
4777    /// Waits until an event arrives and returns it. It is safe for other
4778    /// threads to make concurrent requests while waiting for an event.
4779    pub fn wait_for_event(
4780        &self,
4781        deadline: zx::MonotonicInstant,
4782    ) -> Result<ConnectedIsochronousGroupEvent, fidl::Error> {
4783        ConnectedIsochronousGroupEvent::decode(self.client.wait_for_event(deadline)?)
4784    }
4785
4786    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
4787    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
4788    /// be sent on the IsochronousStream.
4789    ///
4790    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
4791    /// returned.
4792    ///
4793    /// Otherwise, this call returns once each CIS specified has connected.
4794    pub fn r#establish_streams(
4795        &self,
4796        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4797        ___deadline: zx::MonotonicInstant,
4798    ) -> Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error> {
4799        let _response = self.client.send_query::<
4800            ConnectedIsochronousGroupEstablishStreamsRequest,
4801            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EstablishStreamsError>,
4802        >(
4803            payload,
4804            0xc7296c5edb4dacc,
4805            fidl::encoding::DynamicFlags::FLEXIBLE,
4806            ___deadline,
4807        )?
4808        .into_result::<ConnectedIsochronousGroupMarker>("establish_streams")?;
4809        Ok(_response.map(|x| x))
4810    }
4811
4812    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
4813    /// all of the associated streams have closed and the group has been removed.
4814    pub fn r#remove(&self) -> Result<(), fidl::Error> {
4815        self.client.send::<fidl::encoding::EmptyPayload>(
4816            (),
4817            0xbed433babd20503,
4818            fidl::encoding::DynamicFlags::FLEXIBLE,
4819        )
4820    }
4821}
4822
4823#[cfg(target_os = "fuchsia")]
4824impl From<ConnectedIsochronousGroupSynchronousProxy> for zx::Handle {
4825    fn from(value: ConnectedIsochronousGroupSynchronousProxy) -> Self {
4826        value.into_channel().into()
4827    }
4828}
4829
4830#[cfg(target_os = "fuchsia")]
4831impl From<fidl::Channel> for ConnectedIsochronousGroupSynchronousProxy {
4832    fn from(value: fidl::Channel) -> Self {
4833        Self::new(value)
4834    }
4835}
4836
4837#[cfg(target_os = "fuchsia")]
4838impl fidl::endpoints::FromClient for ConnectedIsochronousGroupSynchronousProxy {
4839    type Protocol = ConnectedIsochronousGroupMarker;
4840
4841    fn from_client(value: fidl::endpoints::ClientEnd<ConnectedIsochronousGroupMarker>) -> Self {
4842        Self::new(value.into_channel())
4843    }
4844}
4845
4846#[derive(Debug, Clone)]
4847pub struct ConnectedIsochronousGroupProxy {
4848    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4849}
4850
4851impl fidl::endpoints::Proxy for ConnectedIsochronousGroupProxy {
4852    type Protocol = ConnectedIsochronousGroupMarker;
4853
4854    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4855        Self::new(inner)
4856    }
4857
4858    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4859        self.client.into_channel().map_err(|client| Self { client })
4860    }
4861
4862    fn as_channel(&self) -> &::fidl::AsyncChannel {
4863        self.client.as_channel()
4864    }
4865}
4866
4867impl ConnectedIsochronousGroupProxy {
4868    /// Create a new Proxy for fuchsia.bluetooth.le/ConnectedIsochronousGroup.
4869    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4870        let protocol_name =
4871            <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4872        Self { client: fidl::client::Client::new(channel, protocol_name) }
4873    }
4874
4875    /// Get a Stream of events from the remote end of the protocol.
4876    ///
4877    /// # Panics
4878    ///
4879    /// Panics if the event stream was already taken.
4880    pub fn take_event_stream(&self) -> ConnectedIsochronousGroupEventStream {
4881        ConnectedIsochronousGroupEventStream { event_receiver: self.client.take_event_receiver() }
4882    }
4883
4884    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
4885    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
4886    /// be sent on the IsochronousStream.
4887    ///
4888    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
4889    /// returned.
4890    ///
4891    /// Otherwise, this call returns once each CIS specified has connected.
4892    pub fn r#establish_streams(
4893        &self,
4894        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4895    ) -> fidl::client::QueryResponseFut<
4896        ConnectedIsochronousGroupEstablishStreamsResult,
4897        fidl::encoding::DefaultFuchsiaResourceDialect,
4898    > {
4899        ConnectedIsochronousGroupProxyInterface::r#establish_streams(self, payload)
4900    }
4901
4902    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
4903    /// all of the associated streams have closed and the group has been removed.
4904    pub fn r#remove(&self) -> Result<(), fidl::Error> {
4905        ConnectedIsochronousGroupProxyInterface::r#remove(self)
4906    }
4907}
4908
4909impl ConnectedIsochronousGroupProxyInterface for ConnectedIsochronousGroupProxy {
4910    type EstablishStreamsResponseFut = fidl::client::QueryResponseFut<
4911        ConnectedIsochronousGroupEstablishStreamsResult,
4912        fidl::encoding::DefaultFuchsiaResourceDialect,
4913    >;
4914    fn r#establish_streams(
4915        &self,
4916        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4917    ) -> Self::EstablishStreamsResponseFut {
4918        fn _decode(
4919            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4920        ) -> Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error> {
4921            let _response = fidl::client::decode_transaction_body::<
4922                fidl::encoding::FlexibleResultType<
4923                    fidl::encoding::EmptyStruct,
4924                    EstablishStreamsError,
4925                >,
4926                fidl::encoding::DefaultFuchsiaResourceDialect,
4927                0xc7296c5edb4dacc,
4928            >(_buf?)?
4929            .into_result::<ConnectedIsochronousGroupMarker>("establish_streams")?;
4930            Ok(_response.map(|x| x))
4931        }
4932        self.client.send_query_and_decode::<
4933            ConnectedIsochronousGroupEstablishStreamsRequest,
4934            ConnectedIsochronousGroupEstablishStreamsResult,
4935        >(
4936            payload,
4937            0xc7296c5edb4dacc,
4938            fidl::encoding::DynamicFlags::FLEXIBLE,
4939            _decode,
4940        )
4941    }
4942
4943    fn r#remove(&self) -> Result<(), fidl::Error> {
4944        self.client.send::<fidl::encoding::EmptyPayload>(
4945            (),
4946            0xbed433babd20503,
4947            fidl::encoding::DynamicFlags::FLEXIBLE,
4948        )
4949    }
4950}
4951
4952pub struct ConnectedIsochronousGroupEventStream {
4953    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4954}
4955
4956impl std::marker::Unpin for ConnectedIsochronousGroupEventStream {}
4957
4958impl futures::stream::FusedStream for ConnectedIsochronousGroupEventStream {
4959    fn is_terminated(&self) -> bool {
4960        self.event_receiver.is_terminated()
4961    }
4962}
4963
4964impl futures::Stream for ConnectedIsochronousGroupEventStream {
4965    type Item = Result<ConnectedIsochronousGroupEvent, fidl::Error>;
4966
4967    fn poll_next(
4968        mut self: std::pin::Pin<&mut Self>,
4969        cx: &mut std::task::Context<'_>,
4970    ) -> std::task::Poll<Option<Self::Item>> {
4971        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4972            &mut self.event_receiver,
4973            cx
4974        )?) {
4975            Some(buf) => std::task::Poll::Ready(Some(ConnectedIsochronousGroupEvent::decode(buf))),
4976            None => std::task::Poll::Ready(None),
4977        }
4978    }
4979}
4980
4981#[derive(Debug)]
4982pub enum ConnectedIsochronousGroupEvent {
4983    #[non_exhaustive]
4984    _UnknownEvent {
4985        /// Ordinal of the event that was sent.
4986        ordinal: u64,
4987    },
4988}
4989
4990impl ConnectedIsochronousGroupEvent {
4991    /// Decodes a message buffer as a [`ConnectedIsochronousGroupEvent`].
4992    fn decode(
4993        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4994    ) -> Result<ConnectedIsochronousGroupEvent, fidl::Error> {
4995        let (bytes, _handles) = buf.split_mut();
4996        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4997        debug_assert_eq!(tx_header.tx_id, 0);
4998        match tx_header.ordinal {
4999            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5000                Ok(ConnectedIsochronousGroupEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5001            }
5002            _ => Err(fidl::Error::UnknownOrdinal {
5003                ordinal: tx_header.ordinal,
5004                protocol_name:
5005                    <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5006            }),
5007        }
5008    }
5009}
5010
5011/// A Stream of incoming requests for fuchsia.bluetooth.le/ConnectedIsochronousGroup.
5012pub struct ConnectedIsochronousGroupRequestStream {
5013    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5014    is_terminated: bool,
5015}
5016
5017impl std::marker::Unpin for ConnectedIsochronousGroupRequestStream {}
5018
5019impl futures::stream::FusedStream for ConnectedIsochronousGroupRequestStream {
5020    fn is_terminated(&self) -> bool {
5021        self.is_terminated
5022    }
5023}
5024
5025impl fidl::endpoints::RequestStream for ConnectedIsochronousGroupRequestStream {
5026    type Protocol = ConnectedIsochronousGroupMarker;
5027    type ControlHandle = ConnectedIsochronousGroupControlHandle;
5028
5029    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5030        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5031    }
5032
5033    fn control_handle(&self) -> Self::ControlHandle {
5034        ConnectedIsochronousGroupControlHandle { inner: self.inner.clone() }
5035    }
5036
5037    fn into_inner(
5038        self,
5039    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5040    {
5041        (self.inner, self.is_terminated)
5042    }
5043
5044    fn from_inner(
5045        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5046        is_terminated: bool,
5047    ) -> Self {
5048        Self { inner, is_terminated }
5049    }
5050}
5051
5052impl futures::Stream for ConnectedIsochronousGroupRequestStream {
5053    type Item = Result<ConnectedIsochronousGroupRequest, fidl::Error>;
5054
5055    fn poll_next(
5056        mut self: std::pin::Pin<&mut Self>,
5057        cx: &mut std::task::Context<'_>,
5058    ) -> std::task::Poll<Option<Self::Item>> {
5059        let this = &mut *self;
5060        if this.inner.check_shutdown(cx) {
5061            this.is_terminated = true;
5062            return std::task::Poll::Ready(None);
5063        }
5064        if this.is_terminated {
5065            panic!("polled ConnectedIsochronousGroupRequestStream after completion");
5066        }
5067        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5068            |bytes, handles| {
5069                match this.inner.channel().read_etc(cx, bytes, handles) {
5070                    std::task::Poll::Ready(Ok(())) => {}
5071                    std::task::Poll::Pending => return std::task::Poll::Pending,
5072                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5073                        this.is_terminated = true;
5074                        return std::task::Poll::Ready(None);
5075                    }
5076                    std::task::Poll::Ready(Err(e)) => {
5077                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5078                            e.into(),
5079                        ))));
5080                    }
5081                }
5082
5083                // A message has been received from the channel
5084                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5085
5086                std::task::Poll::Ready(Some(match header.ordinal {
5087                0xc7296c5edb4dacc => {
5088                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5089                    let mut req = fidl::new_empty!(ConnectedIsochronousGroupEstablishStreamsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5090                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectedIsochronousGroupEstablishStreamsRequest>(&header, _body_bytes, handles, &mut req)?;
5091                    let control_handle = ConnectedIsochronousGroupControlHandle {
5092                        inner: this.inner.clone(),
5093                    };
5094                    Ok(ConnectedIsochronousGroupRequest::EstablishStreams {payload: req,
5095                        responder: ConnectedIsochronousGroupEstablishStreamsResponder {
5096                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5097                            tx_id: header.tx_id,
5098                        },
5099                    })
5100                }
5101                0xbed433babd20503 => {
5102                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5103                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5104                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5105                    let control_handle = ConnectedIsochronousGroupControlHandle {
5106                        inner: this.inner.clone(),
5107                    };
5108                    Ok(ConnectedIsochronousGroupRequest::Remove {
5109                        control_handle,
5110                    })
5111                }
5112                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5113                    Ok(ConnectedIsochronousGroupRequest::_UnknownMethod {
5114                        ordinal: header.ordinal,
5115                        control_handle: ConnectedIsochronousGroupControlHandle { inner: this.inner.clone() },
5116                        method_type: fidl::MethodType::OneWay,
5117                    })
5118                }
5119                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5120                    this.inner.send_framework_err(
5121                        fidl::encoding::FrameworkErr::UnknownMethod,
5122                        header.tx_id,
5123                        header.ordinal,
5124                        header.dynamic_flags(),
5125                        (bytes, handles),
5126                    )?;
5127                    Ok(ConnectedIsochronousGroupRequest::_UnknownMethod {
5128                        ordinal: header.ordinal,
5129                        control_handle: ConnectedIsochronousGroupControlHandle { inner: this.inner.clone() },
5130                        method_type: fidl::MethodType::TwoWay,
5131                    })
5132                }
5133                _ => Err(fidl::Error::UnknownOrdinal {
5134                    ordinal: header.ordinal,
5135                    protocol_name: <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5136                }),
5137            }))
5138            },
5139        )
5140    }
5141}
5142
5143#[derive(Debug)]
5144pub enum ConnectedIsochronousGroupRequest {
5145    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
5146    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
5147    /// be sent on the IsochronousStream.
5148    ///
5149    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
5150    /// returned.
5151    ///
5152    /// Otherwise, this call returns once each CIS specified has connected.
5153    EstablishStreams {
5154        payload: ConnectedIsochronousGroupEstablishStreamsRequest,
5155        responder: ConnectedIsochronousGroupEstablishStreamsResponder,
5156    },
5157    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
5158    /// all of the associated streams have closed and the group has been removed.
5159    Remove { control_handle: ConnectedIsochronousGroupControlHandle },
5160    /// An interaction was received which does not match any known method.
5161    #[non_exhaustive]
5162    _UnknownMethod {
5163        /// Ordinal of the method that was called.
5164        ordinal: u64,
5165        control_handle: ConnectedIsochronousGroupControlHandle,
5166        method_type: fidl::MethodType,
5167    },
5168}
5169
5170impl ConnectedIsochronousGroupRequest {
5171    #[allow(irrefutable_let_patterns)]
5172    pub fn into_establish_streams(
5173        self,
5174    ) -> Option<(
5175        ConnectedIsochronousGroupEstablishStreamsRequest,
5176        ConnectedIsochronousGroupEstablishStreamsResponder,
5177    )> {
5178        if let ConnectedIsochronousGroupRequest::EstablishStreams { payload, responder } = self {
5179            Some((payload, responder))
5180        } else {
5181            None
5182        }
5183    }
5184
5185    #[allow(irrefutable_let_patterns)]
5186    pub fn into_remove(self) -> Option<(ConnectedIsochronousGroupControlHandle)> {
5187        if let ConnectedIsochronousGroupRequest::Remove { control_handle } = self {
5188            Some((control_handle))
5189        } else {
5190            None
5191        }
5192    }
5193
5194    /// Name of the method defined in FIDL
5195    pub fn method_name(&self) -> &'static str {
5196        match *self {
5197            ConnectedIsochronousGroupRequest::EstablishStreams { .. } => "establish_streams",
5198            ConnectedIsochronousGroupRequest::Remove { .. } => "remove",
5199            ConnectedIsochronousGroupRequest::_UnknownMethod {
5200                method_type: fidl::MethodType::OneWay,
5201                ..
5202            } => "unknown one-way method",
5203            ConnectedIsochronousGroupRequest::_UnknownMethod {
5204                method_type: fidl::MethodType::TwoWay,
5205                ..
5206            } => "unknown two-way method",
5207        }
5208    }
5209}
5210
5211#[derive(Debug, Clone)]
5212pub struct ConnectedIsochronousGroupControlHandle {
5213    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5214}
5215
5216impl fidl::endpoints::ControlHandle for ConnectedIsochronousGroupControlHandle {
5217    fn shutdown(&self) {
5218        self.inner.shutdown()
5219    }
5220    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5221        self.inner.shutdown_with_epitaph(status)
5222    }
5223
5224    fn is_closed(&self) -> bool {
5225        self.inner.channel().is_closed()
5226    }
5227    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5228        self.inner.channel().on_closed()
5229    }
5230
5231    #[cfg(target_os = "fuchsia")]
5232    fn signal_peer(
5233        &self,
5234        clear_mask: zx::Signals,
5235        set_mask: zx::Signals,
5236    ) -> Result<(), zx_status::Status> {
5237        use fidl::Peered;
5238        self.inner.channel().signal_peer(clear_mask, set_mask)
5239    }
5240}
5241
5242impl ConnectedIsochronousGroupControlHandle {}
5243
5244#[must_use = "FIDL methods require a response to be sent"]
5245#[derive(Debug)]
5246pub struct ConnectedIsochronousGroupEstablishStreamsResponder {
5247    control_handle: std::mem::ManuallyDrop<ConnectedIsochronousGroupControlHandle>,
5248    tx_id: u32,
5249}
5250
5251/// Set the the channel to be shutdown (see [`ConnectedIsochronousGroupControlHandle::shutdown`])
5252/// if the responder is dropped without sending a response, so that the client
5253/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5254impl std::ops::Drop for ConnectedIsochronousGroupEstablishStreamsResponder {
5255    fn drop(&mut self) {
5256        self.control_handle.shutdown();
5257        // Safety: drops once, never accessed again
5258        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5259    }
5260}
5261
5262impl fidl::endpoints::Responder for ConnectedIsochronousGroupEstablishStreamsResponder {
5263    type ControlHandle = ConnectedIsochronousGroupControlHandle;
5264
5265    fn control_handle(&self) -> &ConnectedIsochronousGroupControlHandle {
5266        &self.control_handle
5267    }
5268
5269    fn drop_without_shutdown(mut self) {
5270        // Safety: drops once, never accessed again due to mem::forget
5271        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5272        // Prevent Drop from running (which would shut down the channel)
5273        std::mem::forget(self);
5274    }
5275}
5276
5277impl ConnectedIsochronousGroupEstablishStreamsResponder {
5278    /// Sends a response to the FIDL transaction.
5279    ///
5280    /// Sets the channel to shutdown if an error occurs.
5281    pub fn send(self, mut result: Result<(), EstablishStreamsError>) -> Result<(), fidl::Error> {
5282        let _result = self.send_raw(result);
5283        if _result.is_err() {
5284            self.control_handle.shutdown();
5285        }
5286        self.drop_without_shutdown();
5287        _result
5288    }
5289
5290    /// Similar to "send" but does not shutdown the channel if an error occurs.
5291    pub fn send_no_shutdown_on_err(
5292        self,
5293        mut result: Result<(), EstablishStreamsError>,
5294    ) -> Result<(), fidl::Error> {
5295        let _result = self.send_raw(result);
5296        self.drop_without_shutdown();
5297        _result
5298    }
5299
5300    fn send_raw(&self, mut result: Result<(), EstablishStreamsError>) -> Result<(), fidl::Error> {
5301        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5302            fidl::encoding::EmptyStruct,
5303            EstablishStreamsError,
5304        >>(
5305            fidl::encoding::FlexibleResult::new(result),
5306            self.tx_id,
5307            0xc7296c5edb4dacc,
5308            fidl::encoding::DynamicFlags::FLEXIBLE,
5309        )
5310    }
5311}
5312
5313#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5314pub struct ConnectionMarker;
5315
5316impl fidl::endpoints::ProtocolMarker for ConnectionMarker {
5317    type Proxy = ConnectionProxy;
5318    type RequestStream = ConnectionRequestStream;
5319    #[cfg(target_os = "fuchsia")]
5320    type SynchronousProxy = ConnectionSynchronousProxy;
5321
5322    const DEBUG_NAME: &'static str = "(anonymous) Connection";
5323}
5324pub type ConnectionTransferPeriodicAdvertisingSyncResult =
5325    Result<(), PeriodicAdvertisingSyncTransferError>;
5326pub type ConnectionAcceptPeriodicAdvertisingSyncTransferResult =
5327    Result<(), PeriodicAdvertisingSyncTransferError>;
5328
5329pub trait ConnectionProxyInterface: Send + Sync {
5330    type GetCodecLocalDelayRangeResponseFut: std::future::Future<Output = Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error>>
5331        + Send;
5332    fn r#get_codec_local_delay_range(
5333        &self,
5334        payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5335    ) -> Self::GetCodecLocalDelayRangeResponseFut;
5336    fn r#request_gatt_client(
5337        &self,
5338        client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5339    ) -> Result<(), fidl::Error>;
5340    fn r#accept_cis(&self, payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error>;
5341    fn r#connect_l2cap(&self, payload: ConnectionConnectL2capRequest) -> Result<(), fidl::Error>;
5342    type TransferPeriodicAdvertisingSyncResponseFut: std::future::Future<
5343            Output = Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error>,
5344        > + Send;
5345    fn r#transfer_periodic_advertising_sync(
5346        &self,
5347        payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
5348    ) -> Self::TransferPeriodicAdvertisingSyncResponseFut;
5349    type AcceptPeriodicAdvertisingSyncTransferResponseFut: std::future::Future<
5350            Output = Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error>,
5351        > + Send;
5352    fn r#accept_periodic_advertising_sync_transfer(
5353        &self,
5354        payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5355    ) -> Self::AcceptPeriodicAdvertisingSyncTransferResponseFut;
5356}
5357#[derive(Debug)]
5358#[cfg(target_os = "fuchsia")]
5359pub struct ConnectionSynchronousProxy {
5360    client: fidl::client::sync::Client,
5361}
5362
5363#[cfg(target_os = "fuchsia")]
5364impl fidl::endpoints::SynchronousProxy for ConnectionSynchronousProxy {
5365    type Proxy = ConnectionProxy;
5366    type Protocol = ConnectionMarker;
5367
5368    fn from_channel(inner: fidl::Channel) -> Self {
5369        Self::new(inner)
5370    }
5371
5372    fn into_channel(self) -> fidl::Channel {
5373        self.client.into_channel()
5374    }
5375
5376    fn as_channel(&self) -> &fidl::Channel {
5377        self.client.as_channel()
5378    }
5379}
5380
5381#[cfg(target_os = "fuchsia")]
5382impl ConnectionSynchronousProxy {
5383    pub fn new(channel: fidl::Channel) -> Self {
5384        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5385        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5386    }
5387
5388    pub fn into_channel(self) -> fidl::Channel {
5389        self.client.into_channel()
5390    }
5391
5392    /// Waits until an event arrives and returns it. It is safe for other
5393    /// threads to make concurrent requests while waiting for an event.
5394    pub fn wait_for_event(
5395        &self,
5396        deadline: zx::MonotonicInstant,
5397    ) -> Result<ConnectionEvent, fidl::Error> {
5398        ConnectionEvent::decode(self.client.wait_for_event(deadline)?)
5399    }
5400
5401    /// Retrieve the range of controller delay for the codec specified with the provided stream
5402    /// attributes.
5403    ///
5404    /// On success, returns the minimum and maximum allowed delay.
5405    ///
5406    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5407    /// Returns ZX_ERR_INTERNAL for all other failures.
5408    pub fn r#get_codec_local_delay_range(
5409        &self,
5410        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5411        ___deadline: zx::MonotonicInstant,
5412    ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
5413        let _response = self.client.send_query::<
5414            CodecDelayGetCodecLocalDelayRangeRequest,
5415            fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5416        >(
5417            payload,
5418            0x1cf34fdeed80b4d,
5419            fidl::encoding::DynamicFlags::empty(),
5420            ___deadline,
5421        )?;
5422        Ok(_response.map(|x| x))
5423    }
5424
5425    /// The following epitaphs may be sent by the server on error:
5426    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
5427    ///                           protocol. The existing Client should be used.
5428    pub fn r#request_gatt_client(
5429        &self,
5430        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5431    ) -> Result<(), fidl::Error> {
5432        self.client.send::<ConnectionRequestGattClientRequest>(
5433            (client,),
5434            0x2a670e0fec6ccc6b,
5435            fidl::encoding::DynamicFlags::empty(),
5436        )
5437    }
5438
5439    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
5440    /// CIS requests that have not explicitly been allowed will be rejected.
5441    ///
5442    /// The provided IsochronousStream will be used for future notification of established
5443    /// connections.
5444    ///
5445    /// The host may wait for multiple incoming connections simultaneously, although each
5446    /// must have a combination of CIG/CIS values that is unique to this connection.
5447    ///
5448    /// If we are not operating in the peripheral role in this connection, connection_stream
5449    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
5450    ///
5451    /// If we are already waiting for another connection with the same combination of CIG/CIS
5452    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
5453    pub fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
5454        self.client.send::<ConnectionAcceptCisRequest>(
5455            &mut payload,
5456            0x7e6338c237088144,
5457            fidl::encoding::DynamicFlags::empty(),
5458        )
5459    }
5460
5461    /// Connect to an L2CAP LE connection-oriented channel.
5462    pub fn r#connect_l2cap(
5463        &self,
5464        mut payload: ConnectionConnectL2capRequest,
5465    ) -> Result<(), fidl::Error> {
5466        self.client.send::<ConnectionConnectL2capRequest>(
5467            &mut payload,
5468            0x12351316feaebce9,
5469            fidl::encoding::DynamicFlags::empty(),
5470        )
5471    }
5472
5473    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
5474    /// the connected peer.
5475    pub fn r#transfer_periodic_advertising_sync(
5476        &self,
5477        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
5478        ___deadline: zx::MonotonicInstant,
5479    ) -> Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error> {
5480        let _response = self.client.send_query::<
5481            ConnectionTransferPeriodicAdvertisingSyncRequest,
5482            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeriodicAdvertisingSyncTransferError>,
5483        >(
5484            payload,
5485            0x1117a10b5ba1e219,
5486            fidl::encoding::DynamicFlags::empty(),
5487            ___deadline,
5488        )?;
5489        Ok(_response.map(|x| x))
5490    }
5491
5492    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
5493    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
5494    pub fn r#accept_periodic_advertising_sync_transfer(
5495        &self,
5496        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5497        ___deadline: zx::MonotonicInstant,
5498    ) -> Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error> {
5499        let _response = self.client.send_query::<
5500            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5501            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeriodicAdvertisingSyncTransferError>,
5502        >(
5503            &mut payload,
5504            0x441a31a7effa7e2b,
5505            fidl::encoding::DynamicFlags::empty(),
5506            ___deadline,
5507        )?;
5508        Ok(_response.map(|x| x))
5509    }
5510}
5511
5512#[cfg(target_os = "fuchsia")]
5513impl From<ConnectionSynchronousProxy> for zx::Handle {
5514    fn from(value: ConnectionSynchronousProxy) -> Self {
5515        value.into_channel().into()
5516    }
5517}
5518
5519#[cfg(target_os = "fuchsia")]
5520impl From<fidl::Channel> for ConnectionSynchronousProxy {
5521    fn from(value: fidl::Channel) -> Self {
5522        Self::new(value)
5523    }
5524}
5525
5526#[cfg(target_os = "fuchsia")]
5527impl fidl::endpoints::FromClient for ConnectionSynchronousProxy {
5528    type Protocol = ConnectionMarker;
5529
5530    fn from_client(value: fidl::endpoints::ClientEnd<ConnectionMarker>) -> Self {
5531        Self::new(value.into_channel())
5532    }
5533}
5534
5535#[derive(Debug, Clone)]
5536pub struct ConnectionProxy {
5537    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5538}
5539
5540impl fidl::endpoints::Proxy for ConnectionProxy {
5541    type Protocol = ConnectionMarker;
5542
5543    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5544        Self::new(inner)
5545    }
5546
5547    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5548        self.client.into_channel().map_err(|client| Self { client })
5549    }
5550
5551    fn as_channel(&self) -> &::fidl::AsyncChannel {
5552        self.client.as_channel()
5553    }
5554}
5555
5556impl ConnectionProxy {
5557    /// Create a new Proxy for fuchsia.bluetooth.le/Connection.
5558    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5559        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5560        Self { client: fidl::client::Client::new(channel, protocol_name) }
5561    }
5562
5563    /// Get a Stream of events from the remote end of the protocol.
5564    ///
5565    /// # Panics
5566    ///
5567    /// Panics if the event stream was already taken.
5568    pub fn take_event_stream(&self) -> ConnectionEventStream {
5569        ConnectionEventStream { event_receiver: self.client.take_event_receiver() }
5570    }
5571
5572    /// Retrieve the range of controller delay for the codec specified with the provided stream
5573    /// attributes.
5574    ///
5575    /// On success, returns the minimum and maximum allowed delay.
5576    ///
5577    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5578    /// Returns ZX_ERR_INTERNAL for all other failures.
5579    pub fn r#get_codec_local_delay_range(
5580        &self,
5581        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5582    ) -> fidl::client::QueryResponseFut<
5583        CodecDelayGetCodecLocalDelayRangeResult,
5584        fidl::encoding::DefaultFuchsiaResourceDialect,
5585    > {
5586        ConnectionProxyInterface::r#get_codec_local_delay_range(self, payload)
5587    }
5588
5589    /// The following epitaphs may be sent by the server on error:
5590    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
5591    ///                           protocol. The existing Client should be used.
5592    pub fn r#request_gatt_client(
5593        &self,
5594        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5595    ) -> Result<(), fidl::Error> {
5596        ConnectionProxyInterface::r#request_gatt_client(self, client)
5597    }
5598
5599    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
5600    /// CIS requests that have not explicitly been allowed will be rejected.
5601    ///
5602    /// The provided IsochronousStream will be used for future notification of established
5603    /// connections.
5604    ///
5605    /// The host may wait for multiple incoming connections simultaneously, although each
5606    /// must have a combination of CIG/CIS values that is unique to this connection.
5607    ///
5608    /// If we are not operating in the peripheral role in this connection, connection_stream
5609    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
5610    ///
5611    /// If we are already waiting for another connection with the same combination of CIG/CIS
5612    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
5613    pub fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
5614        ConnectionProxyInterface::r#accept_cis(self, payload)
5615    }
5616
5617    /// Connect to an L2CAP LE connection-oriented channel.
5618    pub fn r#connect_l2cap(
5619        &self,
5620        mut payload: ConnectionConnectL2capRequest,
5621    ) -> Result<(), fidl::Error> {
5622        ConnectionProxyInterface::r#connect_l2cap(self, payload)
5623    }
5624
5625    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
5626    /// the connected peer.
5627    pub fn r#transfer_periodic_advertising_sync(
5628        &self,
5629        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
5630    ) -> fidl::client::QueryResponseFut<
5631        ConnectionTransferPeriodicAdvertisingSyncResult,
5632        fidl::encoding::DefaultFuchsiaResourceDialect,
5633    > {
5634        ConnectionProxyInterface::r#transfer_periodic_advertising_sync(self, payload)
5635    }
5636
5637    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
5638    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
5639    pub fn r#accept_periodic_advertising_sync_transfer(
5640        &self,
5641        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5642    ) -> fidl::client::QueryResponseFut<
5643        ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
5644        fidl::encoding::DefaultFuchsiaResourceDialect,
5645    > {
5646        ConnectionProxyInterface::r#accept_periodic_advertising_sync_transfer(self, payload)
5647    }
5648}
5649
5650impl ConnectionProxyInterface for ConnectionProxy {
5651    type GetCodecLocalDelayRangeResponseFut = fidl::client::QueryResponseFut<
5652        CodecDelayGetCodecLocalDelayRangeResult,
5653        fidl::encoding::DefaultFuchsiaResourceDialect,
5654    >;
5655    fn r#get_codec_local_delay_range(
5656        &self,
5657        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5658    ) -> Self::GetCodecLocalDelayRangeResponseFut {
5659        fn _decode(
5660            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5661        ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
5662            let _response = fidl::client::decode_transaction_body::<
5663                fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5664                fidl::encoding::DefaultFuchsiaResourceDialect,
5665                0x1cf34fdeed80b4d,
5666            >(_buf?)?;
5667            Ok(_response.map(|x| x))
5668        }
5669        self.client.send_query_and_decode::<
5670            CodecDelayGetCodecLocalDelayRangeRequest,
5671            CodecDelayGetCodecLocalDelayRangeResult,
5672        >(
5673            payload,
5674            0x1cf34fdeed80b4d,
5675            fidl::encoding::DynamicFlags::empty(),
5676            _decode,
5677        )
5678    }
5679
5680    fn r#request_gatt_client(
5681        &self,
5682        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5683    ) -> Result<(), fidl::Error> {
5684        self.client.send::<ConnectionRequestGattClientRequest>(
5685            (client,),
5686            0x2a670e0fec6ccc6b,
5687            fidl::encoding::DynamicFlags::empty(),
5688        )
5689    }
5690
5691    fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
5692        self.client.send::<ConnectionAcceptCisRequest>(
5693            &mut payload,
5694            0x7e6338c237088144,
5695            fidl::encoding::DynamicFlags::empty(),
5696        )
5697    }
5698
5699    fn r#connect_l2cap(
5700        &self,
5701        mut payload: ConnectionConnectL2capRequest,
5702    ) -> Result<(), fidl::Error> {
5703        self.client.send::<ConnectionConnectL2capRequest>(
5704            &mut payload,
5705            0x12351316feaebce9,
5706            fidl::encoding::DynamicFlags::empty(),
5707        )
5708    }
5709
5710    type TransferPeriodicAdvertisingSyncResponseFut = fidl::client::QueryResponseFut<
5711        ConnectionTransferPeriodicAdvertisingSyncResult,
5712        fidl::encoding::DefaultFuchsiaResourceDialect,
5713    >;
5714    fn r#transfer_periodic_advertising_sync(
5715        &self,
5716        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
5717    ) -> Self::TransferPeriodicAdvertisingSyncResponseFut {
5718        fn _decode(
5719            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5720        ) -> Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error> {
5721            let _response = fidl::client::decode_transaction_body::<
5722                fidl::encoding::ResultType<
5723                    fidl::encoding::EmptyStruct,
5724                    PeriodicAdvertisingSyncTransferError,
5725                >,
5726                fidl::encoding::DefaultFuchsiaResourceDialect,
5727                0x1117a10b5ba1e219,
5728            >(_buf?)?;
5729            Ok(_response.map(|x| x))
5730        }
5731        self.client.send_query_and_decode::<
5732            ConnectionTransferPeriodicAdvertisingSyncRequest,
5733            ConnectionTransferPeriodicAdvertisingSyncResult,
5734        >(
5735            payload,
5736            0x1117a10b5ba1e219,
5737            fidl::encoding::DynamicFlags::empty(),
5738            _decode,
5739        )
5740    }
5741
5742    type AcceptPeriodicAdvertisingSyncTransferResponseFut = fidl::client::QueryResponseFut<
5743        ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
5744        fidl::encoding::DefaultFuchsiaResourceDialect,
5745    >;
5746    fn r#accept_periodic_advertising_sync_transfer(
5747        &self,
5748        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5749    ) -> Self::AcceptPeriodicAdvertisingSyncTransferResponseFut {
5750        fn _decode(
5751            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5752        ) -> Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error> {
5753            let _response = fidl::client::decode_transaction_body::<
5754                fidl::encoding::ResultType<
5755                    fidl::encoding::EmptyStruct,
5756                    PeriodicAdvertisingSyncTransferError,
5757                >,
5758                fidl::encoding::DefaultFuchsiaResourceDialect,
5759                0x441a31a7effa7e2b,
5760            >(_buf?)?;
5761            Ok(_response.map(|x| x))
5762        }
5763        self.client.send_query_and_decode::<
5764            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5765            ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
5766        >(
5767            &mut payload,
5768            0x441a31a7effa7e2b,
5769            fidl::encoding::DynamicFlags::empty(),
5770            _decode,
5771        )
5772    }
5773}
5774
5775pub struct ConnectionEventStream {
5776    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5777}
5778
5779impl std::marker::Unpin for ConnectionEventStream {}
5780
5781impl futures::stream::FusedStream for ConnectionEventStream {
5782    fn is_terminated(&self) -> bool {
5783        self.event_receiver.is_terminated()
5784    }
5785}
5786
5787impl futures::Stream for ConnectionEventStream {
5788    type Item = Result<ConnectionEvent, fidl::Error>;
5789
5790    fn poll_next(
5791        mut self: std::pin::Pin<&mut Self>,
5792        cx: &mut std::task::Context<'_>,
5793    ) -> std::task::Poll<Option<Self::Item>> {
5794        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5795            &mut self.event_receiver,
5796            cx
5797        )?) {
5798            Some(buf) => std::task::Poll::Ready(Some(ConnectionEvent::decode(buf))),
5799            None => std::task::Poll::Ready(None),
5800        }
5801    }
5802}
5803
5804#[derive(Debug)]
5805pub enum ConnectionEvent {}
5806
5807impl ConnectionEvent {
5808    /// Decodes a message buffer as a [`ConnectionEvent`].
5809    fn decode(
5810        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5811    ) -> Result<ConnectionEvent, fidl::Error> {
5812        let (bytes, _handles) = buf.split_mut();
5813        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5814        debug_assert_eq!(tx_header.tx_id, 0);
5815        match tx_header.ordinal {
5816            _ => Err(fidl::Error::UnknownOrdinal {
5817                ordinal: tx_header.ordinal,
5818                protocol_name: <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5819            }),
5820        }
5821    }
5822}
5823
5824/// A Stream of incoming requests for fuchsia.bluetooth.le/Connection.
5825pub struct ConnectionRequestStream {
5826    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5827    is_terminated: bool,
5828}
5829
5830impl std::marker::Unpin for ConnectionRequestStream {}
5831
5832impl futures::stream::FusedStream for ConnectionRequestStream {
5833    fn is_terminated(&self) -> bool {
5834        self.is_terminated
5835    }
5836}
5837
5838impl fidl::endpoints::RequestStream for ConnectionRequestStream {
5839    type Protocol = ConnectionMarker;
5840    type ControlHandle = ConnectionControlHandle;
5841
5842    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5843        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5844    }
5845
5846    fn control_handle(&self) -> Self::ControlHandle {
5847        ConnectionControlHandle { inner: self.inner.clone() }
5848    }
5849
5850    fn into_inner(
5851        self,
5852    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5853    {
5854        (self.inner, self.is_terminated)
5855    }
5856
5857    fn from_inner(
5858        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5859        is_terminated: bool,
5860    ) -> Self {
5861        Self { inner, is_terminated }
5862    }
5863}
5864
5865impl futures::Stream for ConnectionRequestStream {
5866    type Item = Result<ConnectionRequest, fidl::Error>;
5867
5868    fn poll_next(
5869        mut self: std::pin::Pin<&mut Self>,
5870        cx: &mut std::task::Context<'_>,
5871    ) -> std::task::Poll<Option<Self::Item>> {
5872        let this = &mut *self;
5873        if this.inner.check_shutdown(cx) {
5874            this.is_terminated = true;
5875            return std::task::Poll::Ready(None);
5876        }
5877        if this.is_terminated {
5878            panic!("polled ConnectionRequestStream after completion");
5879        }
5880        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5881            |bytes, handles| {
5882                match this.inner.channel().read_etc(cx, bytes, handles) {
5883                    std::task::Poll::Ready(Ok(())) => {}
5884                    std::task::Poll::Pending => return std::task::Poll::Pending,
5885                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5886                        this.is_terminated = true;
5887                        return std::task::Poll::Ready(None);
5888                    }
5889                    std::task::Poll::Ready(Err(e)) => {
5890                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5891                            e.into(),
5892                        ))));
5893                    }
5894                }
5895
5896                // A message has been received from the channel
5897                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5898
5899                std::task::Poll::Ready(Some(match header.ordinal {
5900                    0x1cf34fdeed80b4d => {
5901                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5902                        let mut req = fidl::new_empty!(
5903                            CodecDelayGetCodecLocalDelayRangeRequest,
5904                            fidl::encoding::DefaultFuchsiaResourceDialect
5905                        );
5906                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecDelayGetCodecLocalDelayRangeRequest>(&header, _body_bytes, handles, &mut req)?;
5907                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5908                        Ok(ConnectionRequest::GetCodecLocalDelayRange {
5909                            payload: req,
5910                            responder: ConnectionGetCodecLocalDelayRangeResponder {
5911                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5912                                tx_id: header.tx_id,
5913                            },
5914                        })
5915                    }
5916                    0x2a670e0fec6ccc6b => {
5917                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5918                        let mut req = fidl::new_empty!(
5919                            ConnectionRequestGattClientRequest,
5920                            fidl::encoding::DefaultFuchsiaResourceDialect
5921                        );
5922                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionRequestGattClientRequest>(&header, _body_bytes, handles, &mut req)?;
5923                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5924                        Ok(ConnectionRequest::RequestGattClient {
5925                            client: req.client,
5926
5927                            control_handle,
5928                        })
5929                    }
5930                    0x7e6338c237088144 => {
5931                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5932                        let mut req = fidl::new_empty!(
5933                            ConnectionAcceptCisRequest,
5934                            fidl::encoding::DefaultFuchsiaResourceDialect
5935                        );
5936                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionAcceptCisRequest>(&header, _body_bytes, handles, &mut req)?;
5937                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5938                        Ok(ConnectionRequest::AcceptCis { payload: req, control_handle })
5939                    }
5940                    0x12351316feaebce9 => {
5941                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5942                        let mut req = fidl::new_empty!(
5943                            ConnectionConnectL2capRequest,
5944                            fidl::encoding::DefaultFuchsiaResourceDialect
5945                        );
5946                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionConnectL2capRequest>(&header, _body_bytes, handles, &mut req)?;
5947                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5948                        Ok(ConnectionRequest::ConnectL2cap { payload: req, control_handle })
5949                    }
5950                    0x1117a10b5ba1e219 => {
5951                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5952                        let mut req = fidl::new_empty!(
5953                            ConnectionTransferPeriodicAdvertisingSyncRequest,
5954                            fidl::encoding::DefaultFuchsiaResourceDialect
5955                        );
5956                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionTransferPeriodicAdvertisingSyncRequest>(&header, _body_bytes, handles, &mut req)?;
5957                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5958                        Ok(ConnectionRequest::TransferPeriodicAdvertisingSync {
5959                            payload: req,
5960                            responder: ConnectionTransferPeriodicAdvertisingSyncResponder {
5961                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5962                                tx_id: header.tx_id,
5963                            },
5964                        })
5965                    }
5966                    0x441a31a7effa7e2b => {
5967                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5968                        let mut req = fidl::new_empty!(
5969                            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5970                            fidl::encoding::DefaultFuchsiaResourceDialect
5971                        );
5972                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionAcceptPeriodicAdvertisingSyncTransferRequest>(&header, _body_bytes, handles, &mut req)?;
5973                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5974                        Ok(ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer {
5975                            payload: req,
5976                            responder: ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
5977                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5978                                tx_id: header.tx_id,
5979                            },
5980                        })
5981                    }
5982                    _ => Err(fidl::Error::UnknownOrdinal {
5983                        ordinal: header.ordinal,
5984                        protocol_name:
5985                            <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5986                    }),
5987                }))
5988            },
5989        )
5990    }
5991}
5992
5993/// Protocol that represents the connection to a peer. This can be used to interact with GATT
5994/// services and establish L2CAP channels.
5995///
5996/// This lifetime of this capability is tied to that of the LE connection it represents. Closing the
5997/// channel results in a disconnection if no other clients hold a Connection to the same peer.
5998#[derive(Debug)]
5999pub enum ConnectionRequest {
6000    /// Retrieve the range of controller delay for the codec specified with the provided stream
6001    /// attributes.
6002    ///
6003    /// On success, returns the minimum and maximum allowed delay.
6004    ///
6005    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
6006    /// Returns ZX_ERR_INTERNAL for all other failures.
6007    GetCodecLocalDelayRange {
6008        payload: CodecDelayGetCodecLocalDelayRangeRequest,
6009        responder: ConnectionGetCodecLocalDelayRangeResponder,
6010    },
6011    /// The following epitaphs may be sent by the server on error:
6012    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
6013    ///                           protocol. The existing Client should be used.
6014    RequestGattClient {
6015        client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6016        control_handle: ConnectionControlHandle,
6017    },
6018    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
6019    /// CIS requests that have not explicitly been allowed will be rejected.
6020    ///
6021    /// The provided IsochronousStream will be used for future notification of established
6022    /// connections.
6023    ///
6024    /// The host may wait for multiple incoming connections simultaneously, although each
6025    /// must have a combination of CIG/CIS values that is unique to this connection.
6026    ///
6027    /// If we are not operating in the peripheral role in this connection, connection_stream
6028    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
6029    ///
6030    /// If we are already waiting for another connection with the same combination of CIG/CIS
6031    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
6032    AcceptCis { payload: ConnectionAcceptCisRequest, control_handle: ConnectionControlHandle },
6033    /// Connect to an L2CAP LE connection-oriented channel.
6034    ConnectL2cap { payload: ConnectionConnectL2capRequest, control_handle: ConnectionControlHandle },
6035    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
6036    /// the connected peer.
6037    TransferPeriodicAdvertisingSync {
6038        payload: ConnectionTransferPeriodicAdvertisingSyncRequest,
6039        responder: ConnectionTransferPeriodicAdvertisingSyncResponder,
6040    },
6041    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
6042    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
6043    AcceptPeriodicAdvertisingSyncTransfer {
6044        payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6045        responder: ConnectionAcceptPeriodicAdvertisingSyncTransferResponder,
6046    },
6047}
6048
6049impl ConnectionRequest {
6050    #[allow(irrefutable_let_patterns)]
6051    pub fn into_get_codec_local_delay_range(
6052        self,
6053    ) -> Option<(
6054        CodecDelayGetCodecLocalDelayRangeRequest,
6055        ConnectionGetCodecLocalDelayRangeResponder,
6056    )> {
6057        if let ConnectionRequest::GetCodecLocalDelayRange { payload, responder } = self {
6058            Some((payload, responder))
6059        } else {
6060            None
6061        }
6062    }
6063
6064    #[allow(irrefutable_let_patterns)]
6065    pub fn into_request_gatt_client(
6066        self,
6067    ) -> Option<(
6068        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6069        ConnectionControlHandle,
6070    )> {
6071        if let ConnectionRequest::RequestGattClient { client, control_handle } = self {
6072            Some((client, control_handle))
6073        } else {
6074            None
6075        }
6076    }
6077
6078    #[allow(irrefutable_let_patterns)]
6079    pub fn into_accept_cis(self) -> Option<(ConnectionAcceptCisRequest, ConnectionControlHandle)> {
6080        if let ConnectionRequest::AcceptCis { payload, control_handle } = self {
6081            Some((payload, control_handle))
6082        } else {
6083            None
6084        }
6085    }
6086
6087    #[allow(irrefutable_let_patterns)]
6088    pub fn into_connect_l2cap(
6089        self,
6090    ) -> Option<(ConnectionConnectL2capRequest, ConnectionControlHandle)> {
6091        if let ConnectionRequest::ConnectL2cap { payload, control_handle } = self {
6092            Some((payload, control_handle))
6093        } else {
6094            None
6095        }
6096    }
6097
6098    #[allow(irrefutable_let_patterns)]
6099    pub fn into_transfer_periodic_advertising_sync(
6100        self,
6101    ) -> Option<(
6102        ConnectionTransferPeriodicAdvertisingSyncRequest,
6103        ConnectionTransferPeriodicAdvertisingSyncResponder,
6104    )> {
6105        if let ConnectionRequest::TransferPeriodicAdvertisingSync { payload, responder } = self {
6106            Some((payload, responder))
6107        } else {
6108            None
6109        }
6110    }
6111
6112    #[allow(irrefutable_let_patterns)]
6113    pub fn into_accept_periodic_advertising_sync_transfer(
6114        self,
6115    ) -> Option<(
6116        ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6117        ConnectionAcceptPeriodicAdvertisingSyncTransferResponder,
6118    )> {
6119        if let ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer { payload, responder } =
6120            self
6121        {
6122            Some((payload, responder))
6123        } else {
6124            None
6125        }
6126    }
6127
6128    /// Name of the method defined in FIDL
6129    pub fn method_name(&self) -> &'static str {
6130        match *self {
6131            ConnectionRequest::GetCodecLocalDelayRange { .. } => "get_codec_local_delay_range",
6132            ConnectionRequest::RequestGattClient { .. } => "request_gatt_client",
6133            ConnectionRequest::AcceptCis { .. } => "accept_cis",
6134            ConnectionRequest::ConnectL2cap { .. } => "connect_l2cap",
6135            ConnectionRequest::TransferPeriodicAdvertisingSync { .. } => {
6136                "transfer_periodic_advertising_sync"
6137            }
6138            ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer { .. } => {
6139                "accept_periodic_advertising_sync_transfer"
6140            }
6141        }
6142    }
6143}
6144
6145#[derive(Debug, Clone)]
6146pub struct ConnectionControlHandle {
6147    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6148}
6149
6150impl fidl::endpoints::ControlHandle for ConnectionControlHandle {
6151    fn shutdown(&self) {
6152        self.inner.shutdown()
6153    }
6154    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6155        self.inner.shutdown_with_epitaph(status)
6156    }
6157
6158    fn is_closed(&self) -> bool {
6159        self.inner.channel().is_closed()
6160    }
6161    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6162        self.inner.channel().on_closed()
6163    }
6164
6165    #[cfg(target_os = "fuchsia")]
6166    fn signal_peer(
6167        &self,
6168        clear_mask: zx::Signals,
6169        set_mask: zx::Signals,
6170    ) -> Result<(), zx_status::Status> {
6171        use fidl::Peered;
6172        self.inner.channel().signal_peer(clear_mask, set_mask)
6173    }
6174}
6175
6176impl ConnectionControlHandle {}
6177
6178#[must_use = "FIDL methods require a response to be sent"]
6179#[derive(Debug)]
6180pub struct ConnectionGetCodecLocalDelayRangeResponder {
6181    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
6182    tx_id: u32,
6183}
6184
6185/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
6186/// if the responder is dropped without sending a response, so that the client
6187/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6188impl std::ops::Drop for ConnectionGetCodecLocalDelayRangeResponder {
6189    fn drop(&mut self) {
6190        self.control_handle.shutdown();
6191        // Safety: drops once, never accessed again
6192        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6193    }
6194}
6195
6196impl fidl::endpoints::Responder for ConnectionGetCodecLocalDelayRangeResponder {
6197    type ControlHandle = ConnectionControlHandle;
6198
6199    fn control_handle(&self) -> &ConnectionControlHandle {
6200        &self.control_handle
6201    }
6202
6203    fn drop_without_shutdown(mut self) {
6204        // Safety: drops once, never accessed again due to mem::forget
6205        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6206        // Prevent Drop from running (which would shut down the channel)
6207        std::mem::forget(self);
6208    }
6209}
6210
6211impl ConnectionGetCodecLocalDelayRangeResponder {
6212    /// Sends a response to the FIDL transaction.
6213    ///
6214    /// Sets the channel to shutdown if an error occurs.
6215    pub fn send(
6216        self,
6217        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
6218    ) -> Result<(), fidl::Error> {
6219        let _result = self.send_raw(result);
6220        if _result.is_err() {
6221            self.control_handle.shutdown();
6222        }
6223        self.drop_without_shutdown();
6224        _result
6225    }
6226
6227    /// Similar to "send" but does not shutdown the channel if an error occurs.
6228    pub fn send_no_shutdown_on_err(
6229        self,
6230        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
6231    ) -> Result<(), fidl::Error> {
6232        let _result = self.send_raw(result);
6233        self.drop_without_shutdown();
6234        _result
6235    }
6236
6237    fn send_raw(
6238        &self,
6239        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
6240    ) -> Result<(), fidl::Error> {
6241        self.control_handle.inner.send::<fidl::encoding::ResultType<
6242            CodecDelayGetCodecLocalDelayRangeResponse,
6243            i32,
6244        >>(
6245            result,
6246            self.tx_id,
6247            0x1cf34fdeed80b4d,
6248            fidl::encoding::DynamicFlags::empty(),
6249        )
6250    }
6251}
6252
6253#[must_use = "FIDL methods require a response to be sent"]
6254#[derive(Debug)]
6255pub struct ConnectionTransferPeriodicAdvertisingSyncResponder {
6256    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
6257    tx_id: u32,
6258}
6259
6260/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
6261/// if the responder is dropped without sending a response, so that the client
6262/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6263impl std::ops::Drop for ConnectionTransferPeriodicAdvertisingSyncResponder {
6264    fn drop(&mut self) {
6265        self.control_handle.shutdown();
6266        // Safety: drops once, never accessed again
6267        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6268    }
6269}
6270
6271impl fidl::endpoints::Responder for ConnectionTransferPeriodicAdvertisingSyncResponder {
6272    type ControlHandle = ConnectionControlHandle;
6273
6274    fn control_handle(&self) -> &ConnectionControlHandle {
6275        &self.control_handle
6276    }
6277
6278    fn drop_without_shutdown(mut self) {
6279        // Safety: drops once, never accessed again due to mem::forget
6280        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6281        // Prevent Drop from running (which would shut down the channel)
6282        std::mem::forget(self);
6283    }
6284}
6285
6286impl ConnectionTransferPeriodicAdvertisingSyncResponder {
6287    /// Sends a response to the FIDL transaction.
6288    ///
6289    /// Sets the channel to shutdown if an error occurs.
6290    pub fn send(
6291        self,
6292        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6293    ) -> Result<(), fidl::Error> {
6294        let _result = self.send_raw(result);
6295        if _result.is_err() {
6296            self.control_handle.shutdown();
6297        }
6298        self.drop_without_shutdown();
6299        _result
6300    }
6301
6302    /// Similar to "send" but does not shutdown the channel if an error occurs.
6303    pub fn send_no_shutdown_on_err(
6304        self,
6305        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6306    ) -> Result<(), fidl::Error> {
6307        let _result = self.send_raw(result);
6308        self.drop_without_shutdown();
6309        _result
6310    }
6311
6312    fn send_raw(
6313        &self,
6314        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6315    ) -> Result<(), fidl::Error> {
6316        self.control_handle.inner.send::<fidl::encoding::ResultType<
6317            fidl::encoding::EmptyStruct,
6318            PeriodicAdvertisingSyncTransferError,
6319        >>(
6320            result,
6321            self.tx_id,
6322            0x1117a10b5ba1e219,
6323            fidl::encoding::DynamicFlags::empty(),
6324        )
6325    }
6326}
6327
6328#[must_use = "FIDL methods require a response to be sent"]
6329#[derive(Debug)]
6330pub struct ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
6331    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
6332    tx_id: u32,
6333}
6334
6335/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
6336/// if the responder is dropped without sending a response, so that the client
6337/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6338impl std::ops::Drop for ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
6339    fn drop(&mut self) {
6340        self.control_handle.shutdown();
6341        // Safety: drops once, never accessed again
6342        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6343    }
6344}
6345
6346impl fidl::endpoints::Responder for ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
6347    type ControlHandle = ConnectionControlHandle;
6348
6349    fn control_handle(&self) -> &ConnectionControlHandle {
6350        &self.control_handle
6351    }
6352
6353    fn drop_without_shutdown(mut self) {
6354        // Safety: drops once, never accessed again due to mem::forget
6355        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6356        // Prevent Drop from running (which would shut down the channel)
6357        std::mem::forget(self);
6358    }
6359}
6360
6361impl ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
6362    /// Sends a response to the FIDL transaction.
6363    ///
6364    /// Sets the channel to shutdown if an error occurs.
6365    pub fn send(
6366        self,
6367        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6368    ) -> Result<(), fidl::Error> {
6369        let _result = self.send_raw(result);
6370        if _result.is_err() {
6371            self.control_handle.shutdown();
6372        }
6373        self.drop_without_shutdown();
6374        _result
6375    }
6376
6377    /// Similar to "send" but does not shutdown the channel if an error occurs.
6378    pub fn send_no_shutdown_on_err(
6379        self,
6380        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6381    ) -> Result<(), fidl::Error> {
6382        let _result = self.send_raw(result);
6383        self.drop_without_shutdown();
6384        _result
6385    }
6386
6387    fn send_raw(
6388        &self,
6389        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6390    ) -> Result<(), fidl::Error> {
6391        self.control_handle.inner.send::<fidl::encoding::ResultType<
6392            fidl::encoding::EmptyStruct,
6393            PeriodicAdvertisingSyncTransferError,
6394        >>(
6395            result,
6396            self.tx_id,
6397            0x441a31a7effa7e2b,
6398            fidl::encoding::DynamicFlags::empty(),
6399        )
6400    }
6401}
6402
6403#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6404pub struct IsochronousStreamMarker;
6405
6406impl fidl::endpoints::ProtocolMarker for IsochronousStreamMarker {
6407    type Proxy = IsochronousStreamProxy;
6408    type RequestStream = IsochronousStreamRequestStream;
6409    #[cfg(target_os = "fuchsia")]
6410    type SynchronousProxy = IsochronousStreamSynchronousProxy;
6411
6412    const DEBUG_NAME: &'static str = "(anonymous) IsochronousStream";
6413}
6414pub type IsochronousStreamSetupDataPathResult = Result<(), i32>;
6415pub type IsochronousStreamWriteResult = Result<(), i32>;
6416
6417pub trait IsochronousStreamProxyInterface: Send + Sync {
6418    type SetupDataPathResponseFut: std::future::Future<Output = Result<IsochronousStreamSetupDataPathResult, fidl::Error>>
6419        + Send;
6420    fn r#setup_data_path(
6421        &self,
6422        payload: &IsochronousStreamSetupDataPathRequest,
6423    ) -> Self::SetupDataPathResponseFut;
6424    type ReadResponseFut: std::future::Future<Output = Result<IsochronousStreamReadResponse, fidl::Error>>
6425        + Send;
6426    fn r#read(&self) -> Self::ReadResponseFut;
6427    type WriteResponseFut: std::future::Future<Output = Result<IsochronousStreamWriteResult, fidl::Error>>
6428        + Send;
6429    fn r#write(&self, payload: &IsochronousStreamWriteRequest) -> Self::WriteResponseFut;
6430}
6431#[derive(Debug)]
6432#[cfg(target_os = "fuchsia")]
6433pub struct IsochronousStreamSynchronousProxy {
6434    client: fidl::client::sync::Client,
6435}
6436
6437#[cfg(target_os = "fuchsia")]
6438impl fidl::endpoints::SynchronousProxy for IsochronousStreamSynchronousProxy {
6439    type Proxy = IsochronousStreamProxy;
6440    type Protocol = IsochronousStreamMarker;
6441
6442    fn from_channel(inner: fidl::Channel) -> Self {
6443        Self::new(inner)
6444    }
6445
6446    fn into_channel(self) -> fidl::Channel {
6447        self.client.into_channel()
6448    }
6449
6450    fn as_channel(&self) -> &fidl::Channel {
6451        self.client.as_channel()
6452    }
6453}
6454
6455#[cfg(target_os = "fuchsia")]
6456impl IsochronousStreamSynchronousProxy {
6457    pub fn new(channel: fidl::Channel) -> Self {
6458        let protocol_name =
6459            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6460        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6461    }
6462
6463    pub fn into_channel(self) -> fidl::Channel {
6464        self.client.into_channel()
6465    }
6466
6467    /// Waits until an event arrives and returns it. It is safe for other
6468    /// threads to make concurrent requests while waiting for an event.
6469    pub fn wait_for_event(
6470        &self,
6471        deadline: zx::MonotonicInstant,
6472    ) -> Result<IsochronousStreamEvent, fidl::Error> {
6473        IsochronousStreamEvent::decode(self.client.wait_for_event(deadline)?)
6474    }
6475
6476    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
6477    /// transport is currently supported.
6478    ///
6479    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
6480    /// direction.
6481    ///
6482    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
6483    /// accepted.
6484    ///
6485    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
6486    /// controller's supported range.
6487    pub fn r#setup_data_path(
6488        &self,
6489        mut payload: &IsochronousStreamSetupDataPathRequest,
6490        ___deadline: zx::MonotonicInstant,
6491    ) -> Result<IsochronousStreamSetupDataPathResult, fidl::Error> {
6492        let _response = self.client.send_query::<
6493            IsochronousStreamSetupDataPathRequest,
6494            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6495        >(
6496            payload,
6497            0x7ec1e2b9cc6d2fbe,
6498            fidl::encoding::DynamicFlags::FLEXIBLE,
6499            ___deadline,
6500        )?
6501        .into_result::<IsochronousStreamMarker>("setup_data_path")?;
6502        Ok(_response.map(|x| x))
6503    }
6504
6505    /// Receive data from an output (controller => host) ISO stream that has been established and
6506    /// set up. Designed to be used with a hanging get pattern.
6507    ///
6508    /// Can be invoked before the ISO data stream has been established and set up, but will not
6509    /// return until after it has been set up and data has been received.
6510    pub fn r#read(
6511        &self,
6512        ___deadline: zx::MonotonicInstant,
6513    ) -> Result<IsochronousStreamReadResponse, fidl::Error> {
6514        let _response = self.client.send_query::<
6515            fidl::encoding::EmptyPayload,
6516            fidl::encoding::FlexibleType<IsochronousStreamReadResponse>,
6517        >(
6518            (),
6519            0x6d7d8b4950ed3a32,
6520            fidl::encoding::DynamicFlags::FLEXIBLE,
6521            ___deadline,
6522        )?
6523        .into_result::<IsochronousStreamMarker>("read")?;
6524        Ok(_response)
6525    }
6526
6527    /// Send data to an established ISO stream (host => controller).
6528    ///
6529    /// Returns ZX_ERR_INTERNAL for any errors encountered.
6530    pub fn r#write(
6531        &self,
6532        mut payload: &IsochronousStreamWriteRequest,
6533        ___deadline: zx::MonotonicInstant,
6534    ) -> Result<IsochronousStreamWriteResult, fidl::Error> {
6535        let _response = self.client.send_query::<
6536            IsochronousStreamWriteRequest,
6537            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6538        >(
6539            payload,
6540            0x5282e90b667d0d43,
6541            fidl::encoding::DynamicFlags::FLEXIBLE,
6542            ___deadline,
6543        )?
6544        .into_result::<IsochronousStreamMarker>("write")?;
6545        Ok(_response.map(|x| x))
6546    }
6547}
6548
6549#[cfg(target_os = "fuchsia")]
6550impl From<IsochronousStreamSynchronousProxy> for zx::Handle {
6551    fn from(value: IsochronousStreamSynchronousProxy) -> Self {
6552        value.into_channel().into()
6553    }
6554}
6555
6556#[cfg(target_os = "fuchsia")]
6557impl From<fidl::Channel> for IsochronousStreamSynchronousProxy {
6558    fn from(value: fidl::Channel) -> Self {
6559        Self::new(value)
6560    }
6561}
6562
6563#[cfg(target_os = "fuchsia")]
6564impl fidl::endpoints::FromClient for IsochronousStreamSynchronousProxy {
6565    type Protocol = IsochronousStreamMarker;
6566
6567    fn from_client(value: fidl::endpoints::ClientEnd<IsochronousStreamMarker>) -> Self {
6568        Self::new(value.into_channel())
6569    }
6570}
6571
6572#[derive(Debug, Clone)]
6573pub struct IsochronousStreamProxy {
6574    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6575}
6576
6577impl fidl::endpoints::Proxy for IsochronousStreamProxy {
6578    type Protocol = IsochronousStreamMarker;
6579
6580    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6581        Self::new(inner)
6582    }
6583
6584    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6585        self.client.into_channel().map_err(|client| Self { client })
6586    }
6587
6588    fn as_channel(&self) -> &::fidl::AsyncChannel {
6589        self.client.as_channel()
6590    }
6591}
6592
6593impl IsochronousStreamProxy {
6594    /// Create a new Proxy for fuchsia.bluetooth.le/IsochronousStream.
6595    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6596        let protocol_name =
6597            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6598        Self { client: fidl::client::Client::new(channel, protocol_name) }
6599    }
6600
6601    /// Get a Stream of events from the remote end of the protocol.
6602    ///
6603    /// # Panics
6604    ///
6605    /// Panics if the event stream was already taken.
6606    pub fn take_event_stream(&self) -> IsochronousStreamEventStream {
6607        IsochronousStreamEventStream { event_receiver: self.client.take_event_receiver() }
6608    }
6609
6610    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
6611    /// transport is currently supported.
6612    ///
6613    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
6614    /// direction.
6615    ///
6616    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
6617    /// accepted.
6618    ///
6619    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
6620    /// controller's supported range.
6621    pub fn r#setup_data_path(
6622        &self,
6623        mut payload: &IsochronousStreamSetupDataPathRequest,
6624    ) -> fidl::client::QueryResponseFut<
6625        IsochronousStreamSetupDataPathResult,
6626        fidl::encoding::DefaultFuchsiaResourceDialect,
6627    > {
6628        IsochronousStreamProxyInterface::r#setup_data_path(self, payload)
6629    }
6630
6631    /// Receive data from an output (controller => host) ISO stream that has been established and
6632    /// set up. Designed to be used with a hanging get pattern.
6633    ///
6634    /// Can be invoked before the ISO data stream has been established and set up, but will not
6635    /// return until after it has been set up and data has been received.
6636    pub fn r#read(
6637        &self,
6638    ) -> fidl::client::QueryResponseFut<
6639        IsochronousStreamReadResponse,
6640        fidl::encoding::DefaultFuchsiaResourceDialect,
6641    > {
6642        IsochronousStreamProxyInterface::r#read(self)
6643    }
6644
6645    /// Send data to an established ISO stream (host => controller).
6646    ///
6647    /// Returns ZX_ERR_INTERNAL for any errors encountered.
6648    pub fn r#write(
6649        &self,
6650        mut payload: &IsochronousStreamWriteRequest,
6651    ) -> fidl::client::QueryResponseFut<
6652        IsochronousStreamWriteResult,
6653        fidl::encoding::DefaultFuchsiaResourceDialect,
6654    > {
6655        IsochronousStreamProxyInterface::r#write(self, payload)
6656    }
6657}
6658
6659impl IsochronousStreamProxyInterface for IsochronousStreamProxy {
6660    type SetupDataPathResponseFut = fidl::client::QueryResponseFut<
6661        IsochronousStreamSetupDataPathResult,
6662        fidl::encoding::DefaultFuchsiaResourceDialect,
6663    >;
6664    fn r#setup_data_path(
6665        &self,
6666        mut payload: &IsochronousStreamSetupDataPathRequest,
6667    ) -> Self::SetupDataPathResponseFut {
6668        fn _decode(
6669            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6670        ) -> Result<IsochronousStreamSetupDataPathResult, fidl::Error> {
6671            let _response = fidl::client::decode_transaction_body::<
6672                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6673                fidl::encoding::DefaultFuchsiaResourceDialect,
6674                0x7ec1e2b9cc6d2fbe,
6675            >(_buf?)?
6676            .into_result::<IsochronousStreamMarker>("setup_data_path")?;
6677            Ok(_response.map(|x| x))
6678        }
6679        self.client.send_query_and_decode::<
6680            IsochronousStreamSetupDataPathRequest,
6681            IsochronousStreamSetupDataPathResult,
6682        >(
6683            payload,
6684            0x7ec1e2b9cc6d2fbe,
6685            fidl::encoding::DynamicFlags::FLEXIBLE,
6686            _decode,
6687        )
6688    }
6689
6690    type ReadResponseFut = fidl::client::QueryResponseFut<
6691        IsochronousStreamReadResponse,
6692        fidl::encoding::DefaultFuchsiaResourceDialect,
6693    >;
6694    fn r#read(&self) -> Self::ReadResponseFut {
6695        fn _decode(
6696            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6697        ) -> Result<IsochronousStreamReadResponse, fidl::Error> {
6698            let _response = fidl::client::decode_transaction_body::<
6699                fidl::encoding::FlexibleType<IsochronousStreamReadResponse>,
6700                fidl::encoding::DefaultFuchsiaResourceDialect,
6701                0x6d7d8b4950ed3a32,
6702            >(_buf?)?
6703            .into_result::<IsochronousStreamMarker>("read")?;
6704            Ok(_response)
6705        }
6706        self.client
6707            .send_query_and_decode::<fidl::encoding::EmptyPayload, IsochronousStreamReadResponse>(
6708                (),
6709                0x6d7d8b4950ed3a32,
6710                fidl::encoding::DynamicFlags::FLEXIBLE,
6711                _decode,
6712            )
6713    }
6714
6715    type WriteResponseFut = fidl::client::QueryResponseFut<
6716        IsochronousStreamWriteResult,
6717        fidl::encoding::DefaultFuchsiaResourceDialect,
6718    >;
6719    fn r#write(&self, mut payload: &IsochronousStreamWriteRequest) -> Self::WriteResponseFut {
6720        fn _decode(
6721            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6722        ) -> Result<IsochronousStreamWriteResult, fidl::Error> {
6723            let _response = fidl::client::decode_transaction_body::<
6724                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6725                fidl::encoding::DefaultFuchsiaResourceDialect,
6726                0x5282e90b667d0d43,
6727            >(_buf?)?
6728            .into_result::<IsochronousStreamMarker>("write")?;
6729            Ok(_response.map(|x| x))
6730        }
6731        self.client
6732            .send_query_and_decode::<IsochronousStreamWriteRequest, IsochronousStreamWriteResult>(
6733                payload,
6734                0x5282e90b667d0d43,
6735                fidl::encoding::DynamicFlags::FLEXIBLE,
6736                _decode,
6737            )
6738    }
6739}
6740
6741pub struct IsochronousStreamEventStream {
6742    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6743}
6744
6745impl std::marker::Unpin for IsochronousStreamEventStream {}
6746
6747impl futures::stream::FusedStream for IsochronousStreamEventStream {
6748    fn is_terminated(&self) -> bool {
6749        self.event_receiver.is_terminated()
6750    }
6751}
6752
6753impl futures::Stream for IsochronousStreamEventStream {
6754    type Item = Result<IsochronousStreamEvent, fidl::Error>;
6755
6756    fn poll_next(
6757        mut self: std::pin::Pin<&mut Self>,
6758        cx: &mut std::task::Context<'_>,
6759    ) -> std::task::Poll<Option<Self::Item>> {
6760        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6761            &mut self.event_receiver,
6762            cx
6763        )?) {
6764            Some(buf) => std::task::Poll::Ready(Some(IsochronousStreamEvent::decode(buf))),
6765            None => std::task::Poll::Ready(None),
6766        }
6767    }
6768}
6769
6770#[derive(Debug)]
6771pub enum IsochronousStreamEvent {
6772    OnEstablished {
6773        payload: IsochronousStreamOnEstablishedRequest,
6774    },
6775    #[non_exhaustive]
6776    _UnknownEvent {
6777        /// Ordinal of the event that was sent.
6778        ordinal: u64,
6779    },
6780}
6781
6782impl IsochronousStreamEvent {
6783    #[allow(irrefutable_let_patterns)]
6784    pub fn into_on_established(self) -> Option<IsochronousStreamOnEstablishedRequest> {
6785        if let IsochronousStreamEvent::OnEstablished { payload } = self {
6786            Some((payload))
6787        } else {
6788            None
6789        }
6790    }
6791
6792    /// Decodes a message buffer as a [`IsochronousStreamEvent`].
6793    fn decode(
6794        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6795    ) -> Result<IsochronousStreamEvent, fidl::Error> {
6796        let (bytes, _handles) = buf.split_mut();
6797        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6798        debug_assert_eq!(tx_header.tx_id, 0);
6799        match tx_header.ordinal {
6800            0x341c50e9d10f3421 => {
6801                let mut out = fidl::new_empty!(
6802                    IsochronousStreamOnEstablishedRequest,
6803                    fidl::encoding::DefaultFuchsiaResourceDialect
6804                );
6805                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamOnEstablishedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6806                Ok((IsochronousStreamEvent::OnEstablished { payload: out }))
6807            }
6808            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6809                Ok(IsochronousStreamEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6810            }
6811            _ => Err(fidl::Error::UnknownOrdinal {
6812                ordinal: tx_header.ordinal,
6813                protocol_name:
6814                    <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6815            }),
6816        }
6817    }
6818}
6819
6820/// A Stream of incoming requests for fuchsia.bluetooth.le/IsochronousStream.
6821pub struct IsochronousStreamRequestStream {
6822    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6823    is_terminated: bool,
6824}
6825
6826impl std::marker::Unpin for IsochronousStreamRequestStream {}
6827
6828impl futures::stream::FusedStream for IsochronousStreamRequestStream {
6829    fn is_terminated(&self) -> bool {
6830        self.is_terminated
6831    }
6832}
6833
6834impl fidl::endpoints::RequestStream for IsochronousStreamRequestStream {
6835    type Protocol = IsochronousStreamMarker;
6836    type ControlHandle = IsochronousStreamControlHandle;
6837
6838    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6839        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6840    }
6841
6842    fn control_handle(&self) -> Self::ControlHandle {
6843        IsochronousStreamControlHandle { inner: self.inner.clone() }
6844    }
6845
6846    fn into_inner(
6847        self,
6848    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6849    {
6850        (self.inner, self.is_terminated)
6851    }
6852
6853    fn from_inner(
6854        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6855        is_terminated: bool,
6856    ) -> Self {
6857        Self { inner, is_terminated }
6858    }
6859}
6860
6861impl futures::Stream for IsochronousStreamRequestStream {
6862    type Item = Result<IsochronousStreamRequest, fidl::Error>;
6863
6864    fn poll_next(
6865        mut self: std::pin::Pin<&mut Self>,
6866        cx: &mut std::task::Context<'_>,
6867    ) -> std::task::Poll<Option<Self::Item>> {
6868        let this = &mut *self;
6869        if this.inner.check_shutdown(cx) {
6870            this.is_terminated = true;
6871            return std::task::Poll::Ready(None);
6872        }
6873        if this.is_terminated {
6874            panic!("polled IsochronousStreamRequestStream after completion");
6875        }
6876        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6877            |bytes, handles| {
6878                match this.inner.channel().read_etc(cx, bytes, handles) {
6879                    std::task::Poll::Ready(Ok(())) => {}
6880                    std::task::Poll::Pending => return std::task::Poll::Pending,
6881                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6882                        this.is_terminated = true;
6883                        return std::task::Poll::Ready(None);
6884                    }
6885                    std::task::Poll::Ready(Err(e)) => {
6886                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6887                            e.into(),
6888                        ))));
6889                    }
6890                }
6891
6892                // A message has been received from the channel
6893                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6894
6895                std::task::Poll::Ready(Some(match header.ordinal {
6896                    0x7ec1e2b9cc6d2fbe => {
6897                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6898                        let mut req = fidl::new_empty!(
6899                            IsochronousStreamSetupDataPathRequest,
6900                            fidl::encoding::DefaultFuchsiaResourceDialect
6901                        );
6902                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamSetupDataPathRequest>(&header, _body_bytes, handles, &mut req)?;
6903                        let control_handle =
6904                            IsochronousStreamControlHandle { inner: this.inner.clone() };
6905                        Ok(IsochronousStreamRequest::SetupDataPath {
6906                            payload: req,
6907                            responder: IsochronousStreamSetupDataPathResponder {
6908                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6909                                tx_id: header.tx_id,
6910                            },
6911                        })
6912                    }
6913                    0x6d7d8b4950ed3a32 => {
6914                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6915                        let mut req = fidl::new_empty!(
6916                            fidl::encoding::EmptyPayload,
6917                            fidl::encoding::DefaultFuchsiaResourceDialect
6918                        );
6919                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6920                        let control_handle =
6921                            IsochronousStreamControlHandle { inner: this.inner.clone() };
6922                        Ok(IsochronousStreamRequest::Read {
6923                            responder: IsochronousStreamReadResponder {
6924                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6925                                tx_id: header.tx_id,
6926                            },
6927                        })
6928                    }
6929                    0x5282e90b667d0d43 => {
6930                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6931                        let mut req = fidl::new_empty!(
6932                            IsochronousStreamWriteRequest,
6933                            fidl::encoding::DefaultFuchsiaResourceDialect
6934                        );
6935                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamWriteRequest>(&header, _body_bytes, handles, &mut req)?;
6936                        let control_handle =
6937                            IsochronousStreamControlHandle { inner: this.inner.clone() };
6938                        Ok(IsochronousStreamRequest::Write {
6939                            payload: req,
6940                            responder: IsochronousStreamWriteResponder {
6941                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6942                                tx_id: header.tx_id,
6943                            },
6944                        })
6945                    }
6946                    _ if header.tx_id == 0
6947                        && header
6948                            .dynamic_flags()
6949                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6950                    {
6951                        Ok(IsochronousStreamRequest::_UnknownMethod {
6952                            ordinal: header.ordinal,
6953                            control_handle: IsochronousStreamControlHandle {
6954                                inner: this.inner.clone(),
6955                            },
6956                            method_type: fidl::MethodType::OneWay,
6957                        })
6958                    }
6959                    _ if header
6960                        .dynamic_flags()
6961                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6962                    {
6963                        this.inner.send_framework_err(
6964                            fidl::encoding::FrameworkErr::UnknownMethod,
6965                            header.tx_id,
6966                            header.ordinal,
6967                            header.dynamic_flags(),
6968                            (bytes, handles),
6969                        )?;
6970                        Ok(IsochronousStreamRequest::_UnknownMethod {
6971                            ordinal: header.ordinal,
6972                            control_handle: IsochronousStreamControlHandle {
6973                                inner: this.inner.clone(),
6974                            },
6975                            method_type: fidl::MethodType::TwoWay,
6976                        })
6977                    }
6978                    _ => Err(fidl::Error::UnknownOrdinal {
6979                        ordinal: header.ordinal,
6980                        protocol_name:
6981                            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6982                    }),
6983                }))
6984            },
6985        )
6986    }
6987}
6988
6989#[derive(Debug)]
6990pub enum IsochronousStreamRequest {
6991    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
6992    /// transport is currently supported.
6993    ///
6994    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
6995    /// direction.
6996    ///
6997    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
6998    /// accepted.
6999    ///
7000    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
7001    /// controller's supported range.
7002    SetupDataPath {
7003        payload: IsochronousStreamSetupDataPathRequest,
7004        responder: IsochronousStreamSetupDataPathResponder,
7005    },
7006    /// Receive data from an output (controller => host) ISO stream that has been established and
7007    /// set up. Designed to be used with a hanging get pattern.
7008    ///
7009    /// Can be invoked before the ISO data stream has been established and set up, but will not
7010    /// return until after it has been set up and data has been received.
7011    Read { responder: IsochronousStreamReadResponder },
7012    /// Send data to an established ISO stream (host => controller).
7013    ///
7014    /// Returns ZX_ERR_INTERNAL for any errors encountered.
7015    Write { payload: IsochronousStreamWriteRequest, responder: IsochronousStreamWriteResponder },
7016    /// An interaction was received which does not match any known method.
7017    #[non_exhaustive]
7018    _UnknownMethod {
7019        /// Ordinal of the method that was called.
7020        ordinal: u64,
7021        control_handle: IsochronousStreamControlHandle,
7022        method_type: fidl::MethodType,
7023    },
7024}
7025
7026impl IsochronousStreamRequest {
7027    #[allow(irrefutable_let_patterns)]
7028    pub fn into_setup_data_path(
7029        self,
7030    ) -> Option<(IsochronousStreamSetupDataPathRequest, IsochronousStreamSetupDataPathResponder)>
7031    {
7032        if let IsochronousStreamRequest::SetupDataPath { payload, responder } = self {
7033            Some((payload, responder))
7034        } else {
7035            None
7036        }
7037    }
7038
7039    #[allow(irrefutable_let_patterns)]
7040    pub fn into_read(self) -> Option<(IsochronousStreamReadResponder)> {
7041        if let IsochronousStreamRequest::Read { responder } = self {
7042            Some((responder))
7043        } else {
7044            None
7045        }
7046    }
7047
7048    #[allow(irrefutable_let_patterns)]
7049    pub fn into_write(
7050        self,
7051    ) -> Option<(IsochronousStreamWriteRequest, IsochronousStreamWriteResponder)> {
7052        if let IsochronousStreamRequest::Write { payload, responder } = self {
7053            Some((payload, responder))
7054        } else {
7055            None
7056        }
7057    }
7058
7059    /// Name of the method defined in FIDL
7060    pub fn method_name(&self) -> &'static str {
7061        match *self {
7062            IsochronousStreamRequest::SetupDataPath { .. } => "setup_data_path",
7063            IsochronousStreamRequest::Read { .. } => "read",
7064            IsochronousStreamRequest::Write { .. } => "write",
7065            IsochronousStreamRequest::_UnknownMethod {
7066                method_type: fidl::MethodType::OneWay,
7067                ..
7068            } => "unknown one-way method",
7069            IsochronousStreamRequest::_UnknownMethod {
7070                method_type: fidl::MethodType::TwoWay,
7071                ..
7072            } => "unknown two-way method",
7073        }
7074    }
7075}
7076
7077#[derive(Debug, Clone)]
7078pub struct IsochronousStreamControlHandle {
7079    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7080}
7081
7082impl fidl::endpoints::ControlHandle for IsochronousStreamControlHandle {
7083    fn shutdown(&self) {
7084        self.inner.shutdown()
7085    }
7086    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7087        self.inner.shutdown_with_epitaph(status)
7088    }
7089
7090    fn is_closed(&self) -> bool {
7091        self.inner.channel().is_closed()
7092    }
7093    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7094        self.inner.channel().on_closed()
7095    }
7096
7097    #[cfg(target_os = "fuchsia")]
7098    fn signal_peer(
7099        &self,
7100        clear_mask: zx::Signals,
7101        set_mask: zx::Signals,
7102    ) -> Result<(), zx_status::Status> {
7103        use fidl::Peered;
7104        self.inner.channel().signal_peer(clear_mask, set_mask)
7105    }
7106}
7107
7108impl IsochronousStreamControlHandle {
7109    pub fn send_on_established(
7110        &self,
7111        mut payload: &IsochronousStreamOnEstablishedRequest,
7112    ) -> Result<(), fidl::Error> {
7113        self.inner.send::<IsochronousStreamOnEstablishedRequest>(
7114            payload,
7115            0,
7116            0x341c50e9d10f3421,
7117            fidl::encoding::DynamicFlags::FLEXIBLE,
7118        )
7119    }
7120}
7121
7122#[must_use = "FIDL methods require a response to be sent"]
7123#[derive(Debug)]
7124pub struct IsochronousStreamSetupDataPathResponder {
7125    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
7126    tx_id: u32,
7127}
7128
7129/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
7130/// if the responder is dropped without sending a response, so that the client
7131/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7132impl std::ops::Drop for IsochronousStreamSetupDataPathResponder {
7133    fn drop(&mut self) {
7134        self.control_handle.shutdown();
7135        // Safety: drops once, never accessed again
7136        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7137    }
7138}
7139
7140impl fidl::endpoints::Responder for IsochronousStreamSetupDataPathResponder {
7141    type ControlHandle = IsochronousStreamControlHandle;
7142
7143    fn control_handle(&self) -> &IsochronousStreamControlHandle {
7144        &self.control_handle
7145    }
7146
7147    fn drop_without_shutdown(mut self) {
7148        // Safety: drops once, never accessed again due to mem::forget
7149        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7150        // Prevent Drop from running (which would shut down the channel)
7151        std::mem::forget(self);
7152    }
7153}
7154
7155impl IsochronousStreamSetupDataPathResponder {
7156    /// Sends a response to the FIDL transaction.
7157    ///
7158    /// Sets the channel to shutdown if an error occurs.
7159    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7160        let _result = self.send_raw(result);
7161        if _result.is_err() {
7162            self.control_handle.shutdown();
7163        }
7164        self.drop_without_shutdown();
7165        _result
7166    }
7167
7168    /// Similar to "send" but does not shutdown the channel if an error occurs.
7169    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7170        let _result = self.send_raw(result);
7171        self.drop_without_shutdown();
7172        _result
7173    }
7174
7175    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7176        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7177            fidl::encoding::EmptyStruct,
7178            i32,
7179        >>(
7180            fidl::encoding::FlexibleResult::new(result),
7181            self.tx_id,
7182            0x7ec1e2b9cc6d2fbe,
7183            fidl::encoding::DynamicFlags::FLEXIBLE,
7184        )
7185    }
7186}
7187
7188#[must_use = "FIDL methods require a response to be sent"]
7189#[derive(Debug)]
7190pub struct IsochronousStreamReadResponder {
7191    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
7192    tx_id: u32,
7193}
7194
7195/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
7196/// if the responder is dropped without sending a response, so that the client
7197/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7198impl std::ops::Drop for IsochronousStreamReadResponder {
7199    fn drop(&mut self) {
7200        self.control_handle.shutdown();
7201        // Safety: drops once, never accessed again
7202        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7203    }
7204}
7205
7206impl fidl::endpoints::Responder for IsochronousStreamReadResponder {
7207    type ControlHandle = IsochronousStreamControlHandle;
7208
7209    fn control_handle(&self) -> &IsochronousStreamControlHandle {
7210        &self.control_handle
7211    }
7212
7213    fn drop_without_shutdown(mut self) {
7214        // Safety: drops once, never accessed again due to mem::forget
7215        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7216        // Prevent Drop from running (which would shut down the channel)
7217        std::mem::forget(self);
7218    }
7219}
7220
7221impl IsochronousStreamReadResponder {
7222    /// Sends a response to the FIDL transaction.
7223    ///
7224    /// Sets the channel to shutdown if an error occurs.
7225    pub fn send(self, mut payload: &IsochronousStreamReadResponse) -> Result<(), fidl::Error> {
7226        let _result = self.send_raw(payload);
7227        if _result.is_err() {
7228            self.control_handle.shutdown();
7229        }
7230        self.drop_without_shutdown();
7231        _result
7232    }
7233
7234    /// Similar to "send" but does not shutdown the channel if an error occurs.
7235    pub fn send_no_shutdown_on_err(
7236        self,
7237        mut payload: &IsochronousStreamReadResponse,
7238    ) -> Result<(), fidl::Error> {
7239        let _result = self.send_raw(payload);
7240        self.drop_without_shutdown();
7241        _result
7242    }
7243
7244    fn send_raw(&self, mut payload: &IsochronousStreamReadResponse) -> Result<(), fidl::Error> {
7245        self.control_handle
7246            .inner
7247            .send::<fidl::encoding::FlexibleType<IsochronousStreamReadResponse>>(
7248                fidl::encoding::Flexible::new(payload),
7249                self.tx_id,
7250                0x6d7d8b4950ed3a32,
7251                fidl::encoding::DynamicFlags::FLEXIBLE,
7252            )
7253    }
7254}
7255
7256#[must_use = "FIDL methods require a response to be sent"]
7257#[derive(Debug)]
7258pub struct IsochronousStreamWriteResponder {
7259    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
7260    tx_id: u32,
7261}
7262
7263/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
7264/// if the responder is dropped without sending a response, so that the client
7265/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7266impl std::ops::Drop for IsochronousStreamWriteResponder {
7267    fn drop(&mut self) {
7268        self.control_handle.shutdown();
7269        // Safety: drops once, never accessed again
7270        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7271    }
7272}
7273
7274impl fidl::endpoints::Responder for IsochronousStreamWriteResponder {
7275    type ControlHandle = IsochronousStreamControlHandle;
7276
7277    fn control_handle(&self) -> &IsochronousStreamControlHandle {
7278        &self.control_handle
7279    }
7280
7281    fn drop_without_shutdown(mut self) {
7282        // Safety: drops once, never accessed again due to mem::forget
7283        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7284        // Prevent Drop from running (which would shut down the channel)
7285        std::mem::forget(self);
7286    }
7287}
7288
7289impl IsochronousStreamWriteResponder {
7290    /// Sends a response to the FIDL transaction.
7291    ///
7292    /// Sets the channel to shutdown if an error occurs.
7293    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7294        let _result = self.send_raw(result);
7295        if _result.is_err() {
7296            self.control_handle.shutdown();
7297        }
7298        self.drop_without_shutdown();
7299        _result
7300    }
7301
7302    /// Similar to "send" but does not shutdown the channel if an error occurs.
7303    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7304        let _result = self.send_raw(result);
7305        self.drop_without_shutdown();
7306        _result
7307    }
7308
7309    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7310        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7311            fidl::encoding::EmptyStruct,
7312            i32,
7313        >>(
7314            fidl::encoding::FlexibleResult::new(result),
7315            self.tx_id,
7316            0x5282e90b667d0d43,
7317            fidl::encoding::DynamicFlags::FLEXIBLE,
7318        )
7319    }
7320}
7321
7322#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7323pub struct PeriodicAdvertisingSyncMarker;
7324
7325impl fidl::endpoints::ProtocolMarker for PeriodicAdvertisingSyncMarker {
7326    type Proxy = PeriodicAdvertisingSyncProxy;
7327    type RequestStream = PeriodicAdvertisingSyncRequestStream;
7328    #[cfg(target_os = "fuchsia")]
7329    type SynchronousProxy = PeriodicAdvertisingSyncSynchronousProxy;
7330
7331    const DEBUG_NAME: &'static str = "(anonymous) PeriodicAdvertisingSync";
7332}
7333pub type PeriodicAdvertisingSyncSyncToSubeventsResult = Result<(), i32>;
7334
7335pub trait PeriodicAdvertisingSyncProxyInterface: Send + Sync {
7336    type WatchAdvertisingReportResponseFut: std::future::Future<
7337            Output = Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error>,
7338        > + Send;
7339    fn r#watch_advertising_report(&self) -> Self::WatchAdvertisingReportResponseFut;
7340    type SyncToSubeventsResponseFut: std::future::Future<
7341            Output = Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error>,
7342        > + Send;
7343    fn r#sync_to_subevents(
7344        &self,
7345        payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
7346    ) -> Self::SyncToSubeventsResponseFut;
7347    fn r#cancel(&self) -> Result<(), fidl::Error>;
7348}
7349#[derive(Debug)]
7350#[cfg(target_os = "fuchsia")]
7351pub struct PeriodicAdvertisingSyncSynchronousProxy {
7352    client: fidl::client::sync::Client,
7353}
7354
7355#[cfg(target_os = "fuchsia")]
7356impl fidl::endpoints::SynchronousProxy for PeriodicAdvertisingSyncSynchronousProxy {
7357    type Proxy = PeriodicAdvertisingSyncProxy;
7358    type Protocol = PeriodicAdvertisingSyncMarker;
7359
7360    fn from_channel(inner: fidl::Channel) -> Self {
7361        Self::new(inner)
7362    }
7363
7364    fn into_channel(self) -> fidl::Channel {
7365        self.client.into_channel()
7366    }
7367
7368    fn as_channel(&self) -> &fidl::Channel {
7369        self.client.as_channel()
7370    }
7371}
7372
7373#[cfg(target_os = "fuchsia")]
7374impl PeriodicAdvertisingSyncSynchronousProxy {
7375    pub fn new(channel: fidl::Channel) -> Self {
7376        let protocol_name =
7377            <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7378        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7379    }
7380
7381    pub fn into_channel(self) -> fidl::Channel {
7382        self.client.into_channel()
7383    }
7384
7385    /// Waits until an event arrives and returns it. It is safe for other
7386    /// threads to make concurrent requests while waiting for an event.
7387    pub fn wait_for_event(
7388        &self,
7389        deadline: zx::MonotonicInstant,
7390    ) -> Result<PeriodicAdvertisingSyncEvent, fidl::Error> {
7391        PeriodicAdvertisingSyncEvent::decode(self.client.wait_for_event(deadline)?)
7392    }
7393
7394    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
7395    /// Only one call may be pending at a time.
7396    pub fn r#watch_advertising_report(
7397        &self,
7398        ___deadline: zx::MonotonicInstant,
7399    ) -> Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error> {
7400        let _response = self.client.send_query::<
7401            fidl::encoding::EmptyPayload,
7402            fidl::encoding::FlexibleType<PeriodicAdvertisingSyncWatchAdvertisingReportResponse>,
7403        >(
7404            (),
7405            0x2ea610fea0e7d337,
7406            fidl::encoding::DynamicFlags::FLEXIBLE,
7407            ___deadline,
7408        )?
7409        .into_result::<PeriodicAdvertisingSyncMarker>("watch_advertising_report")?;
7410        Ok(_response)
7411    }
7412
7413    /// Synchronize to subevents of this periodic advertisement.
7414    /// * error FAILED: The synchronization failed.
7415    pub fn r#sync_to_subevents(
7416        &self,
7417        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
7418        ___deadline: zx::MonotonicInstant,
7419    ) -> Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error> {
7420        let _response = self.client.send_query::<
7421            PeriodicAdvertisingSyncSyncToSubeventsRequest,
7422            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7423        >(
7424            payload,
7425            0x653c5dab1f1d80ed,
7426            fidl::encoding::DynamicFlags::FLEXIBLE,
7427            ___deadline,
7428        )?
7429        .into_result::<PeriodicAdvertisingSyncMarker>("sync_to_subevents")?;
7430        Ok(_response.map(|x| x))
7431    }
7432
7433    /// The server will end the synchronization and then close the protocol.
7434    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
7435    /// Advertisement.
7436    /// Synchronization can also be cancelled by closing the protocol on the client end.
7437    pub fn r#cancel(&self) -> Result<(), fidl::Error> {
7438        self.client.send::<fidl::encoding::EmptyPayload>(
7439            (),
7440            0xd617c037eaf5d92,
7441            fidl::encoding::DynamicFlags::FLEXIBLE,
7442        )
7443    }
7444}
7445
7446#[cfg(target_os = "fuchsia")]
7447impl From<PeriodicAdvertisingSyncSynchronousProxy> for zx::Handle {
7448    fn from(value: PeriodicAdvertisingSyncSynchronousProxy) -> Self {
7449        value.into_channel().into()
7450    }
7451}
7452
7453#[cfg(target_os = "fuchsia")]
7454impl From<fidl::Channel> for PeriodicAdvertisingSyncSynchronousProxy {
7455    fn from(value: fidl::Channel) -> Self {
7456        Self::new(value)
7457    }
7458}
7459
7460#[cfg(target_os = "fuchsia")]
7461impl fidl::endpoints::FromClient for PeriodicAdvertisingSyncSynchronousProxy {
7462    type Protocol = PeriodicAdvertisingSyncMarker;
7463
7464    fn from_client(value: fidl::endpoints::ClientEnd<PeriodicAdvertisingSyncMarker>) -> Self {
7465        Self::new(value.into_channel())
7466    }
7467}
7468
7469#[derive(Debug, Clone)]
7470pub struct PeriodicAdvertisingSyncProxy {
7471    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7472}
7473
7474impl fidl::endpoints::Proxy for PeriodicAdvertisingSyncProxy {
7475    type Protocol = PeriodicAdvertisingSyncMarker;
7476
7477    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7478        Self::new(inner)
7479    }
7480
7481    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7482        self.client.into_channel().map_err(|client| Self { client })
7483    }
7484
7485    fn as_channel(&self) -> &::fidl::AsyncChannel {
7486        self.client.as_channel()
7487    }
7488}
7489
7490impl PeriodicAdvertisingSyncProxy {
7491    /// Create a new Proxy for fuchsia.bluetooth.le/PeriodicAdvertisingSync.
7492    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7493        let protocol_name =
7494            <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7495        Self { client: fidl::client::Client::new(channel, protocol_name) }
7496    }
7497
7498    /// Get a Stream of events from the remote end of the protocol.
7499    ///
7500    /// # Panics
7501    ///
7502    /// Panics if the event stream was already taken.
7503    pub fn take_event_stream(&self) -> PeriodicAdvertisingSyncEventStream {
7504        PeriodicAdvertisingSyncEventStream { event_receiver: self.client.take_event_receiver() }
7505    }
7506
7507    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
7508    /// Only one call may be pending at a time.
7509    pub fn r#watch_advertising_report(
7510        &self,
7511    ) -> fidl::client::QueryResponseFut<
7512        PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
7513        fidl::encoding::DefaultFuchsiaResourceDialect,
7514    > {
7515        PeriodicAdvertisingSyncProxyInterface::r#watch_advertising_report(self)
7516    }
7517
7518    /// Synchronize to subevents of this periodic advertisement.
7519    /// * error FAILED: The synchronization failed.
7520    pub fn r#sync_to_subevents(
7521        &self,
7522        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
7523    ) -> fidl::client::QueryResponseFut<
7524        PeriodicAdvertisingSyncSyncToSubeventsResult,
7525        fidl::encoding::DefaultFuchsiaResourceDialect,
7526    > {
7527        PeriodicAdvertisingSyncProxyInterface::r#sync_to_subevents(self, payload)
7528    }
7529
7530    /// The server will end the synchronization and then close the protocol.
7531    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
7532    /// Advertisement.
7533    /// Synchronization can also be cancelled by closing the protocol on the client end.
7534    pub fn r#cancel(&self) -> Result<(), fidl::Error> {
7535        PeriodicAdvertisingSyncProxyInterface::r#cancel(self)
7536    }
7537}
7538
7539impl PeriodicAdvertisingSyncProxyInterface for PeriodicAdvertisingSyncProxy {
7540    type WatchAdvertisingReportResponseFut = fidl::client::QueryResponseFut<
7541        PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
7542        fidl::encoding::DefaultFuchsiaResourceDialect,
7543    >;
7544    fn r#watch_advertising_report(&self) -> Self::WatchAdvertisingReportResponseFut {
7545        fn _decode(
7546            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7547        ) -> Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error> {
7548            let _response = fidl::client::decode_transaction_body::<
7549                fidl::encoding::FlexibleType<PeriodicAdvertisingSyncWatchAdvertisingReportResponse>,
7550                fidl::encoding::DefaultFuchsiaResourceDialect,
7551                0x2ea610fea0e7d337,
7552            >(_buf?)?
7553            .into_result::<PeriodicAdvertisingSyncMarker>("watch_advertising_report")?;
7554            Ok(_response)
7555        }
7556        self.client.send_query_and_decode::<
7557            fidl::encoding::EmptyPayload,
7558            PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
7559        >(
7560            (),
7561            0x2ea610fea0e7d337,
7562            fidl::encoding::DynamicFlags::FLEXIBLE,
7563            _decode,
7564        )
7565    }
7566
7567    type SyncToSubeventsResponseFut = fidl::client::QueryResponseFut<
7568        PeriodicAdvertisingSyncSyncToSubeventsResult,
7569        fidl::encoding::DefaultFuchsiaResourceDialect,
7570    >;
7571    fn r#sync_to_subevents(
7572        &self,
7573        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
7574    ) -> Self::SyncToSubeventsResponseFut {
7575        fn _decode(
7576            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7577        ) -> Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error> {
7578            let _response = fidl::client::decode_transaction_body::<
7579                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7580                fidl::encoding::DefaultFuchsiaResourceDialect,
7581                0x653c5dab1f1d80ed,
7582            >(_buf?)?
7583            .into_result::<PeriodicAdvertisingSyncMarker>("sync_to_subevents")?;
7584            Ok(_response.map(|x| x))
7585        }
7586        self.client.send_query_and_decode::<
7587            PeriodicAdvertisingSyncSyncToSubeventsRequest,
7588            PeriodicAdvertisingSyncSyncToSubeventsResult,
7589        >(
7590            payload,
7591            0x653c5dab1f1d80ed,
7592            fidl::encoding::DynamicFlags::FLEXIBLE,
7593            _decode,
7594        )
7595    }
7596
7597    fn r#cancel(&self) -> Result<(), fidl::Error> {
7598        self.client.send::<fidl::encoding::EmptyPayload>(
7599            (),
7600            0xd617c037eaf5d92,
7601            fidl::encoding::DynamicFlags::FLEXIBLE,
7602        )
7603    }
7604}
7605
7606pub struct PeriodicAdvertisingSyncEventStream {
7607    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7608}
7609
7610impl std::marker::Unpin for PeriodicAdvertisingSyncEventStream {}
7611
7612impl futures::stream::FusedStream for PeriodicAdvertisingSyncEventStream {
7613    fn is_terminated(&self) -> bool {
7614        self.event_receiver.is_terminated()
7615    }
7616}
7617
7618impl futures::Stream for PeriodicAdvertisingSyncEventStream {
7619    type Item = Result<PeriodicAdvertisingSyncEvent, fidl::Error>;
7620
7621    fn poll_next(
7622        mut self: std::pin::Pin<&mut Self>,
7623        cx: &mut std::task::Context<'_>,
7624    ) -> std::task::Poll<Option<Self::Item>> {
7625        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7626            &mut self.event_receiver,
7627            cx
7628        )?) {
7629            Some(buf) => std::task::Poll::Ready(Some(PeriodicAdvertisingSyncEvent::decode(buf))),
7630            None => std::task::Poll::Ready(None),
7631        }
7632    }
7633}
7634
7635#[derive(Debug)]
7636pub enum PeriodicAdvertisingSyncEvent {
7637    OnEstablished {
7638        payload: PeriodicAdvertisingSyncOnEstablishedRequest,
7639    },
7640    OnError {
7641        error: PeriodicAdvertisingSyncError,
7642    },
7643    #[non_exhaustive]
7644    _UnknownEvent {
7645        /// Ordinal of the event that was sent.
7646        ordinal: u64,
7647    },
7648}
7649
7650impl PeriodicAdvertisingSyncEvent {
7651    #[allow(irrefutable_let_patterns)]
7652    pub fn into_on_established(self) -> Option<PeriodicAdvertisingSyncOnEstablishedRequest> {
7653        if let PeriodicAdvertisingSyncEvent::OnEstablished { payload } = self {
7654            Some((payload))
7655        } else {
7656            None
7657        }
7658    }
7659    #[allow(irrefutable_let_patterns)]
7660    pub fn into_on_error(self) -> Option<PeriodicAdvertisingSyncError> {
7661        if let PeriodicAdvertisingSyncEvent::OnError { error } = self {
7662            Some((error))
7663        } else {
7664            None
7665        }
7666    }
7667
7668    /// Decodes a message buffer as a [`PeriodicAdvertisingSyncEvent`].
7669    fn decode(
7670        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7671    ) -> Result<PeriodicAdvertisingSyncEvent, fidl::Error> {
7672        let (bytes, _handles) = buf.split_mut();
7673        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7674        debug_assert_eq!(tx_header.tx_id, 0);
7675        match tx_header.ordinal {
7676            0x4a5c307761c40fdc => {
7677                let mut out = fidl::new_empty!(
7678                    PeriodicAdvertisingSyncOnEstablishedRequest,
7679                    fidl::encoding::DefaultFuchsiaResourceDialect
7680                );
7681                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncOnEstablishedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7682                Ok((PeriodicAdvertisingSyncEvent::OnEstablished { payload: out }))
7683            }
7684            0x1c051673126ce4a => {
7685                let mut out = fidl::new_empty!(
7686                    PeriodicAdvertisingSyncOnErrorRequest,
7687                    fidl::encoding::DefaultFuchsiaResourceDialect
7688                );
7689                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncOnErrorRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7690                Ok((PeriodicAdvertisingSyncEvent::OnError { error: out.error }))
7691            }
7692            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7693                Ok(PeriodicAdvertisingSyncEvent::_UnknownEvent { ordinal: tx_header.ordinal })
7694            }
7695            _ => Err(fidl::Error::UnknownOrdinal {
7696                ordinal: tx_header.ordinal,
7697                protocol_name:
7698                    <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7699            }),
7700        }
7701    }
7702}
7703
7704/// A Stream of incoming requests for fuchsia.bluetooth.le/PeriodicAdvertisingSync.
7705pub struct PeriodicAdvertisingSyncRequestStream {
7706    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7707    is_terminated: bool,
7708}
7709
7710impl std::marker::Unpin for PeriodicAdvertisingSyncRequestStream {}
7711
7712impl futures::stream::FusedStream for PeriodicAdvertisingSyncRequestStream {
7713    fn is_terminated(&self) -> bool {
7714        self.is_terminated
7715    }
7716}
7717
7718impl fidl::endpoints::RequestStream for PeriodicAdvertisingSyncRequestStream {
7719    type Protocol = PeriodicAdvertisingSyncMarker;
7720    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
7721
7722    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7723        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7724    }
7725
7726    fn control_handle(&self) -> Self::ControlHandle {
7727        PeriodicAdvertisingSyncControlHandle { inner: self.inner.clone() }
7728    }
7729
7730    fn into_inner(
7731        self,
7732    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7733    {
7734        (self.inner, self.is_terminated)
7735    }
7736
7737    fn from_inner(
7738        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7739        is_terminated: bool,
7740    ) -> Self {
7741        Self { inner, is_terminated }
7742    }
7743}
7744
7745impl futures::Stream for PeriodicAdvertisingSyncRequestStream {
7746    type Item = Result<PeriodicAdvertisingSyncRequest, fidl::Error>;
7747
7748    fn poll_next(
7749        mut self: std::pin::Pin<&mut Self>,
7750        cx: &mut std::task::Context<'_>,
7751    ) -> std::task::Poll<Option<Self::Item>> {
7752        let this = &mut *self;
7753        if this.inner.check_shutdown(cx) {
7754            this.is_terminated = true;
7755            return std::task::Poll::Ready(None);
7756        }
7757        if this.is_terminated {
7758            panic!("polled PeriodicAdvertisingSyncRequestStream after completion");
7759        }
7760        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7761            |bytes, handles| {
7762                match this.inner.channel().read_etc(cx, bytes, handles) {
7763                    std::task::Poll::Ready(Ok(())) => {}
7764                    std::task::Poll::Pending => return std::task::Poll::Pending,
7765                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7766                        this.is_terminated = true;
7767                        return std::task::Poll::Ready(None);
7768                    }
7769                    std::task::Poll::Ready(Err(e)) => {
7770                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7771                            e.into(),
7772                        ))));
7773                    }
7774                }
7775
7776                // A message has been received from the channel
7777                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7778
7779                std::task::Poll::Ready(Some(match header.ordinal {
7780                0x2ea610fea0e7d337 => {
7781                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7782                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7783                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7784                    let control_handle = PeriodicAdvertisingSyncControlHandle {
7785                        inner: this.inner.clone(),
7786                    };
7787                    Ok(PeriodicAdvertisingSyncRequest::WatchAdvertisingReport {
7788                        responder: PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
7789                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7790                            tx_id: header.tx_id,
7791                        },
7792                    })
7793                }
7794                0x653c5dab1f1d80ed => {
7795                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7796                    let mut req = fidl::new_empty!(PeriodicAdvertisingSyncSyncToSubeventsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7797                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncSyncToSubeventsRequest>(&header, _body_bytes, handles, &mut req)?;
7798                    let control_handle = PeriodicAdvertisingSyncControlHandle {
7799                        inner: this.inner.clone(),
7800                    };
7801                    Ok(PeriodicAdvertisingSyncRequest::SyncToSubevents {payload: req,
7802                        responder: PeriodicAdvertisingSyncSyncToSubeventsResponder {
7803                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7804                            tx_id: header.tx_id,
7805                        },
7806                    })
7807                }
7808                0xd617c037eaf5d92 => {
7809                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7810                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7811                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7812                    let control_handle = PeriodicAdvertisingSyncControlHandle {
7813                        inner: this.inner.clone(),
7814                    };
7815                    Ok(PeriodicAdvertisingSyncRequest::Cancel {
7816                        control_handle,
7817                    })
7818                }
7819                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7820                    Ok(PeriodicAdvertisingSyncRequest::_UnknownMethod {
7821                        ordinal: header.ordinal,
7822                        control_handle: PeriodicAdvertisingSyncControlHandle { inner: this.inner.clone() },
7823                        method_type: fidl::MethodType::OneWay,
7824                    })
7825                }
7826                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7827                    this.inner.send_framework_err(
7828                        fidl::encoding::FrameworkErr::UnknownMethod,
7829                        header.tx_id,
7830                        header.ordinal,
7831                        header.dynamic_flags(),
7832                        (bytes, handles),
7833                    )?;
7834                    Ok(PeriodicAdvertisingSyncRequest::_UnknownMethod {
7835                        ordinal: header.ordinal,
7836                        control_handle: PeriodicAdvertisingSyncControlHandle { inner: this.inner.clone() },
7837                        method_type: fidl::MethodType::TwoWay,
7838                    })
7839                }
7840                _ => Err(fidl::Error::UnknownOrdinal {
7841                    ordinal: header.ordinal,
7842                    protocol_name: <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7843                }),
7844            }))
7845            },
7846        )
7847    }
7848}
7849
7850/// Closed by the server when the sync fails to be established or is lost.
7851#[derive(Debug)]
7852pub enum PeriodicAdvertisingSyncRequest {
7853    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
7854    /// Only one call may be pending at a time.
7855    WatchAdvertisingReport { responder: PeriodicAdvertisingSyncWatchAdvertisingReportResponder },
7856    /// Synchronize to subevents of this periodic advertisement.
7857    /// * error FAILED: The synchronization failed.
7858    SyncToSubevents {
7859        payload: PeriodicAdvertisingSyncSyncToSubeventsRequest,
7860        responder: PeriodicAdvertisingSyncSyncToSubeventsResponder,
7861    },
7862    /// The server will end the synchronization and then close the protocol.
7863    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
7864    /// Advertisement.
7865    /// Synchronization can also be cancelled by closing the protocol on the client end.
7866    Cancel { control_handle: PeriodicAdvertisingSyncControlHandle },
7867    /// An interaction was received which does not match any known method.
7868    #[non_exhaustive]
7869    _UnknownMethod {
7870        /// Ordinal of the method that was called.
7871        ordinal: u64,
7872        control_handle: PeriodicAdvertisingSyncControlHandle,
7873        method_type: fidl::MethodType,
7874    },
7875}
7876
7877impl PeriodicAdvertisingSyncRequest {
7878    #[allow(irrefutable_let_patterns)]
7879    pub fn into_watch_advertising_report(
7880        self,
7881    ) -> Option<(PeriodicAdvertisingSyncWatchAdvertisingReportResponder)> {
7882        if let PeriodicAdvertisingSyncRequest::WatchAdvertisingReport { responder } = self {
7883            Some((responder))
7884        } else {
7885            None
7886        }
7887    }
7888
7889    #[allow(irrefutable_let_patterns)]
7890    pub fn into_sync_to_subevents(
7891        self,
7892    ) -> Option<(
7893        PeriodicAdvertisingSyncSyncToSubeventsRequest,
7894        PeriodicAdvertisingSyncSyncToSubeventsResponder,
7895    )> {
7896        if let PeriodicAdvertisingSyncRequest::SyncToSubevents { payload, responder } = self {
7897            Some((payload, responder))
7898        } else {
7899            None
7900        }
7901    }
7902
7903    #[allow(irrefutable_let_patterns)]
7904    pub fn into_cancel(self) -> Option<(PeriodicAdvertisingSyncControlHandle)> {
7905        if let PeriodicAdvertisingSyncRequest::Cancel { control_handle } = self {
7906            Some((control_handle))
7907        } else {
7908            None
7909        }
7910    }
7911
7912    /// Name of the method defined in FIDL
7913    pub fn method_name(&self) -> &'static str {
7914        match *self {
7915            PeriodicAdvertisingSyncRequest::WatchAdvertisingReport { .. } => {
7916                "watch_advertising_report"
7917            }
7918            PeriodicAdvertisingSyncRequest::SyncToSubevents { .. } => "sync_to_subevents",
7919            PeriodicAdvertisingSyncRequest::Cancel { .. } => "cancel",
7920            PeriodicAdvertisingSyncRequest::_UnknownMethod {
7921                method_type: fidl::MethodType::OneWay,
7922                ..
7923            } => "unknown one-way method",
7924            PeriodicAdvertisingSyncRequest::_UnknownMethod {
7925                method_type: fidl::MethodType::TwoWay,
7926                ..
7927            } => "unknown two-way method",
7928        }
7929    }
7930}
7931
7932#[derive(Debug, Clone)]
7933pub struct PeriodicAdvertisingSyncControlHandle {
7934    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7935}
7936
7937impl fidl::endpoints::ControlHandle for PeriodicAdvertisingSyncControlHandle {
7938    fn shutdown(&self) {
7939        self.inner.shutdown()
7940    }
7941    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7942        self.inner.shutdown_with_epitaph(status)
7943    }
7944
7945    fn is_closed(&self) -> bool {
7946        self.inner.channel().is_closed()
7947    }
7948    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7949        self.inner.channel().on_closed()
7950    }
7951
7952    #[cfg(target_os = "fuchsia")]
7953    fn signal_peer(
7954        &self,
7955        clear_mask: zx::Signals,
7956        set_mask: zx::Signals,
7957    ) -> Result<(), zx_status::Status> {
7958        use fidl::Peered;
7959        self.inner.channel().signal_peer(clear_mask, set_mask)
7960    }
7961}
7962
7963impl PeriodicAdvertisingSyncControlHandle {
7964    pub fn send_on_established(
7965        &self,
7966        mut payload: &PeriodicAdvertisingSyncOnEstablishedRequest,
7967    ) -> Result<(), fidl::Error> {
7968        self.inner.send::<PeriodicAdvertisingSyncOnEstablishedRequest>(
7969            payload,
7970            0,
7971            0x4a5c307761c40fdc,
7972            fidl::encoding::DynamicFlags::FLEXIBLE,
7973        )
7974    }
7975
7976    pub fn send_on_error(
7977        &self,
7978        mut error: PeriodicAdvertisingSyncError,
7979    ) -> Result<(), fidl::Error> {
7980        self.inner.send::<PeriodicAdvertisingSyncOnErrorRequest>(
7981            (error,),
7982            0,
7983            0x1c051673126ce4a,
7984            fidl::encoding::DynamicFlags::FLEXIBLE,
7985        )
7986    }
7987}
7988
7989#[must_use = "FIDL methods require a response to be sent"]
7990#[derive(Debug)]
7991pub struct PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
7992    control_handle: std::mem::ManuallyDrop<PeriodicAdvertisingSyncControlHandle>,
7993    tx_id: u32,
7994}
7995
7996/// Set the the channel to be shutdown (see [`PeriodicAdvertisingSyncControlHandle::shutdown`])
7997/// if the responder is dropped without sending a response, so that the client
7998/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7999impl std::ops::Drop for PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8000    fn drop(&mut self) {
8001        self.control_handle.shutdown();
8002        // Safety: drops once, never accessed again
8003        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8004    }
8005}
8006
8007impl fidl::endpoints::Responder for PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8008    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
8009
8010    fn control_handle(&self) -> &PeriodicAdvertisingSyncControlHandle {
8011        &self.control_handle
8012    }
8013
8014    fn drop_without_shutdown(mut self) {
8015        // Safety: drops once, never accessed again due to mem::forget
8016        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8017        // Prevent Drop from running (which would shut down the channel)
8018        std::mem::forget(self);
8019    }
8020}
8021
8022impl PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8023    /// Sends a response to the FIDL transaction.
8024    ///
8025    /// Sets the channel to shutdown if an error occurs.
8026    pub fn send(
8027        self,
8028        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8029    ) -> Result<(), fidl::Error> {
8030        let _result = self.send_raw(payload);
8031        if _result.is_err() {
8032            self.control_handle.shutdown();
8033        }
8034        self.drop_without_shutdown();
8035        _result
8036    }
8037
8038    /// Similar to "send" but does not shutdown the channel if an error occurs.
8039    pub fn send_no_shutdown_on_err(
8040        self,
8041        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8042    ) -> Result<(), fidl::Error> {
8043        let _result = self.send_raw(payload);
8044        self.drop_without_shutdown();
8045        _result
8046    }
8047
8048    fn send_raw(
8049        &self,
8050        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8051    ) -> Result<(), fidl::Error> {
8052        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
8053            PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8054        >>(
8055            fidl::encoding::Flexible::new(payload),
8056            self.tx_id,
8057            0x2ea610fea0e7d337,
8058            fidl::encoding::DynamicFlags::FLEXIBLE,
8059        )
8060    }
8061}
8062
8063#[must_use = "FIDL methods require a response to be sent"]
8064#[derive(Debug)]
8065pub struct PeriodicAdvertisingSyncSyncToSubeventsResponder {
8066    control_handle: std::mem::ManuallyDrop<PeriodicAdvertisingSyncControlHandle>,
8067    tx_id: u32,
8068}
8069
8070/// Set the the channel to be shutdown (see [`PeriodicAdvertisingSyncControlHandle::shutdown`])
8071/// if the responder is dropped without sending a response, so that the client
8072/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8073impl std::ops::Drop for PeriodicAdvertisingSyncSyncToSubeventsResponder {
8074    fn drop(&mut self) {
8075        self.control_handle.shutdown();
8076        // Safety: drops once, never accessed again
8077        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8078    }
8079}
8080
8081impl fidl::endpoints::Responder for PeriodicAdvertisingSyncSyncToSubeventsResponder {
8082    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
8083
8084    fn control_handle(&self) -> &PeriodicAdvertisingSyncControlHandle {
8085        &self.control_handle
8086    }
8087
8088    fn drop_without_shutdown(mut self) {
8089        // Safety: drops once, never accessed again due to mem::forget
8090        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8091        // Prevent Drop from running (which would shut down the channel)
8092        std::mem::forget(self);
8093    }
8094}
8095
8096impl PeriodicAdvertisingSyncSyncToSubeventsResponder {
8097    /// Sends a response to the FIDL transaction.
8098    ///
8099    /// Sets the channel to shutdown if an error occurs.
8100    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8101        let _result = self.send_raw(result);
8102        if _result.is_err() {
8103            self.control_handle.shutdown();
8104        }
8105        self.drop_without_shutdown();
8106        _result
8107    }
8108
8109    /// Similar to "send" but does not shutdown the channel if an error occurs.
8110    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8111        let _result = self.send_raw(result);
8112        self.drop_without_shutdown();
8113        _result
8114    }
8115
8116    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8117        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8118            fidl::encoding::EmptyStruct,
8119            i32,
8120        >>(
8121            fidl::encoding::FlexibleResult::new(result),
8122            self.tx_id,
8123            0x653c5dab1f1d80ed,
8124            fidl::encoding::DynamicFlags::FLEXIBLE,
8125        )
8126    }
8127}
8128
8129#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8130pub struct PeripheralMarker;
8131
8132impl fidl::endpoints::ProtocolMarker for PeripheralMarker {
8133    type Proxy = PeripheralProxy;
8134    type RequestStream = PeripheralRequestStream;
8135    #[cfg(target_os = "fuchsia")]
8136    type SynchronousProxy = PeripheralSynchronousProxy;
8137
8138    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.Peripheral";
8139}
8140impl fidl::endpoints::DiscoverableProtocolMarker for PeripheralMarker {}
8141pub type PeripheralAdvertiseResult = Result<(), PeripheralError>;
8142pub type PeripheralStartAdvertisingResult = Result<(), PeripheralError>;
8143
8144pub trait PeripheralProxyInterface: Send + Sync {
8145    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
8146        + Send;
8147    fn r#listen_l2cap(
8148        &self,
8149        payload: ChannelListenerRegistryListenL2capRequest,
8150    ) -> Self::ListenL2capResponseFut;
8151    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralAdvertiseResult, fidl::Error>>
8152        + Send;
8153    fn r#advertise(
8154        &self,
8155        parameters: &AdvertisingParameters,
8156        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8157    ) -> Self::AdvertiseResponseFut;
8158    type StartAdvertisingResponseFut: std::future::Future<Output = Result<PeripheralStartAdvertisingResult, fidl::Error>>
8159        + Send;
8160    fn r#start_advertising(
8161        &self,
8162        parameters: &AdvertisingParameters,
8163        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8164    ) -> Self::StartAdvertisingResponseFut;
8165}
8166#[derive(Debug)]
8167#[cfg(target_os = "fuchsia")]
8168pub struct PeripheralSynchronousProxy {
8169    client: fidl::client::sync::Client,
8170}
8171
8172#[cfg(target_os = "fuchsia")]
8173impl fidl::endpoints::SynchronousProxy for PeripheralSynchronousProxy {
8174    type Proxy = PeripheralProxy;
8175    type Protocol = PeripheralMarker;
8176
8177    fn from_channel(inner: fidl::Channel) -> Self {
8178        Self::new(inner)
8179    }
8180
8181    fn into_channel(self) -> fidl::Channel {
8182        self.client.into_channel()
8183    }
8184
8185    fn as_channel(&self) -> &fidl::Channel {
8186        self.client.as_channel()
8187    }
8188}
8189
8190#[cfg(target_os = "fuchsia")]
8191impl PeripheralSynchronousProxy {
8192    pub fn new(channel: fidl::Channel) -> Self {
8193        let protocol_name = <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8194        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8195    }
8196
8197    pub fn into_channel(self) -> fidl::Channel {
8198        self.client.into_channel()
8199    }
8200
8201    /// Waits until an event arrives and returns it. It is safe for other
8202    /// threads to make concurrent requests while waiting for an event.
8203    pub fn wait_for_event(
8204        &self,
8205        deadline: zx::MonotonicInstant,
8206    ) -> Result<PeripheralEvent, fidl::Error> {
8207        PeripheralEvent::decode(self.client.wait_for_event(deadline)?)
8208    }
8209
8210    /// Register a listener for incoming channels. The registry will assign a
8211    /// PSM value that is unique for the local device, as well as open a
8212    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
8213    /// event that all PSMs have been assigned, this call will fail with
8214    /// `ZX_ERR_NO_RESOURCES`.
8215    ///
8216    /// Note that the method of service discovery or advertising is defined by
8217    /// the service or protocol, so it is the responsibility of the caller to
8218    /// communicate the assigned PSM to any clients.
8219    pub fn r#listen_l2cap(
8220        &self,
8221        mut payload: ChannelListenerRegistryListenL2capRequest,
8222        ___deadline: zx::MonotonicInstant,
8223    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
8224        let _response = self.client.send_query::<
8225            ChannelListenerRegistryListenL2capRequest,
8226            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
8227        >(
8228            &mut payload,
8229            0x39c6e9001d102338,
8230            fidl::encoding::DynamicFlags::empty(),
8231            ___deadline,
8232        )?;
8233        Ok(_response.map(|x| x))
8234    }
8235
8236    /// Start advertising continuously as a LE peripheral. If advertising cannot
8237    /// be initiated then `advertised_peripheral` will be closed and an error
8238    /// will be returned.
8239    ///
8240    /// This method may be called any number of times. To reconfigure an
8241    /// advertisement, first close the original advertisement and then initiate
8242    /// a new advertisement after an empty response is returned.
8243    ///
8244    /// If the client closes its end of the
8245    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
8246    /// advertising will be stopped. If the handle is closed before the request
8247    /// is fulfilled, advertising may be briefly enabled before it is
8248    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
8249    /// the Peripheral protocol, but this may be changed in the future
8250    /// (https://fxbug.dev/42157682).
8251    ///
8252    /// + request `parameters` Parameters used while configuring the advertising
8253    ///   instance.
8254    /// + request `advertised_peripheral` Protocol that remains valid for the
8255    ///   duration of this advertising session.
8256    /// - response An empty response will be sent when the advertisement is
8257    ///   successfully stopped (due to release of the `advertised_peripheral`
8258    ///   protocol). To prevent overlapping similar advertisements and transient
8259    ///   errors with limited advertising resources, waiting for a response is
8260    ///   recommended before calling `Advertise` again.
8261    /// * error If an error occurs, `advertised_peripheral` will be closed and a
8262    ///   `PeripheralError` will be returned.
8263    pub fn r#advertise(
8264        &self,
8265        mut parameters: &AdvertisingParameters,
8266        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8267        ___deadline: zx::MonotonicInstant,
8268    ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
8269        let _response = self.client.send_query::<
8270            PeripheralAdvertiseRequest,
8271            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8272        >(
8273            (parameters, advertised_peripheral,),
8274            0x2d9ec9260c32c17f,
8275            fidl::encoding::DynamicFlags::empty(),
8276            ___deadline,
8277        )?;
8278        Ok(_response.map(|x| x))
8279    }
8280
8281    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
8282    /// has successfully initiated. If advertising cannot be initiated, then the response will
8283    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
8284    ///
8285    /// This method can get called any number of times and successive calls can be made to
8286    /// reconfigure the advertising parameters. However only the most recent
8287    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
8288    ///
8289    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
8290    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
8291    /// advertisements.
8292    ///
8293    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
8294    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
8295    /// advertising will be briefly enabled before it is terminated.
8296    ///
8297    /// + request `parameters` Parameters used while configuring the advertising instance.
8298    /// + request `handle` Handle that remains valid for the duration of this advertising session.
8299    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
8300    ///         initiated. In this case the `handle` will be closed.
8301    pub fn r#start_advertising(
8302        &self,
8303        mut parameters: &AdvertisingParameters,
8304        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8305        ___deadline: zx::MonotonicInstant,
8306    ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
8307        let _response = self.client.send_query::<
8308            PeripheralStartAdvertisingRequest,
8309            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8310        >(
8311            (parameters, handle,),
8312            0x5875c1c575f00f7d,
8313            fidl::encoding::DynamicFlags::empty(),
8314            ___deadline,
8315        )?;
8316        Ok(_response.map(|x| x))
8317    }
8318}
8319
8320#[cfg(target_os = "fuchsia")]
8321impl From<PeripheralSynchronousProxy> for zx::Handle {
8322    fn from(value: PeripheralSynchronousProxy) -> Self {
8323        value.into_channel().into()
8324    }
8325}
8326
8327#[cfg(target_os = "fuchsia")]
8328impl From<fidl::Channel> for PeripheralSynchronousProxy {
8329    fn from(value: fidl::Channel) -> Self {
8330        Self::new(value)
8331    }
8332}
8333
8334#[cfg(target_os = "fuchsia")]
8335impl fidl::endpoints::FromClient for PeripheralSynchronousProxy {
8336    type Protocol = PeripheralMarker;
8337
8338    fn from_client(value: fidl::endpoints::ClientEnd<PeripheralMarker>) -> Self {
8339        Self::new(value.into_channel())
8340    }
8341}
8342
8343#[derive(Debug, Clone)]
8344pub struct PeripheralProxy {
8345    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8346}
8347
8348impl fidl::endpoints::Proxy for PeripheralProxy {
8349    type Protocol = PeripheralMarker;
8350
8351    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8352        Self::new(inner)
8353    }
8354
8355    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8356        self.client.into_channel().map_err(|client| Self { client })
8357    }
8358
8359    fn as_channel(&self) -> &::fidl::AsyncChannel {
8360        self.client.as_channel()
8361    }
8362}
8363
8364impl PeripheralProxy {
8365    /// Create a new Proxy for fuchsia.bluetooth.le/Peripheral.
8366    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8367        let protocol_name = <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8368        Self { client: fidl::client::Client::new(channel, protocol_name) }
8369    }
8370
8371    /// Get a Stream of events from the remote end of the protocol.
8372    ///
8373    /// # Panics
8374    ///
8375    /// Panics if the event stream was already taken.
8376    pub fn take_event_stream(&self) -> PeripheralEventStream {
8377        PeripheralEventStream { event_receiver: self.client.take_event_receiver() }
8378    }
8379
8380    /// Register a listener for incoming channels. The registry will assign a
8381    /// PSM value that is unique for the local device, as well as open a
8382    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
8383    /// event that all PSMs have been assigned, this call will fail with
8384    /// `ZX_ERR_NO_RESOURCES`.
8385    ///
8386    /// Note that the method of service discovery or advertising is defined by
8387    /// the service or protocol, so it is the responsibility of the caller to
8388    /// communicate the assigned PSM to any clients.
8389    pub fn r#listen_l2cap(
8390        &self,
8391        mut payload: ChannelListenerRegistryListenL2capRequest,
8392    ) -> fidl::client::QueryResponseFut<
8393        ChannelListenerRegistryListenL2capResult,
8394        fidl::encoding::DefaultFuchsiaResourceDialect,
8395    > {
8396        PeripheralProxyInterface::r#listen_l2cap(self, payload)
8397    }
8398
8399    /// Start advertising continuously as a LE peripheral. If advertising cannot
8400    /// be initiated then `advertised_peripheral` will be closed and an error
8401    /// will be returned.
8402    ///
8403    /// This method may be called any number of times. To reconfigure an
8404    /// advertisement, first close the original advertisement and then initiate
8405    /// a new advertisement after an empty response is returned.
8406    ///
8407    /// If the client closes its end of the
8408    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
8409    /// advertising will be stopped. If the handle is closed before the request
8410    /// is fulfilled, advertising may be briefly enabled before it is
8411    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
8412    /// the Peripheral protocol, but this may be changed in the future
8413    /// (https://fxbug.dev/42157682).
8414    ///
8415    /// + request `parameters` Parameters used while configuring the advertising
8416    ///   instance.
8417    /// + request `advertised_peripheral` Protocol that remains valid for the
8418    ///   duration of this advertising session.
8419    /// - response An empty response will be sent when the advertisement is
8420    ///   successfully stopped (due to release of the `advertised_peripheral`
8421    ///   protocol). To prevent overlapping similar advertisements and transient
8422    ///   errors with limited advertising resources, waiting for a response is
8423    ///   recommended before calling `Advertise` again.
8424    /// * error If an error occurs, `advertised_peripheral` will be closed and a
8425    ///   `PeripheralError` will be returned.
8426    pub fn r#advertise(
8427        &self,
8428        mut parameters: &AdvertisingParameters,
8429        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8430    ) -> fidl::client::QueryResponseFut<
8431        PeripheralAdvertiseResult,
8432        fidl::encoding::DefaultFuchsiaResourceDialect,
8433    > {
8434        PeripheralProxyInterface::r#advertise(self, parameters, advertised_peripheral)
8435    }
8436
8437    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
8438    /// has successfully initiated. If advertising cannot be initiated, then the response will
8439    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
8440    ///
8441    /// This method can get called any number of times and successive calls can be made to
8442    /// reconfigure the advertising parameters. However only the most recent
8443    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
8444    ///
8445    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
8446    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
8447    /// advertisements.
8448    ///
8449    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
8450    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
8451    /// advertising will be briefly enabled before it is terminated.
8452    ///
8453    /// + request `parameters` Parameters used while configuring the advertising instance.
8454    /// + request `handle` Handle that remains valid for the duration of this advertising session.
8455    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
8456    ///         initiated. In this case the `handle` will be closed.
8457    pub fn r#start_advertising(
8458        &self,
8459        mut parameters: &AdvertisingParameters,
8460        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8461    ) -> fidl::client::QueryResponseFut<
8462        PeripheralStartAdvertisingResult,
8463        fidl::encoding::DefaultFuchsiaResourceDialect,
8464    > {
8465        PeripheralProxyInterface::r#start_advertising(self, parameters, handle)
8466    }
8467}
8468
8469impl PeripheralProxyInterface for PeripheralProxy {
8470    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
8471        ChannelListenerRegistryListenL2capResult,
8472        fidl::encoding::DefaultFuchsiaResourceDialect,
8473    >;
8474    fn r#listen_l2cap(
8475        &self,
8476        mut payload: ChannelListenerRegistryListenL2capRequest,
8477    ) -> Self::ListenL2capResponseFut {
8478        fn _decode(
8479            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8480        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
8481            let _response = fidl::client::decode_transaction_body::<
8482                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
8483                fidl::encoding::DefaultFuchsiaResourceDialect,
8484                0x39c6e9001d102338,
8485            >(_buf?)?;
8486            Ok(_response.map(|x| x))
8487        }
8488        self.client.send_query_and_decode::<
8489            ChannelListenerRegistryListenL2capRequest,
8490            ChannelListenerRegistryListenL2capResult,
8491        >(
8492            &mut payload,
8493            0x39c6e9001d102338,
8494            fidl::encoding::DynamicFlags::empty(),
8495            _decode,
8496        )
8497    }
8498
8499    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
8500        PeripheralAdvertiseResult,
8501        fidl::encoding::DefaultFuchsiaResourceDialect,
8502    >;
8503    fn r#advertise(
8504        &self,
8505        mut parameters: &AdvertisingParameters,
8506        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8507    ) -> Self::AdvertiseResponseFut {
8508        fn _decode(
8509            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8510        ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
8511            let _response = fidl::client::decode_transaction_body::<
8512                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8513                fidl::encoding::DefaultFuchsiaResourceDialect,
8514                0x2d9ec9260c32c17f,
8515            >(_buf?)?;
8516            Ok(_response.map(|x| x))
8517        }
8518        self.client.send_query_and_decode::<PeripheralAdvertiseRequest, PeripheralAdvertiseResult>(
8519            (parameters, advertised_peripheral),
8520            0x2d9ec9260c32c17f,
8521            fidl::encoding::DynamicFlags::empty(),
8522            _decode,
8523        )
8524    }
8525
8526    type StartAdvertisingResponseFut = fidl::client::QueryResponseFut<
8527        PeripheralStartAdvertisingResult,
8528        fidl::encoding::DefaultFuchsiaResourceDialect,
8529    >;
8530    fn r#start_advertising(
8531        &self,
8532        mut parameters: &AdvertisingParameters,
8533        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8534    ) -> Self::StartAdvertisingResponseFut {
8535        fn _decode(
8536            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8537        ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
8538            let _response = fidl::client::decode_transaction_body::<
8539                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8540                fidl::encoding::DefaultFuchsiaResourceDialect,
8541                0x5875c1c575f00f7d,
8542            >(_buf?)?;
8543            Ok(_response.map(|x| x))
8544        }
8545        self.client.send_query_and_decode::<
8546            PeripheralStartAdvertisingRequest,
8547            PeripheralStartAdvertisingResult,
8548        >(
8549            (parameters, handle,),
8550            0x5875c1c575f00f7d,
8551            fidl::encoding::DynamicFlags::empty(),
8552            _decode,
8553        )
8554    }
8555}
8556
8557pub struct PeripheralEventStream {
8558    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8559}
8560
8561impl std::marker::Unpin for PeripheralEventStream {}
8562
8563impl futures::stream::FusedStream for PeripheralEventStream {
8564    fn is_terminated(&self) -> bool {
8565        self.event_receiver.is_terminated()
8566    }
8567}
8568
8569impl futures::Stream for PeripheralEventStream {
8570    type Item = Result<PeripheralEvent, fidl::Error>;
8571
8572    fn poll_next(
8573        mut self: std::pin::Pin<&mut Self>,
8574        cx: &mut std::task::Context<'_>,
8575    ) -> std::task::Poll<Option<Self::Item>> {
8576        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8577            &mut self.event_receiver,
8578            cx
8579        )?) {
8580            Some(buf) => std::task::Poll::Ready(Some(PeripheralEvent::decode(buf))),
8581            None => std::task::Poll::Ready(None),
8582        }
8583    }
8584}
8585
8586#[derive(Debug)]
8587pub enum PeripheralEvent {
8588    OnPeerConnected { peer: Peer, connection: fidl::endpoints::ClientEnd<ConnectionMarker> },
8589}
8590
8591impl PeripheralEvent {
8592    #[allow(irrefutable_let_patterns)]
8593    pub fn into_on_peer_connected(
8594        self,
8595    ) -> Option<(Peer, fidl::endpoints::ClientEnd<ConnectionMarker>)> {
8596        if let PeripheralEvent::OnPeerConnected { peer, connection } = self {
8597            Some((peer, connection))
8598        } else {
8599            None
8600        }
8601    }
8602
8603    /// Decodes a message buffer as a [`PeripheralEvent`].
8604    fn decode(
8605        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8606    ) -> Result<PeripheralEvent, fidl::Error> {
8607        let (bytes, _handles) = buf.split_mut();
8608        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8609        debug_assert_eq!(tx_header.tx_id, 0);
8610        match tx_header.ordinal {
8611            0x16135d464299e356 => {
8612                let mut out = fidl::new_empty!(
8613                    PeripheralOnPeerConnectedRequest,
8614                    fidl::encoding::DefaultFuchsiaResourceDialect
8615                );
8616                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralOnPeerConnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
8617                Ok((PeripheralEvent::OnPeerConnected {
8618                    peer: out.peer,
8619                    connection: out.connection,
8620                }))
8621            }
8622            _ => Err(fidl::Error::UnknownOrdinal {
8623                ordinal: tx_header.ordinal,
8624                protocol_name: <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8625            }),
8626        }
8627    }
8628}
8629
8630/// A Stream of incoming requests for fuchsia.bluetooth.le/Peripheral.
8631pub struct PeripheralRequestStream {
8632    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8633    is_terminated: bool,
8634}
8635
8636impl std::marker::Unpin for PeripheralRequestStream {}
8637
8638impl futures::stream::FusedStream for PeripheralRequestStream {
8639    fn is_terminated(&self) -> bool {
8640        self.is_terminated
8641    }
8642}
8643
8644impl fidl::endpoints::RequestStream for PeripheralRequestStream {
8645    type Protocol = PeripheralMarker;
8646    type ControlHandle = PeripheralControlHandle;
8647
8648    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8649        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8650    }
8651
8652    fn control_handle(&self) -> Self::ControlHandle {
8653        PeripheralControlHandle { inner: self.inner.clone() }
8654    }
8655
8656    fn into_inner(
8657        self,
8658    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8659    {
8660        (self.inner, self.is_terminated)
8661    }
8662
8663    fn from_inner(
8664        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8665        is_terminated: bool,
8666    ) -> Self {
8667        Self { inner, is_terminated }
8668    }
8669}
8670
8671impl futures::Stream for PeripheralRequestStream {
8672    type Item = Result<PeripheralRequest, fidl::Error>;
8673
8674    fn poll_next(
8675        mut self: std::pin::Pin<&mut Self>,
8676        cx: &mut std::task::Context<'_>,
8677    ) -> std::task::Poll<Option<Self::Item>> {
8678        let this = &mut *self;
8679        if this.inner.check_shutdown(cx) {
8680            this.is_terminated = true;
8681            return std::task::Poll::Ready(None);
8682        }
8683        if this.is_terminated {
8684            panic!("polled PeripheralRequestStream after completion");
8685        }
8686        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8687            |bytes, handles| {
8688                match this.inner.channel().read_etc(cx, bytes, handles) {
8689                    std::task::Poll::Ready(Ok(())) => {}
8690                    std::task::Poll::Pending => return std::task::Poll::Pending,
8691                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8692                        this.is_terminated = true;
8693                        return std::task::Poll::Ready(None);
8694                    }
8695                    std::task::Poll::Ready(Err(e)) => {
8696                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8697                            e.into(),
8698                        ))));
8699                    }
8700                }
8701
8702                // A message has been received from the channel
8703                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8704
8705                std::task::Poll::Ready(Some(match header.ordinal {
8706                    0x39c6e9001d102338 => {
8707                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8708                        let mut req = fidl::new_empty!(
8709                            ChannelListenerRegistryListenL2capRequest,
8710                            fidl::encoding::DefaultFuchsiaResourceDialect
8711                        );
8712                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
8713                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
8714                        Ok(PeripheralRequest::ListenL2cap {
8715                            payload: req,
8716                            responder: PeripheralListenL2capResponder {
8717                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8718                                tx_id: header.tx_id,
8719                            },
8720                        })
8721                    }
8722                    0x2d9ec9260c32c17f => {
8723                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8724                        let mut req = fidl::new_empty!(
8725                            PeripheralAdvertiseRequest,
8726                            fidl::encoding::DefaultFuchsiaResourceDialect
8727                        );
8728                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
8729                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
8730                        Ok(PeripheralRequest::Advertise {
8731                            parameters: req.parameters,
8732                            advertised_peripheral: req.advertised_peripheral,
8733
8734                            responder: PeripheralAdvertiseResponder {
8735                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8736                                tx_id: header.tx_id,
8737                            },
8738                        })
8739                    }
8740                    0x5875c1c575f00f7d => {
8741                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8742                        let mut req = fidl::new_empty!(
8743                            PeripheralStartAdvertisingRequest,
8744                            fidl::encoding::DefaultFuchsiaResourceDialect
8745                        );
8746                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralStartAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
8747                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
8748                        Ok(PeripheralRequest::StartAdvertising {
8749                            parameters: req.parameters,
8750                            handle: req.handle,
8751
8752                            responder: PeripheralStartAdvertisingResponder {
8753                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8754                                tx_id: header.tx_id,
8755                            },
8756                        })
8757                    }
8758                    _ => Err(fidl::Error::UnknownOrdinal {
8759                        ordinal: header.ordinal,
8760                        protocol_name:
8761                            <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8762                    }),
8763                }))
8764            },
8765        )
8766    }
8767}
8768
8769#[derive(Debug)]
8770pub enum PeripheralRequest {
8771    /// Register a listener for incoming channels. The registry will assign a
8772    /// PSM value that is unique for the local device, as well as open a
8773    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
8774    /// event that all PSMs have been assigned, this call will fail with
8775    /// `ZX_ERR_NO_RESOURCES`.
8776    ///
8777    /// Note that the method of service discovery or advertising is defined by
8778    /// the service or protocol, so it is the responsibility of the caller to
8779    /// communicate the assigned PSM to any clients.
8780    ListenL2cap {
8781        payload: ChannelListenerRegistryListenL2capRequest,
8782        responder: PeripheralListenL2capResponder,
8783    },
8784    /// Start advertising continuously as a LE peripheral. If advertising cannot
8785    /// be initiated then `advertised_peripheral` will be closed and an error
8786    /// will be returned.
8787    ///
8788    /// This method may be called any number of times. To reconfigure an
8789    /// advertisement, first close the original advertisement and then initiate
8790    /// a new advertisement after an empty response is returned.
8791    ///
8792    /// If the client closes its end of the
8793    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
8794    /// advertising will be stopped. If the handle is closed before the request
8795    /// is fulfilled, advertising may be briefly enabled before it is
8796    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
8797    /// the Peripheral protocol, but this may be changed in the future
8798    /// (https://fxbug.dev/42157682).
8799    ///
8800    /// + request `parameters` Parameters used while configuring the advertising
8801    ///   instance.
8802    /// + request `advertised_peripheral` Protocol that remains valid for the
8803    ///   duration of this advertising session.
8804    /// - response An empty response will be sent when the advertisement is
8805    ///   successfully stopped (due to release of the `advertised_peripheral`
8806    ///   protocol). To prevent overlapping similar advertisements and transient
8807    ///   errors with limited advertising resources, waiting for a response is
8808    ///   recommended before calling `Advertise` again.
8809    /// * error If an error occurs, `advertised_peripheral` will be closed and a
8810    ///   `PeripheralError` will be returned.
8811    Advertise {
8812        parameters: AdvertisingParameters,
8813        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8814        responder: PeripheralAdvertiseResponder,
8815    },
8816    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
8817    /// has successfully initiated. If advertising cannot be initiated, then the response will
8818    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
8819    ///
8820    /// This method can get called any number of times and successive calls can be made to
8821    /// reconfigure the advertising parameters. However only the most recent
8822    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
8823    ///
8824    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
8825    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
8826    /// advertisements.
8827    ///
8828    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
8829    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
8830    /// advertising will be briefly enabled before it is terminated.
8831    ///
8832    /// + request `parameters` Parameters used while configuring the advertising instance.
8833    /// + request `handle` Handle that remains valid for the duration of this advertising session.
8834    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
8835    ///         initiated. In this case the `handle` will be closed.
8836    StartAdvertising {
8837        parameters: AdvertisingParameters,
8838        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8839        responder: PeripheralStartAdvertisingResponder,
8840    },
8841}
8842
8843impl PeripheralRequest {
8844    #[allow(irrefutable_let_patterns)]
8845    pub fn into_listen_l2cap(
8846        self,
8847    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PeripheralListenL2capResponder)> {
8848        if let PeripheralRequest::ListenL2cap { payload, responder } = self {
8849            Some((payload, responder))
8850        } else {
8851            None
8852        }
8853    }
8854
8855    #[allow(irrefutable_let_patterns)]
8856    pub fn into_advertise(
8857        self,
8858    ) -> Option<(
8859        AdvertisingParameters,
8860        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8861        PeripheralAdvertiseResponder,
8862    )> {
8863        if let PeripheralRequest::Advertise { parameters, advertised_peripheral, responder } = self
8864        {
8865            Some((parameters, advertised_peripheral, responder))
8866        } else {
8867            None
8868        }
8869    }
8870
8871    #[allow(irrefutable_let_patterns)]
8872    pub fn into_start_advertising(
8873        self,
8874    ) -> Option<(
8875        AdvertisingParameters,
8876        fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8877        PeripheralStartAdvertisingResponder,
8878    )> {
8879        if let PeripheralRequest::StartAdvertising { parameters, handle, responder } = self {
8880            Some((parameters, handle, responder))
8881        } else {
8882            None
8883        }
8884    }
8885
8886    /// Name of the method defined in FIDL
8887    pub fn method_name(&self) -> &'static str {
8888        match *self {
8889            PeripheralRequest::ListenL2cap { .. } => "listen_l2cap",
8890            PeripheralRequest::Advertise { .. } => "advertise",
8891            PeripheralRequest::StartAdvertising { .. } => "start_advertising",
8892        }
8893    }
8894}
8895
8896#[derive(Debug, Clone)]
8897pub struct PeripheralControlHandle {
8898    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8899}
8900
8901impl fidl::endpoints::ControlHandle for PeripheralControlHandle {
8902    fn shutdown(&self) {
8903        self.inner.shutdown()
8904    }
8905    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8906        self.inner.shutdown_with_epitaph(status)
8907    }
8908
8909    fn is_closed(&self) -> bool {
8910        self.inner.channel().is_closed()
8911    }
8912    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8913        self.inner.channel().on_closed()
8914    }
8915
8916    #[cfg(target_os = "fuchsia")]
8917    fn signal_peer(
8918        &self,
8919        clear_mask: zx::Signals,
8920        set_mask: zx::Signals,
8921    ) -> Result<(), zx_status::Status> {
8922        use fidl::Peered;
8923        self.inner.channel().signal_peer(clear_mask, set_mask)
8924    }
8925}
8926
8927impl PeripheralControlHandle {
8928    pub fn send_on_peer_connected(
8929        &self,
8930        mut peer: &Peer,
8931        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
8932    ) -> Result<(), fidl::Error> {
8933        self.inner.send::<PeripheralOnPeerConnectedRequest>(
8934            (peer, connection),
8935            0,
8936            0x16135d464299e356,
8937            fidl::encoding::DynamicFlags::empty(),
8938        )
8939    }
8940}
8941
8942#[must_use = "FIDL methods require a response to be sent"]
8943#[derive(Debug)]
8944pub struct PeripheralListenL2capResponder {
8945    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
8946    tx_id: u32,
8947}
8948
8949/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
8950/// if the responder is dropped without sending a response, so that the client
8951/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8952impl std::ops::Drop for PeripheralListenL2capResponder {
8953    fn drop(&mut self) {
8954        self.control_handle.shutdown();
8955        // Safety: drops once, never accessed again
8956        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8957    }
8958}
8959
8960impl fidl::endpoints::Responder for PeripheralListenL2capResponder {
8961    type ControlHandle = PeripheralControlHandle;
8962
8963    fn control_handle(&self) -> &PeripheralControlHandle {
8964        &self.control_handle
8965    }
8966
8967    fn drop_without_shutdown(mut self) {
8968        // Safety: drops once, never accessed again due to mem::forget
8969        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8970        // Prevent Drop from running (which would shut down the channel)
8971        std::mem::forget(self);
8972    }
8973}
8974
8975impl PeripheralListenL2capResponder {
8976    /// Sends a response to the FIDL transaction.
8977    ///
8978    /// Sets the channel to shutdown if an error occurs.
8979    pub fn send(
8980        self,
8981        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
8982    ) -> Result<(), fidl::Error> {
8983        let _result = self.send_raw(result);
8984        if _result.is_err() {
8985            self.control_handle.shutdown();
8986        }
8987        self.drop_without_shutdown();
8988        _result
8989    }
8990
8991    /// Similar to "send" but does not shutdown the channel if an error occurs.
8992    pub fn send_no_shutdown_on_err(
8993        self,
8994        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
8995    ) -> Result<(), fidl::Error> {
8996        let _result = self.send_raw(result);
8997        self.drop_without_shutdown();
8998        _result
8999    }
9000
9001    fn send_raw(
9002        &self,
9003        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
9004    ) -> Result<(), fidl::Error> {
9005        self.control_handle.inner.send::<fidl::encoding::ResultType<
9006            ChannelListenerRegistryListenL2capResponse,
9007            i32,
9008        >>(
9009            result,
9010            self.tx_id,
9011            0x39c6e9001d102338,
9012            fidl::encoding::DynamicFlags::empty(),
9013        )
9014    }
9015}
9016
9017#[must_use = "FIDL methods require a response to be sent"]
9018#[derive(Debug)]
9019pub struct PeripheralAdvertiseResponder {
9020    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
9021    tx_id: u32,
9022}
9023
9024/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
9025/// if the responder is dropped without sending a response, so that the client
9026/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9027impl std::ops::Drop for PeripheralAdvertiseResponder {
9028    fn drop(&mut self) {
9029        self.control_handle.shutdown();
9030        // Safety: drops once, never accessed again
9031        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9032    }
9033}
9034
9035impl fidl::endpoints::Responder for PeripheralAdvertiseResponder {
9036    type ControlHandle = PeripheralControlHandle;
9037
9038    fn control_handle(&self) -> &PeripheralControlHandle {
9039        &self.control_handle
9040    }
9041
9042    fn drop_without_shutdown(mut self) {
9043        // Safety: drops once, never accessed again due to mem::forget
9044        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9045        // Prevent Drop from running (which would shut down the channel)
9046        std::mem::forget(self);
9047    }
9048}
9049
9050impl PeripheralAdvertiseResponder {
9051    /// Sends a response to the FIDL transaction.
9052    ///
9053    /// Sets the channel to shutdown if an error occurs.
9054    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9055        let _result = self.send_raw(result);
9056        if _result.is_err() {
9057            self.control_handle.shutdown();
9058        }
9059        self.drop_without_shutdown();
9060        _result
9061    }
9062
9063    /// Similar to "send" but does not shutdown the channel if an error occurs.
9064    pub fn send_no_shutdown_on_err(
9065        self,
9066        mut result: Result<(), PeripheralError>,
9067    ) -> Result<(), fidl::Error> {
9068        let _result = self.send_raw(result);
9069        self.drop_without_shutdown();
9070        _result
9071    }
9072
9073    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9074        self.control_handle.inner.send::<fidl::encoding::ResultType<
9075            fidl::encoding::EmptyStruct,
9076            PeripheralError,
9077        >>(
9078            result,
9079            self.tx_id,
9080            0x2d9ec9260c32c17f,
9081            fidl::encoding::DynamicFlags::empty(),
9082        )
9083    }
9084}
9085
9086#[must_use = "FIDL methods require a response to be sent"]
9087#[derive(Debug)]
9088pub struct PeripheralStartAdvertisingResponder {
9089    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
9090    tx_id: u32,
9091}
9092
9093/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
9094/// if the responder is dropped without sending a response, so that the client
9095/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9096impl std::ops::Drop for PeripheralStartAdvertisingResponder {
9097    fn drop(&mut self) {
9098        self.control_handle.shutdown();
9099        // Safety: drops once, never accessed again
9100        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9101    }
9102}
9103
9104impl fidl::endpoints::Responder for PeripheralStartAdvertisingResponder {
9105    type ControlHandle = PeripheralControlHandle;
9106
9107    fn control_handle(&self) -> &PeripheralControlHandle {
9108        &self.control_handle
9109    }
9110
9111    fn drop_without_shutdown(mut self) {
9112        // Safety: drops once, never accessed again due to mem::forget
9113        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9114        // Prevent Drop from running (which would shut down the channel)
9115        std::mem::forget(self);
9116    }
9117}
9118
9119impl PeripheralStartAdvertisingResponder {
9120    /// Sends a response to the FIDL transaction.
9121    ///
9122    /// Sets the channel to shutdown if an error occurs.
9123    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9124        let _result = self.send_raw(result);
9125        if _result.is_err() {
9126            self.control_handle.shutdown();
9127        }
9128        self.drop_without_shutdown();
9129        _result
9130    }
9131
9132    /// Similar to "send" but does not shutdown the channel if an error occurs.
9133    pub fn send_no_shutdown_on_err(
9134        self,
9135        mut result: Result<(), PeripheralError>,
9136    ) -> Result<(), fidl::Error> {
9137        let _result = self.send_raw(result);
9138        self.drop_without_shutdown();
9139        _result
9140    }
9141
9142    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9143        self.control_handle.inner.send::<fidl::encoding::ResultType<
9144            fidl::encoding::EmptyStruct,
9145            PeripheralError,
9146        >>(
9147            result,
9148            self.tx_id,
9149            0x5875c1c575f00f7d,
9150            fidl::encoding::DynamicFlags::empty(),
9151        )
9152    }
9153}
9154
9155#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9156pub struct PrivilegedPeripheralMarker;
9157
9158impl fidl::endpoints::ProtocolMarker for PrivilegedPeripheralMarker {
9159    type Proxy = PrivilegedPeripheralProxy;
9160    type RequestStream = PrivilegedPeripheralRequestStream;
9161    #[cfg(target_os = "fuchsia")]
9162    type SynchronousProxy = PrivilegedPeripheralSynchronousProxy;
9163
9164    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.PrivilegedPeripheral";
9165}
9166impl fidl::endpoints::DiscoverableProtocolMarker for PrivilegedPeripheralMarker {}
9167
9168pub trait PrivilegedPeripheralProxyInterface: Send + Sync {
9169    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
9170        + Send;
9171    fn r#listen_l2cap(
9172        &self,
9173        payload: ChannelListenerRegistryListenL2capRequest,
9174    ) -> Self::ListenL2capResponseFut;
9175    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralAdvertiseResult, fidl::Error>>
9176        + Send;
9177    fn r#advertise(
9178        &self,
9179        parameters: &AdvertisingParameters,
9180        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9181    ) -> Self::AdvertiseResponseFut;
9182    type StartAdvertisingResponseFut: std::future::Future<Output = Result<PeripheralStartAdvertisingResult, fidl::Error>>
9183        + Send;
9184    fn r#start_advertising(
9185        &self,
9186        parameters: &AdvertisingParameters,
9187        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9188    ) -> Self::StartAdvertisingResponseFut;
9189}
9190#[derive(Debug)]
9191#[cfg(target_os = "fuchsia")]
9192pub struct PrivilegedPeripheralSynchronousProxy {
9193    client: fidl::client::sync::Client,
9194}
9195
9196#[cfg(target_os = "fuchsia")]
9197impl fidl::endpoints::SynchronousProxy for PrivilegedPeripheralSynchronousProxy {
9198    type Proxy = PrivilegedPeripheralProxy;
9199    type Protocol = PrivilegedPeripheralMarker;
9200
9201    fn from_channel(inner: fidl::Channel) -> Self {
9202        Self::new(inner)
9203    }
9204
9205    fn into_channel(self) -> fidl::Channel {
9206        self.client.into_channel()
9207    }
9208
9209    fn as_channel(&self) -> &fidl::Channel {
9210        self.client.as_channel()
9211    }
9212}
9213
9214#[cfg(target_os = "fuchsia")]
9215impl PrivilegedPeripheralSynchronousProxy {
9216    pub fn new(channel: fidl::Channel) -> Self {
9217        let protocol_name =
9218            <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9219        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
9220    }
9221
9222    pub fn into_channel(self) -> fidl::Channel {
9223        self.client.into_channel()
9224    }
9225
9226    /// Waits until an event arrives and returns it. It is safe for other
9227    /// threads to make concurrent requests while waiting for an event.
9228    pub fn wait_for_event(
9229        &self,
9230        deadline: zx::MonotonicInstant,
9231    ) -> Result<PrivilegedPeripheralEvent, fidl::Error> {
9232        PrivilegedPeripheralEvent::decode(self.client.wait_for_event(deadline)?)
9233    }
9234
9235    /// Register a listener for incoming channels. The registry will assign a
9236    /// PSM value that is unique for the local device, as well as open a
9237    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
9238    /// event that all PSMs have been assigned, this call will fail with
9239    /// `ZX_ERR_NO_RESOURCES`.
9240    ///
9241    /// Note that the method of service discovery or advertising is defined by
9242    /// the service or protocol, so it is the responsibility of the caller to
9243    /// communicate the assigned PSM to any clients.
9244    pub fn r#listen_l2cap(
9245        &self,
9246        mut payload: ChannelListenerRegistryListenL2capRequest,
9247        ___deadline: zx::MonotonicInstant,
9248    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
9249        let _response = self.client.send_query::<
9250            ChannelListenerRegistryListenL2capRequest,
9251            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
9252        >(
9253            &mut payload,
9254            0x39c6e9001d102338,
9255            fidl::encoding::DynamicFlags::empty(),
9256            ___deadline,
9257        )?;
9258        Ok(_response.map(|x| x))
9259    }
9260
9261    /// Start advertising continuously as a LE peripheral. If advertising cannot
9262    /// be initiated then `advertised_peripheral` will be closed and an error
9263    /// will be returned.
9264    ///
9265    /// This method may be called any number of times. To reconfigure an
9266    /// advertisement, first close the original advertisement and then initiate
9267    /// a new advertisement after an empty response is returned.
9268    ///
9269    /// If the client closes its end of the
9270    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9271    /// advertising will be stopped. If the handle is closed before the request
9272    /// is fulfilled, advertising may be briefly enabled before it is
9273    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9274    /// the Peripheral protocol, but this may be changed in the future
9275    /// (https://fxbug.dev/42157682).
9276    ///
9277    /// + request `parameters` Parameters used while configuring the advertising
9278    ///   instance.
9279    /// + request `advertised_peripheral` Protocol that remains valid for the
9280    ///   duration of this advertising session.
9281    /// - response An empty response will be sent when the advertisement is
9282    ///   successfully stopped (due to release of the `advertised_peripheral`
9283    ///   protocol). To prevent overlapping similar advertisements and transient
9284    ///   errors with limited advertising resources, waiting for a response is
9285    ///   recommended before calling `Advertise` again.
9286    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9287    ///   `PeripheralError` will be returned.
9288    pub fn r#advertise(
9289        &self,
9290        mut parameters: &AdvertisingParameters,
9291        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9292        ___deadline: zx::MonotonicInstant,
9293    ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
9294        let _response = self.client.send_query::<
9295            PeripheralAdvertiseRequest,
9296            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9297        >(
9298            (parameters, advertised_peripheral,),
9299            0x2d9ec9260c32c17f,
9300            fidl::encoding::DynamicFlags::empty(),
9301            ___deadline,
9302        )?;
9303        Ok(_response.map(|x| x))
9304    }
9305
9306    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9307    /// has successfully initiated. If advertising cannot be initiated, then the response will
9308    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9309    ///
9310    /// This method can get called any number of times and successive calls can be made to
9311    /// reconfigure the advertising parameters. However only the most recent
9312    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9313    ///
9314    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9315    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9316    /// advertisements.
9317    ///
9318    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9319    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9320    /// advertising will be briefly enabled before it is terminated.
9321    ///
9322    /// + request `parameters` Parameters used while configuring the advertising instance.
9323    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9324    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9325    ///         initiated. In this case the `handle` will be closed.
9326    pub fn r#start_advertising(
9327        &self,
9328        mut parameters: &AdvertisingParameters,
9329        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9330        ___deadline: zx::MonotonicInstant,
9331    ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
9332        let _response = self.client.send_query::<
9333            PeripheralStartAdvertisingRequest,
9334            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9335        >(
9336            (parameters, handle,),
9337            0x5875c1c575f00f7d,
9338            fidl::encoding::DynamicFlags::empty(),
9339            ___deadline,
9340        )?;
9341        Ok(_response.map(|x| x))
9342    }
9343}
9344
9345#[cfg(target_os = "fuchsia")]
9346impl From<PrivilegedPeripheralSynchronousProxy> for zx::Handle {
9347    fn from(value: PrivilegedPeripheralSynchronousProxy) -> Self {
9348        value.into_channel().into()
9349    }
9350}
9351
9352#[cfg(target_os = "fuchsia")]
9353impl From<fidl::Channel> for PrivilegedPeripheralSynchronousProxy {
9354    fn from(value: fidl::Channel) -> Self {
9355        Self::new(value)
9356    }
9357}
9358
9359#[cfg(target_os = "fuchsia")]
9360impl fidl::endpoints::FromClient for PrivilegedPeripheralSynchronousProxy {
9361    type Protocol = PrivilegedPeripheralMarker;
9362
9363    fn from_client(value: fidl::endpoints::ClientEnd<PrivilegedPeripheralMarker>) -> Self {
9364        Self::new(value.into_channel())
9365    }
9366}
9367
9368#[derive(Debug, Clone)]
9369pub struct PrivilegedPeripheralProxy {
9370    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
9371}
9372
9373impl fidl::endpoints::Proxy for PrivilegedPeripheralProxy {
9374    type Protocol = PrivilegedPeripheralMarker;
9375
9376    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
9377        Self::new(inner)
9378    }
9379
9380    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
9381        self.client.into_channel().map_err(|client| Self { client })
9382    }
9383
9384    fn as_channel(&self) -> &::fidl::AsyncChannel {
9385        self.client.as_channel()
9386    }
9387}
9388
9389impl PrivilegedPeripheralProxy {
9390    /// Create a new Proxy for fuchsia.bluetooth.le/PrivilegedPeripheral.
9391    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
9392        let protocol_name =
9393            <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9394        Self { client: fidl::client::Client::new(channel, protocol_name) }
9395    }
9396
9397    /// Get a Stream of events from the remote end of the protocol.
9398    ///
9399    /// # Panics
9400    ///
9401    /// Panics if the event stream was already taken.
9402    pub fn take_event_stream(&self) -> PrivilegedPeripheralEventStream {
9403        PrivilegedPeripheralEventStream { event_receiver: self.client.take_event_receiver() }
9404    }
9405
9406    /// Register a listener for incoming channels. The registry will assign a
9407    /// PSM value that is unique for the local device, as well as open a
9408    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
9409    /// event that all PSMs have been assigned, this call will fail with
9410    /// `ZX_ERR_NO_RESOURCES`.
9411    ///
9412    /// Note that the method of service discovery or advertising is defined by
9413    /// the service or protocol, so it is the responsibility of the caller to
9414    /// communicate the assigned PSM to any clients.
9415    pub fn r#listen_l2cap(
9416        &self,
9417        mut payload: ChannelListenerRegistryListenL2capRequest,
9418    ) -> fidl::client::QueryResponseFut<
9419        ChannelListenerRegistryListenL2capResult,
9420        fidl::encoding::DefaultFuchsiaResourceDialect,
9421    > {
9422        PrivilegedPeripheralProxyInterface::r#listen_l2cap(self, payload)
9423    }
9424
9425    /// Start advertising continuously as a LE peripheral. If advertising cannot
9426    /// be initiated then `advertised_peripheral` will be closed and an error
9427    /// will be returned.
9428    ///
9429    /// This method may be called any number of times. To reconfigure an
9430    /// advertisement, first close the original advertisement and then initiate
9431    /// a new advertisement after an empty response is returned.
9432    ///
9433    /// If the client closes its end of the
9434    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9435    /// advertising will be stopped. If the handle is closed before the request
9436    /// is fulfilled, advertising may be briefly enabled before it is
9437    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9438    /// the Peripheral protocol, but this may be changed in the future
9439    /// (https://fxbug.dev/42157682).
9440    ///
9441    /// + request `parameters` Parameters used while configuring the advertising
9442    ///   instance.
9443    /// + request `advertised_peripheral` Protocol that remains valid for the
9444    ///   duration of this advertising session.
9445    /// - response An empty response will be sent when the advertisement is
9446    ///   successfully stopped (due to release of the `advertised_peripheral`
9447    ///   protocol). To prevent overlapping similar advertisements and transient
9448    ///   errors with limited advertising resources, waiting for a response is
9449    ///   recommended before calling `Advertise` again.
9450    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9451    ///   `PeripheralError` will be returned.
9452    pub fn r#advertise(
9453        &self,
9454        mut parameters: &AdvertisingParameters,
9455        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9456    ) -> fidl::client::QueryResponseFut<
9457        PeripheralAdvertiseResult,
9458        fidl::encoding::DefaultFuchsiaResourceDialect,
9459    > {
9460        PrivilegedPeripheralProxyInterface::r#advertise(self, parameters, advertised_peripheral)
9461    }
9462
9463    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9464    /// has successfully initiated. If advertising cannot be initiated, then the response will
9465    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9466    ///
9467    /// This method can get called any number of times and successive calls can be made to
9468    /// reconfigure the advertising parameters. However only the most recent
9469    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9470    ///
9471    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9472    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9473    /// advertisements.
9474    ///
9475    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9476    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9477    /// advertising will be briefly enabled before it is terminated.
9478    ///
9479    /// + request `parameters` Parameters used while configuring the advertising instance.
9480    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9481    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9482    ///         initiated. In this case the `handle` will be closed.
9483    pub fn r#start_advertising(
9484        &self,
9485        mut parameters: &AdvertisingParameters,
9486        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9487    ) -> fidl::client::QueryResponseFut<
9488        PeripheralStartAdvertisingResult,
9489        fidl::encoding::DefaultFuchsiaResourceDialect,
9490    > {
9491        PrivilegedPeripheralProxyInterface::r#start_advertising(self, parameters, handle)
9492    }
9493}
9494
9495impl PrivilegedPeripheralProxyInterface for PrivilegedPeripheralProxy {
9496    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
9497        ChannelListenerRegistryListenL2capResult,
9498        fidl::encoding::DefaultFuchsiaResourceDialect,
9499    >;
9500    fn r#listen_l2cap(
9501        &self,
9502        mut payload: ChannelListenerRegistryListenL2capRequest,
9503    ) -> Self::ListenL2capResponseFut {
9504        fn _decode(
9505            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9506        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
9507            let _response = fidl::client::decode_transaction_body::<
9508                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
9509                fidl::encoding::DefaultFuchsiaResourceDialect,
9510                0x39c6e9001d102338,
9511            >(_buf?)?;
9512            Ok(_response.map(|x| x))
9513        }
9514        self.client.send_query_and_decode::<
9515            ChannelListenerRegistryListenL2capRequest,
9516            ChannelListenerRegistryListenL2capResult,
9517        >(
9518            &mut payload,
9519            0x39c6e9001d102338,
9520            fidl::encoding::DynamicFlags::empty(),
9521            _decode,
9522        )
9523    }
9524
9525    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
9526        PeripheralAdvertiseResult,
9527        fidl::encoding::DefaultFuchsiaResourceDialect,
9528    >;
9529    fn r#advertise(
9530        &self,
9531        mut parameters: &AdvertisingParameters,
9532        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9533    ) -> Self::AdvertiseResponseFut {
9534        fn _decode(
9535            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9536        ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
9537            let _response = fidl::client::decode_transaction_body::<
9538                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9539                fidl::encoding::DefaultFuchsiaResourceDialect,
9540                0x2d9ec9260c32c17f,
9541            >(_buf?)?;
9542            Ok(_response.map(|x| x))
9543        }
9544        self.client.send_query_and_decode::<PeripheralAdvertiseRequest, PeripheralAdvertiseResult>(
9545            (parameters, advertised_peripheral),
9546            0x2d9ec9260c32c17f,
9547            fidl::encoding::DynamicFlags::empty(),
9548            _decode,
9549        )
9550    }
9551
9552    type StartAdvertisingResponseFut = fidl::client::QueryResponseFut<
9553        PeripheralStartAdvertisingResult,
9554        fidl::encoding::DefaultFuchsiaResourceDialect,
9555    >;
9556    fn r#start_advertising(
9557        &self,
9558        mut parameters: &AdvertisingParameters,
9559        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9560    ) -> Self::StartAdvertisingResponseFut {
9561        fn _decode(
9562            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9563        ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
9564            let _response = fidl::client::decode_transaction_body::<
9565                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9566                fidl::encoding::DefaultFuchsiaResourceDialect,
9567                0x5875c1c575f00f7d,
9568            >(_buf?)?;
9569            Ok(_response.map(|x| x))
9570        }
9571        self.client.send_query_and_decode::<
9572            PeripheralStartAdvertisingRequest,
9573            PeripheralStartAdvertisingResult,
9574        >(
9575            (parameters, handle,),
9576            0x5875c1c575f00f7d,
9577            fidl::encoding::DynamicFlags::empty(),
9578            _decode,
9579        )
9580    }
9581}
9582
9583pub struct PrivilegedPeripheralEventStream {
9584    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9585}
9586
9587impl std::marker::Unpin for PrivilegedPeripheralEventStream {}
9588
9589impl futures::stream::FusedStream for PrivilegedPeripheralEventStream {
9590    fn is_terminated(&self) -> bool {
9591        self.event_receiver.is_terminated()
9592    }
9593}
9594
9595impl futures::Stream for PrivilegedPeripheralEventStream {
9596    type Item = Result<PrivilegedPeripheralEvent, fidl::Error>;
9597
9598    fn poll_next(
9599        mut self: std::pin::Pin<&mut Self>,
9600        cx: &mut std::task::Context<'_>,
9601    ) -> std::task::Poll<Option<Self::Item>> {
9602        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9603            &mut self.event_receiver,
9604            cx
9605        )?) {
9606            Some(buf) => std::task::Poll::Ready(Some(PrivilegedPeripheralEvent::decode(buf))),
9607            None => std::task::Poll::Ready(None),
9608        }
9609    }
9610}
9611
9612#[derive(Debug)]
9613pub enum PrivilegedPeripheralEvent {
9614    OnPeerConnected { peer: Peer, connection: fidl::endpoints::ClientEnd<ConnectionMarker> },
9615}
9616
9617impl PrivilegedPeripheralEvent {
9618    #[allow(irrefutable_let_patterns)]
9619    pub fn into_on_peer_connected(
9620        self,
9621    ) -> Option<(Peer, fidl::endpoints::ClientEnd<ConnectionMarker>)> {
9622        if let PrivilegedPeripheralEvent::OnPeerConnected { peer, connection } = self {
9623            Some((peer, connection))
9624        } else {
9625            None
9626        }
9627    }
9628
9629    /// Decodes a message buffer as a [`PrivilegedPeripheralEvent`].
9630    fn decode(
9631        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9632    ) -> Result<PrivilegedPeripheralEvent, fidl::Error> {
9633        let (bytes, _handles) = buf.split_mut();
9634        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9635        debug_assert_eq!(tx_header.tx_id, 0);
9636        match tx_header.ordinal {
9637            0x16135d464299e356 => {
9638                let mut out = fidl::new_empty!(
9639                    PeripheralOnPeerConnectedRequest,
9640                    fidl::encoding::DefaultFuchsiaResourceDialect
9641                );
9642                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralOnPeerConnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
9643                Ok((PrivilegedPeripheralEvent::OnPeerConnected {
9644                    peer: out.peer,
9645                    connection: out.connection,
9646                }))
9647            }
9648            _ => Err(fidl::Error::UnknownOrdinal {
9649                ordinal: tx_header.ordinal,
9650                protocol_name:
9651                    <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9652            }),
9653        }
9654    }
9655}
9656
9657/// A Stream of incoming requests for fuchsia.bluetooth.le/PrivilegedPeripheral.
9658pub struct PrivilegedPeripheralRequestStream {
9659    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9660    is_terminated: bool,
9661}
9662
9663impl std::marker::Unpin for PrivilegedPeripheralRequestStream {}
9664
9665impl futures::stream::FusedStream for PrivilegedPeripheralRequestStream {
9666    fn is_terminated(&self) -> bool {
9667        self.is_terminated
9668    }
9669}
9670
9671impl fidl::endpoints::RequestStream for PrivilegedPeripheralRequestStream {
9672    type Protocol = PrivilegedPeripheralMarker;
9673    type ControlHandle = PrivilegedPeripheralControlHandle;
9674
9675    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9676        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9677    }
9678
9679    fn control_handle(&self) -> Self::ControlHandle {
9680        PrivilegedPeripheralControlHandle { inner: self.inner.clone() }
9681    }
9682
9683    fn into_inner(
9684        self,
9685    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9686    {
9687        (self.inner, self.is_terminated)
9688    }
9689
9690    fn from_inner(
9691        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9692        is_terminated: bool,
9693    ) -> Self {
9694        Self { inner, is_terminated }
9695    }
9696}
9697
9698impl futures::Stream for PrivilegedPeripheralRequestStream {
9699    type Item = Result<PrivilegedPeripheralRequest, fidl::Error>;
9700
9701    fn poll_next(
9702        mut self: std::pin::Pin<&mut Self>,
9703        cx: &mut std::task::Context<'_>,
9704    ) -> std::task::Poll<Option<Self::Item>> {
9705        let this = &mut *self;
9706        if this.inner.check_shutdown(cx) {
9707            this.is_terminated = true;
9708            return std::task::Poll::Ready(None);
9709        }
9710        if this.is_terminated {
9711            panic!("polled PrivilegedPeripheralRequestStream after completion");
9712        }
9713        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9714            |bytes, handles| {
9715                match this.inner.channel().read_etc(cx, bytes, handles) {
9716                    std::task::Poll::Ready(Ok(())) => {}
9717                    std::task::Poll::Pending => return std::task::Poll::Pending,
9718                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9719                        this.is_terminated = true;
9720                        return std::task::Poll::Ready(None);
9721                    }
9722                    std::task::Poll::Ready(Err(e)) => {
9723                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9724                            e.into(),
9725                        ))));
9726                    }
9727                }
9728
9729                // A message has been received from the channel
9730                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9731
9732                std::task::Poll::Ready(Some(match header.ordinal {
9733                0x39c6e9001d102338 => {
9734                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9735                    let mut req = fidl::new_empty!(ChannelListenerRegistryListenL2capRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
9736                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
9737                    let control_handle = PrivilegedPeripheralControlHandle {
9738                        inner: this.inner.clone(),
9739                    };
9740                    Ok(PrivilegedPeripheralRequest::ListenL2cap {payload: req,
9741                        responder: PrivilegedPeripheralListenL2capResponder {
9742                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9743                            tx_id: header.tx_id,
9744                        },
9745                    })
9746                }
9747                0x2d9ec9260c32c17f => {
9748                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9749                    let mut req = fidl::new_empty!(PeripheralAdvertiseRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
9750                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
9751                    let control_handle = PrivilegedPeripheralControlHandle {
9752                        inner: this.inner.clone(),
9753                    };
9754                    Ok(PrivilegedPeripheralRequest::Advertise {parameters: req.parameters,
9755advertised_peripheral: req.advertised_peripheral,
9756
9757                        responder: PrivilegedPeripheralAdvertiseResponder {
9758                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9759                            tx_id: header.tx_id,
9760                        },
9761                    })
9762                }
9763                0x5875c1c575f00f7d => {
9764                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9765                    let mut req = fidl::new_empty!(PeripheralStartAdvertisingRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
9766                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralStartAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
9767                    let control_handle = PrivilegedPeripheralControlHandle {
9768                        inner: this.inner.clone(),
9769                    };
9770                    Ok(PrivilegedPeripheralRequest::StartAdvertising {parameters: req.parameters,
9771handle: req.handle,
9772
9773                        responder: PrivilegedPeripheralStartAdvertisingResponder {
9774                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9775                            tx_id: header.tx_id,
9776                        },
9777                    })
9778                }
9779                _ => Err(fidl::Error::UnknownOrdinal {
9780                    ordinal: header.ordinal,
9781                    protocol_name: <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9782                }),
9783            }))
9784            },
9785        )
9786    }
9787}
9788
9789/// Privileged version of the Peripheral protocol.
9790/// This protocol should only be routed to trusted and system components. Using this protocol will
9791/// enable the client to break normal privacy restrictions which could leak information about the
9792/// location or owner of the device.
9793///
9794/// Use cases which reveal information are noted in documentation and marked as only available
9795/// through PrivilegedPeripheral, and are an error if used through Peripheral.
9796#[derive(Debug)]
9797pub enum PrivilegedPeripheralRequest {
9798    /// Register a listener for incoming channels. The registry will assign a
9799    /// PSM value that is unique for the local device, as well as open a
9800    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
9801    /// event that all PSMs have been assigned, this call will fail with
9802    /// `ZX_ERR_NO_RESOURCES`.
9803    ///
9804    /// Note that the method of service discovery or advertising is defined by
9805    /// the service or protocol, so it is the responsibility of the caller to
9806    /// communicate the assigned PSM to any clients.
9807    ListenL2cap {
9808        payload: ChannelListenerRegistryListenL2capRequest,
9809        responder: PrivilegedPeripheralListenL2capResponder,
9810    },
9811    /// Start advertising continuously as a LE peripheral. If advertising cannot
9812    /// be initiated then `advertised_peripheral` will be closed and an error
9813    /// will be returned.
9814    ///
9815    /// This method may be called any number of times. To reconfigure an
9816    /// advertisement, first close the original advertisement and then initiate
9817    /// a new advertisement after an empty response is returned.
9818    ///
9819    /// If the client closes its end of the
9820    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9821    /// advertising will be stopped. If the handle is closed before the request
9822    /// is fulfilled, advertising may be briefly enabled before it is
9823    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9824    /// the Peripheral protocol, but this may be changed in the future
9825    /// (https://fxbug.dev/42157682).
9826    ///
9827    /// + request `parameters` Parameters used while configuring the advertising
9828    ///   instance.
9829    /// + request `advertised_peripheral` Protocol that remains valid for the
9830    ///   duration of this advertising session.
9831    /// - response An empty response will be sent when the advertisement is
9832    ///   successfully stopped (due to release of the `advertised_peripheral`
9833    ///   protocol). To prevent overlapping similar advertisements and transient
9834    ///   errors with limited advertising resources, waiting for a response is
9835    ///   recommended before calling `Advertise` again.
9836    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9837    ///   `PeripheralError` will be returned.
9838    Advertise {
9839        parameters: AdvertisingParameters,
9840        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9841        responder: PrivilegedPeripheralAdvertiseResponder,
9842    },
9843    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9844    /// has successfully initiated. If advertising cannot be initiated, then the response will
9845    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9846    ///
9847    /// This method can get called any number of times and successive calls can be made to
9848    /// reconfigure the advertising parameters. However only the most recent
9849    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9850    ///
9851    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9852    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9853    /// advertisements.
9854    ///
9855    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9856    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9857    /// advertising will be briefly enabled before it is terminated.
9858    ///
9859    /// + request `parameters` Parameters used while configuring the advertising instance.
9860    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9861    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9862    ///         initiated. In this case the `handle` will be closed.
9863    StartAdvertising {
9864        parameters: AdvertisingParameters,
9865        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9866        responder: PrivilegedPeripheralStartAdvertisingResponder,
9867    },
9868}
9869
9870impl PrivilegedPeripheralRequest {
9871    #[allow(irrefutable_let_patterns)]
9872    pub fn into_listen_l2cap(
9873        self,
9874    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PrivilegedPeripheralListenL2capResponder)>
9875    {
9876        if let PrivilegedPeripheralRequest::ListenL2cap { payload, responder } = self {
9877            Some((payload, responder))
9878        } else {
9879            None
9880        }
9881    }
9882
9883    #[allow(irrefutable_let_patterns)]
9884    pub fn into_advertise(
9885        self,
9886    ) -> Option<(
9887        AdvertisingParameters,
9888        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9889        PrivilegedPeripheralAdvertiseResponder,
9890    )> {
9891        if let PrivilegedPeripheralRequest::Advertise {
9892            parameters,
9893            advertised_peripheral,
9894            responder,
9895        } = self
9896        {
9897            Some((parameters, advertised_peripheral, responder))
9898        } else {
9899            None
9900        }
9901    }
9902
9903    #[allow(irrefutable_let_patterns)]
9904    pub fn into_start_advertising(
9905        self,
9906    ) -> Option<(
9907        AdvertisingParameters,
9908        fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9909        PrivilegedPeripheralStartAdvertisingResponder,
9910    )> {
9911        if let PrivilegedPeripheralRequest::StartAdvertising { parameters, handle, responder } =
9912            self
9913        {
9914            Some((parameters, handle, responder))
9915        } else {
9916            None
9917        }
9918    }
9919
9920    /// Name of the method defined in FIDL
9921    pub fn method_name(&self) -> &'static str {
9922        match *self {
9923            PrivilegedPeripheralRequest::ListenL2cap { .. } => "listen_l2cap",
9924            PrivilegedPeripheralRequest::Advertise { .. } => "advertise",
9925            PrivilegedPeripheralRequest::StartAdvertising { .. } => "start_advertising",
9926        }
9927    }
9928}
9929
9930#[derive(Debug, Clone)]
9931pub struct PrivilegedPeripheralControlHandle {
9932    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9933}
9934
9935impl fidl::endpoints::ControlHandle for PrivilegedPeripheralControlHandle {
9936    fn shutdown(&self) {
9937        self.inner.shutdown()
9938    }
9939    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9940        self.inner.shutdown_with_epitaph(status)
9941    }
9942
9943    fn is_closed(&self) -> bool {
9944        self.inner.channel().is_closed()
9945    }
9946    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
9947        self.inner.channel().on_closed()
9948    }
9949
9950    #[cfg(target_os = "fuchsia")]
9951    fn signal_peer(
9952        &self,
9953        clear_mask: zx::Signals,
9954        set_mask: zx::Signals,
9955    ) -> Result<(), zx_status::Status> {
9956        use fidl::Peered;
9957        self.inner.channel().signal_peer(clear_mask, set_mask)
9958    }
9959}
9960
9961impl PrivilegedPeripheralControlHandle {
9962    pub fn send_on_peer_connected(
9963        &self,
9964        mut peer: &Peer,
9965        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
9966    ) -> Result<(), fidl::Error> {
9967        self.inner.send::<PeripheralOnPeerConnectedRequest>(
9968            (peer, connection),
9969            0,
9970            0x16135d464299e356,
9971            fidl::encoding::DynamicFlags::empty(),
9972        )
9973    }
9974}
9975
9976#[must_use = "FIDL methods require a response to be sent"]
9977#[derive(Debug)]
9978pub struct PrivilegedPeripheralListenL2capResponder {
9979    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
9980    tx_id: u32,
9981}
9982
9983/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
9984/// if the responder is dropped without sending a response, so that the client
9985/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9986impl std::ops::Drop for PrivilegedPeripheralListenL2capResponder {
9987    fn drop(&mut self) {
9988        self.control_handle.shutdown();
9989        // Safety: drops once, never accessed again
9990        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9991    }
9992}
9993
9994impl fidl::endpoints::Responder for PrivilegedPeripheralListenL2capResponder {
9995    type ControlHandle = PrivilegedPeripheralControlHandle;
9996
9997    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
9998        &self.control_handle
9999    }
10000
10001    fn drop_without_shutdown(mut self) {
10002        // Safety: drops once, never accessed again due to mem::forget
10003        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10004        // Prevent Drop from running (which would shut down the channel)
10005        std::mem::forget(self);
10006    }
10007}
10008
10009impl PrivilegedPeripheralListenL2capResponder {
10010    /// Sends a response to the FIDL transaction.
10011    ///
10012    /// Sets the channel to shutdown if an error occurs.
10013    pub fn send(
10014        self,
10015        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
10016    ) -> Result<(), fidl::Error> {
10017        let _result = self.send_raw(result);
10018        if _result.is_err() {
10019            self.control_handle.shutdown();
10020        }
10021        self.drop_without_shutdown();
10022        _result
10023    }
10024
10025    /// Similar to "send" but does not shutdown the channel if an error occurs.
10026    pub fn send_no_shutdown_on_err(
10027        self,
10028        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
10029    ) -> Result<(), fidl::Error> {
10030        let _result = self.send_raw(result);
10031        self.drop_without_shutdown();
10032        _result
10033    }
10034
10035    fn send_raw(
10036        &self,
10037        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
10038    ) -> Result<(), fidl::Error> {
10039        self.control_handle.inner.send::<fidl::encoding::ResultType<
10040            ChannelListenerRegistryListenL2capResponse,
10041            i32,
10042        >>(
10043            result,
10044            self.tx_id,
10045            0x39c6e9001d102338,
10046            fidl::encoding::DynamicFlags::empty(),
10047        )
10048    }
10049}
10050
10051#[must_use = "FIDL methods require a response to be sent"]
10052#[derive(Debug)]
10053pub struct PrivilegedPeripheralAdvertiseResponder {
10054    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
10055    tx_id: u32,
10056}
10057
10058/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
10059/// if the responder is dropped without sending a response, so that the client
10060/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10061impl std::ops::Drop for PrivilegedPeripheralAdvertiseResponder {
10062    fn drop(&mut self) {
10063        self.control_handle.shutdown();
10064        // Safety: drops once, never accessed again
10065        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10066    }
10067}
10068
10069impl fidl::endpoints::Responder for PrivilegedPeripheralAdvertiseResponder {
10070    type ControlHandle = PrivilegedPeripheralControlHandle;
10071
10072    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
10073        &self.control_handle
10074    }
10075
10076    fn drop_without_shutdown(mut self) {
10077        // Safety: drops once, never accessed again due to mem::forget
10078        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10079        // Prevent Drop from running (which would shut down the channel)
10080        std::mem::forget(self);
10081    }
10082}
10083
10084impl PrivilegedPeripheralAdvertiseResponder {
10085    /// Sends a response to the FIDL transaction.
10086    ///
10087    /// Sets the channel to shutdown if an error occurs.
10088    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
10089        let _result = self.send_raw(result);
10090        if _result.is_err() {
10091            self.control_handle.shutdown();
10092        }
10093        self.drop_without_shutdown();
10094        _result
10095    }
10096
10097    /// Similar to "send" but does not shutdown the channel if an error occurs.
10098    pub fn send_no_shutdown_on_err(
10099        self,
10100        mut result: Result<(), PeripheralError>,
10101    ) -> Result<(), fidl::Error> {
10102        let _result = self.send_raw(result);
10103        self.drop_without_shutdown();
10104        _result
10105    }
10106
10107    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
10108        self.control_handle.inner.send::<fidl::encoding::ResultType<
10109            fidl::encoding::EmptyStruct,
10110            PeripheralError,
10111        >>(
10112            result,
10113            self.tx_id,
10114            0x2d9ec9260c32c17f,
10115            fidl::encoding::DynamicFlags::empty(),
10116        )
10117    }
10118}
10119
10120#[must_use = "FIDL methods require a response to be sent"]
10121#[derive(Debug)]
10122pub struct PrivilegedPeripheralStartAdvertisingResponder {
10123    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
10124    tx_id: u32,
10125}
10126
10127/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
10128/// if the responder is dropped without sending a response, so that the client
10129/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10130impl std::ops::Drop for PrivilegedPeripheralStartAdvertisingResponder {
10131    fn drop(&mut self) {
10132        self.control_handle.shutdown();
10133        // Safety: drops once, never accessed again
10134        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10135    }
10136}
10137
10138impl fidl::endpoints::Responder for PrivilegedPeripheralStartAdvertisingResponder {
10139    type ControlHandle = PrivilegedPeripheralControlHandle;
10140
10141    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
10142        &self.control_handle
10143    }
10144
10145    fn drop_without_shutdown(mut self) {
10146        // Safety: drops once, never accessed again due to mem::forget
10147        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10148        // Prevent Drop from running (which would shut down the channel)
10149        std::mem::forget(self);
10150    }
10151}
10152
10153impl PrivilegedPeripheralStartAdvertisingResponder {
10154    /// Sends a response to the FIDL transaction.
10155    ///
10156    /// Sets the channel to shutdown if an error occurs.
10157    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
10158        let _result = self.send_raw(result);
10159        if _result.is_err() {
10160            self.control_handle.shutdown();
10161        }
10162        self.drop_without_shutdown();
10163        _result
10164    }
10165
10166    /// Similar to "send" but does not shutdown the channel if an error occurs.
10167    pub fn send_no_shutdown_on_err(
10168        self,
10169        mut result: Result<(), PeripheralError>,
10170    ) -> Result<(), fidl::Error> {
10171        let _result = self.send_raw(result);
10172        self.drop_without_shutdown();
10173        _result
10174    }
10175
10176    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
10177        self.control_handle.inner.send::<fidl::encoding::ResultType<
10178            fidl::encoding::EmptyStruct,
10179            PeripheralError,
10180        >>(
10181            result,
10182            self.tx_id,
10183            0x5875c1c575f00f7d,
10184            fidl::encoding::DynamicFlags::empty(),
10185        )
10186    }
10187}
10188
10189#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10190pub struct ScanResultWatcherMarker;
10191
10192impl fidl::endpoints::ProtocolMarker for ScanResultWatcherMarker {
10193    type Proxy = ScanResultWatcherProxy;
10194    type RequestStream = ScanResultWatcherRequestStream;
10195    #[cfg(target_os = "fuchsia")]
10196    type SynchronousProxy = ScanResultWatcherSynchronousProxy;
10197
10198    const DEBUG_NAME: &'static str = "(anonymous) ScanResultWatcher";
10199}
10200
10201pub trait ScanResultWatcherProxyInterface: Send + Sync {
10202    type WatchResponseFut: std::future::Future<Output = Result<Vec<Peer>, fidl::Error>> + Send;
10203    fn r#watch(&self) -> Self::WatchResponseFut;
10204}
10205#[derive(Debug)]
10206#[cfg(target_os = "fuchsia")]
10207pub struct ScanResultWatcherSynchronousProxy {
10208    client: fidl::client::sync::Client,
10209}
10210
10211#[cfg(target_os = "fuchsia")]
10212impl fidl::endpoints::SynchronousProxy for ScanResultWatcherSynchronousProxy {
10213    type Proxy = ScanResultWatcherProxy;
10214    type Protocol = ScanResultWatcherMarker;
10215
10216    fn from_channel(inner: fidl::Channel) -> Self {
10217        Self::new(inner)
10218    }
10219
10220    fn into_channel(self) -> fidl::Channel {
10221        self.client.into_channel()
10222    }
10223
10224    fn as_channel(&self) -> &fidl::Channel {
10225        self.client.as_channel()
10226    }
10227}
10228
10229#[cfg(target_os = "fuchsia")]
10230impl ScanResultWatcherSynchronousProxy {
10231    pub fn new(channel: fidl::Channel) -> Self {
10232        let protocol_name =
10233            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10234        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
10235    }
10236
10237    pub fn into_channel(self) -> fidl::Channel {
10238        self.client.into_channel()
10239    }
10240
10241    /// Waits until an event arrives and returns it. It is safe for other
10242    /// threads to make concurrent requests while waiting for an event.
10243    pub fn wait_for_event(
10244        &self,
10245        deadline: zx::MonotonicInstant,
10246    ) -> Result<ScanResultWatcherEvent, fidl::Error> {
10247        ScanResultWatcherEvent::decode(self.client.wait_for_event(deadline)?)
10248    }
10249
10250    /// Returns a list of all LE peers that satisfy the filters indicated in
10251    /// `ScanOptions`. The first response(s) will return matching discovered
10252    /// peers immediately. Subsequent calls receive a response only when peers
10253    /// have been scanned or updated since the last call. If a second call to
10254    /// `Watch` is erronously sent while one call is already pending, the scan
10255    /// will be canceled and the protocol will be closed.
10256    ///
10257    /// - response `updated` Peers that were added or updated since the last
10258    ///   call to Watch().
10259    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<Peer>, fidl::Error> {
10260        let _response = self
10261            .client
10262            .send_query::<fidl::encoding::EmptyPayload, ScanResultWatcherWatchResponse>(
10263                (),
10264                0x713a122e949f301a,
10265                fidl::encoding::DynamicFlags::empty(),
10266                ___deadline,
10267            )?;
10268        Ok(_response.updated)
10269    }
10270}
10271
10272#[cfg(target_os = "fuchsia")]
10273impl From<ScanResultWatcherSynchronousProxy> for zx::Handle {
10274    fn from(value: ScanResultWatcherSynchronousProxy) -> Self {
10275        value.into_channel().into()
10276    }
10277}
10278
10279#[cfg(target_os = "fuchsia")]
10280impl From<fidl::Channel> for ScanResultWatcherSynchronousProxy {
10281    fn from(value: fidl::Channel) -> Self {
10282        Self::new(value)
10283    }
10284}
10285
10286#[cfg(target_os = "fuchsia")]
10287impl fidl::endpoints::FromClient for ScanResultWatcherSynchronousProxy {
10288    type Protocol = ScanResultWatcherMarker;
10289
10290    fn from_client(value: fidl::endpoints::ClientEnd<ScanResultWatcherMarker>) -> Self {
10291        Self::new(value.into_channel())
10292    }
10293}
10294
10295#[derive(Debug, Clone)]
10296pub struct ScanResultWatcherProxy {
10297    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10298}
10299
10300impl fidl::endpoints::Proxy for ScanResultWatcherProxy {
10301    type Protocol = ScanResultWatcherMarker;
10302
10303    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10304        Self::new(inner)
10305    }
10306
10307    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10308        self.client.into_channel().map_err(|client| Self { client })
10309    }
10310
10311    fn as_channel(&self) -> &::fidl::AsyncChannel {
10312        self.client.as_channel()
10313    }
10314}
10315
10316impl ScanResultWatcherProxy {
10317    /// Create a new Proxy for fuchsia.bluetooth.le/ScanResultWatcher.
10318    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10319        let protocol_name =
10320            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10321        Self { client: fidl::client::Client::new(channel, protocol_name) }
10322    }
10323
10324    /// Get a Stream of events from the remote end of the protocol.
10325    ///
10326    /// # Panics
10327    ///
10328    /// Panics if the event stream was already taken.
10329    pub fn take_event_stream(&self) -> ScanResultWatcherEventStream {
10330        ScanResultWatcherEventStream { event_receiver: self.client.take_event_receiver() }
10331    }
10332
10333    /// Returns a list of all LE peers that satisfy the filters indicated in
10334    /// `ScanOptions`. The first response(s) will return matching discovered
10335    /// peers immediately. Subsequent calls receive a response only when peers
10336    /// have been scanned or updated since the last call. If a second call to
10337    /// `Watch` is erronously sent while one call is already pending, the scan
10338    /// will be canceled and the protocol will be closed.
10339    ///
10340    /// - response `updated` Peers that were added or updated since the last
10341    ///   call to Watch().
10342    pub fn r#watch(
10343        &self,
10344    ) -> fidl::client::QueryResponseFut<Vec<Peer>, fidl::encoding::DefaultFuchsiaResourceDialect>
10345    {
10346        ScanResultWatcherProxyInterface::r#watch(self)
10347    }
10348}
10349
10350impl ScanResultWatcherProxyInterface for ScanResultWatcherProxy {
10351    type WatchResponseFut =
10352        fidl::client::QueryResponseFut<Vec<Peer>, fidl::encoding::DefaultFuchsiaResourceDialect>;
10353    fn r#watch(&self) -> Self::WatchResponseFut {
10354        fn _decode(
10355            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10356        ) -> Result<Vec<Peer>, fidl::Error> {
10357            let _response = fidl::client::decode_transaction_body::<
10358                ScanResultWatcherWatchResponse,
10359                fidl::encoding::DefaultFuchsiaResourceDialect,
10360                0x713a122e949f301a,
10361            >(_buf?)?;
10362            Ok(_response.updated)
10363        }
10364        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Peer>>(
10365            (),
10366            0x713a122e949f301a,
10367            fidl::encoding::DynamicFlags::empty(),
10368            _decode,
10369        )
10370    }
10371}
10372
10373pub struct ScanResultWatcherEventStream {
10374    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
10375}
10376
10377impl std::marker::Unpin for ScanResultWatcherEventStream {}
10378
10379impl futures::stream::FusedStream for ScanResultWatcherEventStream {
10380    fn is_terminated(&self) -> bool {
10381        self.event_receiver.is_terminated()
10382    }
10383}
10384
10385impl futures::Stream for ScanResultWatcherEventStream {
10386    type Item = Result<ScanResultWatcherEvent, fidl::Error>;
10387
10388    fn poll_next(
10389        mut self: std::pin::Pin<&mut Self>,
10390        cx: &mut std::task::Context<'_>,
10391    ) -> std::task::Poll<Option<Self::Item>> {
10392        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10393            &mut self.event_receiver,
10394            cx
10395        )?) {
10396            Some(buf) => std::task::Poll::Ready(Some(ScanResultWatcherEvent::decode(buf))),
10397            None => std::task::Poll::Ready(None),
10398        }
10399    }
10400}
10401
10402#[derive(Debug)]
10403pub enum ScanResultWatcherEvent {}
10404
10405impl ScanResultWatcherEvent {
10406    /// Decodes a message buffer as a [`ScanResultWatcherEvent`].
10407    fn decode(
10408        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10409    ) -> Result<ScanResultWatcherEvent, fidl::Error> {
10410        let (bytes, _handles) = buf.split_mut();
10411        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10412        debug_assert_eq!(tx_header.tx_id, 0);
10413        match tx_header.ordinal {
10414            _ => Err(fidl::Error::UnknownOrdinal {
10415                ordinal: tx_header.ordinal,
10416                protocol_name:
10417                    <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
10418            }),
10419        }
10420    }
10421}
10422
10423/// A Stream of incoming requests for fuchsia.bluetooth.le/ScanResultWatcher.
10424pub struct ScanResultWatcherRequestStream {
10425    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10426    is_terminated: bool,
10427}
10428
10429impl std::marker::Unpin for ScanResultWatcherRequestStream {}
10430
10431impl futures::stream::FusedStream for ScanResultWatcherRequestStream {
10432    fn is_terminated(&self) -> bool {
10433        self.is_terminated
10434    }
10435}
10436
10437impl fidl::endpoints::RequestStream for ScanResultWatcherRequestStream {
10438    type Protocol = ScanResultWatcherMarker;
10439    type ControlHandle = ScanResultWatcherControlHandle;
10440
10441    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
10442        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10443    }
10444
10445    fn control_handle(&self) -> Self::ControlHandle {
10446        ScanResultWatcherControlHandle { inner: self.inner.clone() }
10447    }
10448
10449    fn into_inner(
10450        self,
10451    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
10452    {
10453        (self.inner, self.is_terminated)
10454    }
10455
10456    fn from_inner(
10457        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10458        is_terminated: bool,
10459    ) -> Self {
10460        Self { inner, is_terminated }
10461    }
10462}
10463
10464impl futures::Stream for ScanResultWatcherRequestStream {
10465    type Item = Result<ScanResultWatcherRequest, fidl::Error>;
10466
10467    fn poll_next(
10468        mut self: std::pin::Pin<&mut Self>,
10469        cx: &mut std::task::Context<'_>,
10470    ) -> std::task::Poll<Option<Self::Item>> {
10471        let this = &mut *self;
10472        if this.inner.check_shutdown(cx) {
10473            this.is_terminated = true;
10474            return std::task::Poll::Ready(None);
10475        }
10476        if this.is_terminated {
10477            panic!("polled ScanResultWatcherRequestStream after completion");
10478        }
10479        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
10480            |bytes, handles| {
10481                match this.inner.channel().read_etc(cx, bytes, handles) {
10482                    std::task::Poll::Ready(Ok(())) => {}
10483                    std::task::Poll::Pending => return std::task::Poll::Pending,
10484                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
10485                        this.is_terminated = true;
10486                        return std::task::Poll::Ready(None);
10487                    }
10488                    std::task::Poll::Ready(Err(e)) => {
10489                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10490                            e.into(),
10491                        ))));
10492                    }
10493                }
10494
10495                // A message has been received from the channel
10496                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10497
10498                std::task::Poll::Ready(Some(match header.ordinal {
10499                    0x713a122e949f301a => {
10500                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10501                        let mut req = fidl::new_empty!(
10502                            fidl::encoding::EmptyPayload,
10503                            fidl::encoding::DefaultFuchsiaResourceDialect
10504                        );
10505                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10506                        let control_handle =
10507                            ScanResultWatcherControlHandle { inner: this.inner.clone() };
10508                        Ok(ScanResultWatcherRequest::Watch {
10509                            responder: ScanResultWatcherWatchResponder {
10510                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10511                                tx_id: header.tx_id,
10512                            },
10513                        })
10514                    }
10515                    _ => Err(fidl::Error::UnknownOrdinal {
10516                        ordinal: header.ordinal,
10517                        protocol_name:
10518                            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
10519                    }),
10520                }))
10521            },
10522        )
10523    }
10524}
10525
10526/// Represents an active scan procedure. This protocol remains valid for the
10527/// duration of a scan and can be used to obtain scan results. The client can
10528/// close the protocol to stop scanning. If a scan is stopped by the system, the
10529/// protocol will be closed with the epitaph `CANCELED` to communicate this to
10530/// the client.
10531#[derive(Debug)]
10532pub enum ScanResultWatcherRequest {
10533    /// Returns a list of all LE peers that satisfy the filters indicated in
10534    /// `ScanOptions`. The first response(s) will return matching discovered
10535    /// peers immediately. Subsequent calls receive a response only when peers
10536    /// have been scanned or updated since the last call. If a second call to
10537    /// `Watch` is erronously sent while one call is already pending, the scan
10538    /// will be canceled and the protocol will be closed.
10539    ///
10540    /// - response `updated` Peers that were added or updated since the last
10541    ///   call to Watch().
10542    Watch { responder: ScanResultWatcherWatchResponder },
10543}
10544
10545impl ScanResultWatcherRequest {
10546    #[allow(irrefutable_let_patterns)]
10547    pub fn into_watch(self) -> Option<(ScanResultWatcherWatchResponder)> {
10548        if let ScanResultWatcherRequest::Watch { responder } = self {
10549            Some((responder))
10550        } else {
10551            None
10552        }
10553    }
10554
10555    /// Name of the method defined in FIDL
10556    pub fn method_name(&self) -> &'static str {
10557        match *self {
10558            ScanResultWatcherRequest::Watch { .. } => "watch",
10559        }
10560    }
10561}
10562
10563#[derive(Debug, Clone)]
10564pub struct ScanResultWatcherControlHandle {
10565    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10566}
10567
10568impl fidl::endpoints::ControlHandle for ScanResultWatcherControlHandle {
10569    fn shutdown(&self) {
10570        self.inner.shutdown()
10571    }
10572    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10573        self.inner.shutdown_with_epitaph(status)
10574    }
10575
10576    fn is_closed(&self) -> bool {
10577        self.inner.channel().is_closed()
10578    }
10579    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10580        self.inner.channel().on_closed()
10581    }
10582
10583    #[cfg(target_os = "fuchsia")]
10584    fn signal_peer(
10585        &self,
10586        clear_mask: zx::Signals,
10587        set_mask: zx::Signals,
10588    ) -> Result<(), zx_status::Status> {
10589        use fidl::Peered;
10590        self.inner.channel().signal_peer(clear_mask, set_mask)
10591    }
10592}
10593
10594impl ScanResultWatcherControlHandle {}
10595
10596#[must_use = "FIDL methods require a response to be sent"]
10597#[derive(Debug)]
10598pub struct ScanResultWatcherWatchResponder {
10599    control_handle: std::mem::ManuallyDrop<ScanResultWatcherControlHandle>,
10600    tx_id: u32,
10601}
10602
10603/// Set the the channel to be shutdown (see [`ScanResultWatcherControlHandle::shutdown`])
10604/// if the responder is dropped without sending a response, so that the client
10605/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10606impl std::ops::Drop for ScanResultWatcherWatchResponder {
10607    fn drop(&mut self) {
10608        self.control_handle.shutdown();
10609        // Safety: drops once, never accessed again
10610        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10611    }
10612}
10613
10614impl fidl::endpoints::Responder for ScanResultWatcherWatchResponder {
10615    type ControlHandle = ScanResultWatcherControlHandle;
10616
10617    fn control_handle(&self) -> &ScanResultWatcherControlHandle {
10618        &self.control_handle
10619    }
10620
10621    fn drop_without_shutdown(mut self) {
10622        // Safety: drops once, never accessed again due to mem::forget
10623        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10624        // Prevent Drop from running (which would shut down the channel)
10625        std::mem::forget(self);
10626    }
10627}
10628
10629impl ScanResultWatcherWatchResponder {
10630    /// Sends a response to the FIDL transaction.
10631    ///
10632    /// Sets the channel to shutdown if an error occurs.
10633    pub fn send(self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
10634        let _result = self.send_raw(updated);
10635        if _result.is_err() {
10636            self.control_handle.shutdown();
10637        }
10638        self.drop_without_shutdown();
10639        _result
10640    }
10641
10642    /// Similar to "send" but does not shutdown the channel if an error occurs.
10643    pub fn send_no_shutdown_on_err(self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
10644        let _result = self.send_raw(updated);
10645        self.drop_without_shutdown();
10646        _result
10647    }
10648
10649    fn send_raw(&self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
10650        self.control_handle.inner.send::<ScanResultWatcherWatchResponse>(
10651            (updated,),
10652            self.tx_id,
10653            0x713a122e949f301a,
10654            fidl::encoding::DynamicFlags::empty(),
10655        )
10656    }
10657}
10658
10659mod internal {
10660    use super::*;
10661
10662    impl fidl::encoding::ResourceTypeMarker for AdvertisedPeripheralOnConnectedRequest {
10663        type Borrowed<'a> = &'a mut Self;
10664        fn take_or_borrow<'a>(
10665            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10666        ) -> Self::Borrowed<'a> {
10667            value
10668        }
10669    }
10670
10671    unsafe impl fidl::encoding::TypeMarker for AdvertisedPeripheralOnConnectedRequest {
10672        type Owned = Self;
10673
10674        #[inline(always)]
10675        fn inline_align(_context: fidl::encoding::Context) -> usize {
10676            8
10677        }
10678
10679        #[inline(always)]
10680        fn inline_size(_context: fidl::encoding::Context) -> usize {
10681            24
10682        }
10683    }
10684
10685    unsafe impl
10686        fidl::encoding::Encode<
10687            AdvertisedPeripheralOnConnectedRequest,
10688            fidl::encoding::DefaultFuchsiaResourceDialect,
10689        > for &mut AdvertisedPeripheralOnConnectedRequest
10690    {
10691        #[inline]
10692        unsafe fn encode(
10693            self,
10694            encoder: &mut fidl::encoding::Encoder<
10695                '_,
10696                fidl::encoding::DefaultFuchsiaResourceDialect,
10697            >,
10698            offset: usize,
10699            _depth: fidl::encoding::Depth,
10700        ) -> fidl::Result<()> {
10701            encoder.debug_check_bounds::<AdvertisedPeripheralOnConnectedRequest>(offset);
10702            // Delegate to tuple encoding.
10703            fidl::encoding::Encode::<AdvertisedPeripheralOnConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10704                (
10705                    <Peer as fidl::encoding::ValueTypeMarker>::borrow(&self.peer),
10706                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.connection),
10707                ),
10708                encoder, offset, _depth
10709            )
10710        }
10711    }
10712    unsafe impl<
10713        T0: fidl::encoding::Encode<Peer, fidl::encoding::DefaultFuchsiaResourceDialect>,
10714        T1: fidl::encoding::Encode<
10715                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
10716                fidl::encoding::DefaultFuchsiaResourceDialect,
10717            >,
10718    >
10719        fidl::encoding::Encode<
10720            AdvertisedPeripheralOnConnectedRequest,
10721            fidl::encoding::DefaultFuchsiaResourceDialect,
10722        > for (T0, T1)
10723    {
10724        #[inline]
10725        unsafe fn encode(
10726            self,
10727            encoder: &mut fidl::encoding::Encoder<
10728                '_,
10729                fidl::encoding::DefaultFuchsiaResourceDialect,
10730            >,
10731            offset: usize,
10732            depth: fidl::encoding::Depth,
10733        ) -> fidl::Result<()> {
10734            encoder.debug_check_bounds::<AdvertisedPeripheralOnConnectedRequest>(offset);
10735            // Zero out padding regions. There's no need to apply masks
10736            // because the unmasked parts will be overwritten by fields.
10737            unsafe {
10738                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
10739                (ptr as *mut u64).write_unaligned(0);
10740            }
10741            // Write the fields.
10742            self.0.encode(encoder, offset + 0, depth)?;
10743            self.1.encode(encoder, offset + 16, depth)?;
10744            Ok(())
10745        }
10746    }
10747
10748    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10749        for AdvertisedPeripheralOnConnectedRequest
10750    {
10751        #[inline(always)]
10752        fn new_empty() -> Self {
10753            Self {
10754                peer: fidl::new_empty!(Peer, fidl::encoding::DefaultFuchsiaResourceDialect),
10755                connection: fidl::new_empty!(
10756                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
10757                    fidl::encoding::DefaultFuchsiaResourceDialect
10758                ),
10759            }
10760        }
10761
10762        #[inline]
10763        unsafe fn decode(
10764            &mut self,
10765            decoder: &mut fidl::encoding::Decoder<
10766                '_,
10767                fidl::encoding::DefaultFuchsiaResourceDialect,
10768            >,
10769            offset: usize,
10770            _depth: fidl::encoding::Depth,
10771        ) -> fidl::Result<()> {
10772            decoder.debug_check_bounds::<Self>(offset);
10773            // Verify that padding bytes are zero.
10774            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
10775            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10776            let mask = 0xffffffff00000000u64;
10777            let maskedval = padval & mask;
10778            if maskedval != 0 {
10779                return Err(fidl::Error::NonZeroPadding {
10780                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
10781                });
10782            }
10783            fidl::decode!(
10784                Peer,
10785                fidl::encoding::DefaultFuchsiaResourceDialect,
10786                &mut self.peer,
10787                decoder,
10788                offset + 0,
10789                _depth
10790            )?;
10791            fidl::decode!(
10792                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
10793                fidl::encoding::DefaultFuchsiaResourceDialect,
10794                &mut self.connection,
10795                decoder,
10796                offset + 16,
10797                _depth
10798            )?;
10799            Ok(())
10800        }
10801    }
10802
10803    impl fidl::encoding::ResourceTypeMarker for CentralConnectPeripheralRequest {
10804        type Borrowed<'a> = &'a mut Self;
10805        fn take_or_borrow<'a>(
10806            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10807        ) -> Self::Borrowed<'a> {
10808            value
10809        }
10810    }
10811
10812    unsafe impl fidl::encoding::TypeMarker for CentralConnectPeripheralRequest {
10813        type Owned = Self;
10814
10815        #[inline(always)]
10816        fn inline_align(_context: fidl::encoding::Context) -> usize {
10817            8
10818        }
10819
10820        #[inline(always)]
10821        fn inline_size(_context: fidl::encoding::Context) -> usize {
10822            40
10823        }
10824    }
10825
10826    unsafe impl
10827        fidl::encoding::Encode<
10828            CentralConnectPeripheralRequest,
10829            fidl::encoding::DefaultFuchsiaResourceDialect,
10830        > for &mut CentralConnectPeripheralRequest
10831    {
10832        #[inline]
10833        unsafe fn encode(
10834            self,
10835            encoder: &mut fidl::encoding::Encoder<
10836                '_,
10837                fidl::encoding::DefaultFuchsiaResourceDialect,
10838            >,
10839            offset: usize,
10840            _depth: fidl::encoding::Depth,
10841        ) -> fidl::Result<()> {
10842            encoder.debug_check_bounds::<CentralConnectPeripheralRequest>(offset);
10843            // Delegate to tuple encoding.
10844            fidl::encoding::Encode::<
10845                CentralConnectPeripheralRequest,
10846                fidl::encoding::DefaultFuchsiaResourceDialect,
10847            >::encode(
10848                (
10849                    <fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(
10850                        &self.identifier,
10851                    ),
10852                    <ConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
10853                    <fidl::encoding::Endpoint<
10854                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10855                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10856                        &mut self.gatt_client
10857                    ),
10858                ),
10859                encoder,
10860                offset,
10861                _depth,
10862            )
10863        }
10864    }
10865    unsafe impl<
10866        T0: fidl::encoding::Encode<
10867                fidl::encoding::BoundedString<16>,
10868                fidl::encoding::DefaultFuchsiaResourceDialect,
10869            >,
10870        T1: fidl::encoding::Encode<ConnectionOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
10871        T2: fidl::encoding::Encode<
10872                fidl::encoding::Endpoint<
10873                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10874                >,
10875                fidl::encoding::DefaultFuchsiaResourceDialect,
10876            >,
10877    >
10878        fidl::encoding::Encode<
10879            CentralConnectPeripheralRequest,
10880            fidl::encoding::DefaultFuchsiaResourceDialect,
10881        > for (T0, T1, T2)
10882    {
10883        #[inline]
10884        unsafe fn encode(
10885            self,
10886            encoder: &mut fidl::encoding::Encoder<
10887                '_,
10888                fidl::encoding::DefaultFuchsiaResourceDialect,
10889            >,
10890            offset: usize,
10891            depth: fidl::encoding::Depth,
10892        ) -> fidl::Result<()> {
10893            encoder.debug_check_bounds::<CentralConnectPeripheralRequest>(offset);
10894            // Zero out padding regions. There's no need to apply masks
10895            // because the unmasked parts will be overwritten by fields.
10896            unsafe {
10897                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
10898                (ptr as *mut u64).write_unaligned(0);
10899            }
10900            // Write the fields.
10901            self.0.encode(encoder, offset + 0, depth)?;
10902            self.1.encode(encoder, offset + 16, depth)?;
10903            self.2.encode(encoder, offset + 32, depth)?;
10904            Ok(())
10905        }
10906    }
10907
10908    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10909        for CentralConnectPeripheralRequest
10910    {
10911        #[inline(always)]
10912        fn new_empty() -> Self {
10913            Self {
10914                identifier: fidl::new_empty!(
10915                    fidl::encoding::BoundedString<16>,
10916                    fidl::encoding::DefaultFuchsiaResourceDialect
10917                ),
10918                options: fidl::new_empty!(
10919                    ConnectionOptions,
10920                    fidl::encoding::DefaultFuchsiaResourceDialect
10921                ),
10922                gatt_client: fidl::new_empty!(
10923                    fidl::encoding::Endpoint<
10924                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10925                    >,
10926                    fidl::encoding::DefaultFuchsiaResourceDialect
10927                ),
10928            }
10929        }
10930
10931        #[inline]
10932        unsafe fn decode(
10933            &mut self,
10934            decoder: &mut fidl::encoding::Decoder<
10935                '_,
10936                fidl::encoding::DefaultFuchsiaResourceDialect,
10937            >,
10938            offset: usize,
10939            _depth: fidl::encoding::Depth,
10940        ) -> fidl::Result<()> {
10941            decoder.debug_check_bounds::<Self>(offset);
10942            // Verify that padding bytes are zero.
10943            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
10944            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10945            let mask = 0xffffffff00000000u64;
10946            let maskedval = padval & mask;
10947            if maskedval != 0 {
10948                return Err(fidl::Error::NonZeroPadding {
10949                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
10950                });
10951            }
10952            fidl::decode!(
10953                fidl::encoding::BoundedString<16>,
10954                fidl::encoding::DefaultFuchsiaResourceDialect,
10955                &mut self.identifier,
10956                decoder,
10957                offset + 0,
10958                _depth
10959            )?;
10960            fidl::decode!(
10961                ConnectionOptions,
10962                fidl::encoding::DefaultFuchsiaResourceDialect,
10963                &mut self.options,
10964                decoder,
10965                offset + 16,
10966                _depth
10967            )?;
10968            fidl::decode!(
10969                fidl::encoding::Endpoint<
10970                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10971                >,
10972                fidl::encoding::DefaultFuchsiaResourceDialect,
10973                &mut self.gatt_client,
10974                decoder,
10975                offset + 32,
10976                _depth
10977            )?;
10978            Ok(())
10979        }
10980    }
10981
10982    impl fidl::encoding::ResourceTypeMarker for CentralConnectRequest {
10983        type Borrowed<'a> = &'a mut Self;
10984        fn take_or_borrow<'a>(
10985            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10986        ) -> Self::Borrowed<'a> {
10987            value
10988        }
10989    }
10990
10991    unsafe impl fidl::encoding::TypeMarker for CentralConnectRequest {
10992        type Owned = Self;
10993
10994        #[inline(always)]
10995        fn inline_align(_context: fidl::encoding::Context) -> usize {
10996            8
10997        }
10998
10999        #[inline(always)]
11000        fn inline_size(_context: fidl::encoding::Context) -> usize {
11001            32
11002        }
11003    }
11004
11005    unsafe impl
11006        fidl::encoding::Encode<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
11007        for &mut CentralConnectRequest
11008    {
11009        #[inline]
11010        unsafe fn encode(
11011            self,
11012            encoder: &mut fidl::encoding::Encoder<
11013                '_,
11014                fidl::encoding::DefaultFuchsiaResourceDialect,
11015            >,
11016            offset: usize,
11017            _depth: fidl::encoding::Depth,
11018        ) -> fidl::Result<()> {
11019            encoder.debug_check_bounds::<CentralConnectRequest>(offset);
11020            // Delegate to tuple encoding.
11021            fidl::encoding::Encode::<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
11022                (
11023                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
11024                    <ConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
11025                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
11026                ),
11027                encoder, offset, _depth
11028            )
11029        }
11030    }
11031    unsafe impl<
11032        T0: fidl::encoding::Encode<
11033                fidl_fuchsia_bluetooth::PeerId,
11034                fidl::encoding::DefaultFuchsiaResourceDialect,
11035            >,
11036        T1: fidl::encoding::Encode<ConnectionOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
11037        T2: fidl::encoding::Encode<
11038                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
11039                fidl::encoding::DefaultFuchsiaResourceDialect,
11040            >,
11041    >
11042        fidl::encoding::Encode<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
11043        for (T0, T1, T2)
11044    {
11045        #[inline]
11046        unsafe fn encode(
11047            self,
11048            encoder: &mut fidl::encoding::Encoder<
11049                '_,
11050                fidl::encoding::DefaultFuchsiaResourceDialect,
11051            >,
11052            offset: usize,
11053            depth: fidl::encoding::Depth,
11054        ) -> fidl::Result<()> {
11055            encoder.debug_check_bounds::<CentralConnectRequest>(offset);
11056            // Zero out padding regions. There's no need to apply masks
11057            // because the unmasked parts will be overwritten by fields.
11058            unsafe {
11059                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
11060                (ptr as *mut u64).write_unaligned(0);
11061            }
11062            // Write the fields.
11063            self.0.encode(encoder, offset + 0, depth)?;
11064            self.1.encode(encoder, offset + 8, depth)?;
11065            self.2.encode(encoder, offset + 24, depth)?;
11066            Ok(())
11067        }
11068    }
11069
11070    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11071        for CentralConnectRequest
11072    {
11073        #[inline(always)]
11074        fn new_empty() -> Self {
11075            Self {
11076                id: fidl::new_empty!(
11077                    fidl_fuchsia_bluetooth::PeerId,
11078                    fidl::encoding::DefaultFuchsiaResourceDialect
11079                ),
11080                options: fidl::new_empty!(
11081                    ConnectionOptions,
11082                    fidl::encoding::DefaultFuchsiaResourceDialect
11083                ),
11084                handle: fidl::new_empty!(
11085                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
11086                    fidl::encoding::DefaultFuchsiaResourceDialect
11087                ),
11088            }
11089        }
11090
11091        #[inline]
11092        unsafe fn decode(
11093            &mut self,
11094            decoder: &mut fidl::encoding::Decoder<
11095                '_,
11096                fidl::encoding::DefaultFuchsiaResourceDialect,
11097            >,
11098            offset: usize,
11099            _depth: fidl::encoding::Depth,
11100        ) -> fidl::Result<()> {
11101            decoder.debug_check_bounds::<Self>(offset);
11102            // Verify that padding bytes are zero.
11103            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
11104            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11105            let mask = 0xffffffff00000000u64;
11106            let maskedval = padval & mask;
11107            if maskedval != 0 {
11108                return Err(fidl::Error::NonZeroPadding {
11109                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
11110                });
11111            }
11112            fidl::decode!(
11113                fidl_fuchsia_bluetooth::PeerId,
11114                fidl::encoding::DefaultFuchsiaResourceDialect,
11115                &mut self.id,
11116                decoder,
11117                offset + 0,
11118                _depth
11119            )?;
11120            fidl::decode!(
11121                ConnectionOptions,
11122                fidl::encoding::DefaultFuchsiaResourceDialect,
11123                &mut self.options,
11124                decoder,
11125                offset + 8,
11126                _depth
11127            )?;
11128            fidl::decode!(
11129                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
11130                fidl::encoding::DefaultFuchsiaResourceDialect,
11131                &mut self.handle,
11132                decoder,
11133                offset + 24,
11134                _depth
11135            )?;
11136            Ok(())
11137        }
11138    }
11139
11140    impl fidl::encoding::ResourceTypeMarker for CentralScanRequest {
11141        type Borrowed<'a> = &'a mut Self;
11142        fn take_or_borrow<'a>(
11143            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11144        ) -> Self::Borrowed<'a> {
11145            value
11146        }
11147    }
11148
11149    unsafe impl fidl::encoding::TypeMarker for CentralScanRequest {
11150        type Owned = Self;
11151
11152        #[inline(always)]
11153        fn inline_align(_context: fidl::encoding::Context) -> usize {
11154            8
11155        }
11156
11157        #[inline(always)]
11158        fn inline_size(_context: fidl::encoding::Context) -> usize {
11159            24
11160        }
11161    }
11162
11163    unsafe impl
11164        fidl::encoding::Encode<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
11165        for &mut CentralScanRequest
11166    {
11167        #[inline]
11168        unsafe fn encode(
11169            self,
11170            encoder: &mut fidl::encoding::Encoder<
11171                '_,
11172                fidl::encoding::DefaultFuchsiaResourceDialect,
11173            >,
11174            offset: usize,
11175            _depth: fidl::encoding::Depth,
11176        ) -> fidl::Result<()> {
11177            encoder.debug_check_bounds::<CentralScanRequest>(offset);
11178            // Delegate to tuple encoding.
11179            fidl::encoding::Encode::<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
11180                (
11181                    <ScanOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
11182                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.result_watcher),
11183                ),
11184                encoder, offset, _depth
11185            )
11186        }
11187    }
11188    unsafe impl<
11189        T0: fidl::encoding::Encode<ScanOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
11190        T1: fidl::encoding::Encode<
11191                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
11192                fidl::encoding::DefaultFuchsiaResourceDialect,
11193            >,
11194    > fidl::encoding::Encode<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
11195        for (T0, T1)
11196    {
11197        #[inline]
11198        unsafe fn encode(
11199            self,
11200            encoder: &mut fidl::encoding::Encoder<
11201                '_,
11202                fidl::encoding::DefaultFuchsiaResourceDialect,
11203            >,
11204            offset: usize,
11205            depth: fidl::encoding::Depth,
11206        ) -> fidl::Result<()> {
11207            encoder.debug_check_bounds::<CentralScanRequest>(offset);
11208            // Zero out padding regions. There's no need to apply masks
11209            // because the unmasked parts will be overwritten by fields.
11210            unsafe {
11211                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
11212                (ptr as *mut u64).write_unaligned(0);
11213            }
11214            // Write the fields.
11215            self.0.encode(encoder, offset + 0, depth)?;
11216            self.1.encode(encoder, offset + 16, depth)?;
11217            Ok(())
11218        }
11219    }
11220
11221    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11222        for CentralScanRequest
11223    {
11224        #[inline(always)]
11225        fn new_empty() -> Self {
11226            Self {
11227                options: fidl::new_empty!(
11228                    ScanOptions,
11229                    fidl::encoding::DefaultFuchsiaResourceDialect
11230                ),
11231                result_watcher: fidl::new_empty!(
11232                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
11233                    fidl::encoding::DefaultFuchsiaResourceDialect
11234                ),
11235            }
11236        }
11237
11238        #[inline]
11239        unsafe fn decode(
11240            &mut self,
11241            decoder: &mut fidl::encoding::Decoder<
11242                '_,
11243                fidl::encoding::DefaultFuchsiaResourceDialect,
11244            >,
11245            offset: usize,
11246            _depth: fidl::encoding::Depth,
11247        ) -> fidl::Result<()> {
11248            decoder.debug_check_bounds::<Self>(offset);
11249            // Verify that padding bytes are zero.
11250            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
11251            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11252            let mask = 0xffffffff00000000u64;
11253            let maskedval = padval & mask;
11254            if maskedval != 0 {
11255                return Err(fidl::Error::NonZeroPadding {
11256                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
11257                });
11258            }
11259            fidl::decode!(
11260                ScanOptions,
11261                fidl::encoding::DefaultFuchsiaResourceDialect,
11262                &mut self.options,
11263                decoder,
11264                offset + 0,
11265                _depth
11266            )?;
11267            fidl::decode!(
11268                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
11269                fidl::encoding::DefaultFuchsiaResourceDialect,
11270                &mut self.result_watcher,
11271                decoder,
11272                offset + 16,
11273                _depth
11274            )?;
11275            Ok(())
11276        }
11277    }
11278
11279    impl fidl::encoding::ResourceTypeMarker for ChannelListenerAcceptRequest {
11280        type Borrowed<'a> = &'a mut Self;
11281        fn take_or_borrow<'a>(
11282            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11283        ) -> Self::Borrowed<'a> {
11284            value
11285        }
11286    }
11287
11288    unsafe impl fidl::encoding::TypeMarker for ChannelListenerAcceptRequest {
11289        type Owned = Self;
11290
11291        #[inline(always)]
11292        fn inline_align(_context: fidl::encoding::Context) -> usize {
11293            4
11294        }
11295
11296        #[inline(always)]
11297        fn inline_size(_context: fidl::encoding::Context) -> usize {
11298            4
11299        }
11300    }
11301
11302    unsafe impl
11303        fidl::encoding::Encode<
11304            ChannelListenerAcceptRequest,
11305            fidl::encoding::DefaultFuchsiaResourceDialect,
11306        > for &mut ChannelListenerAcceptRequest
11307    {
11308        #[inline]
11309        unsafe fn encode(
11310            self,
11311            encoder: &mut fidl::encoding::Encoder<
11312                '_,
11313                fidl::encoding::DefaultFuchsiaResourceDialect,
11314            >,
11315            offset: usize,
11316            _depth: fidl::encoding::Depth,
11317        ) -> fidl::Result<()> {
11318            encoder.debug_check_bounds::<ChannelListenerAcceptRequest>(offset);
11319            // Delegate to tuple encoding.
11320            fidl::encoding::Encode::<
11321                ChannelListenerAcceptRequest,
11322                fidl::encoding::DefaultFuchsiaResourceDialect,
11323            >::encode(
11324                (<fidl::encoding::Endpoint<
11325                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
11326                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11327                    &mut self.channel
11328                ),),
11329                encoder,
11330                offset,
11331                _depth,
11332            )
11333        }
11334    }
11335    unsafe impl<
11336        T0: fidl::encoding::Encode<
11337                fidl::encoding::Endpoint<
11338                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
11339                >,
11340                fidl::encoding::DefaultFuchsiaResourceDialect,
11341            >,
11342    >
11343        fidl::encoding::Encode<
11344            ChannelListenerAcceptRequest,
11345            fidl::encoding::DefaultFuchsiaResourceDialect,
11346        > for (T0,)
11347    {
11348        #[inline]
11349        unsafe fn encode(
11350            self,
11351            encoder: &mut fidl::encoding::Encoder<
11352                '_,
11353                fidl::encoding::DefaultFuchsiaResourceDialect,
11354            >,
11355            offset: usize,
11356            depth: fidl::encoding::Depth,
11357        ) -> fidl::Result<()> {
11358            encoder.debug_check_bounds::<ChannelListenerAcceptRequest>(offset);
11359            // Zero out padding regions. There's no need to apply masks
11360            // because the unmasked parts will be overwritten by fields.
11361            // Write the fields.
11362            self.0.encode(encoder, offset + 0, depth)?;
11363            Ok(())
11364        }
11365    }
11366
11367    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11368        for ChannelListenerAcceptRequest
11369    {
11370        #[inline(always)]
11371        fn new_empty() -> Self {
11372            Self {
11373                channel: fidl::new_empty!(
11374                    fidl::encoding::Endpoint<
11375                        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
11376                    >,
11377                    fidl::encoding::DefaultFuchsiaResourceDialect
11378                ),
11379            }
11380        }
11381
11382        #[inline]
11383        unsafe fn decode(
11384            &mut self,
11385            decoder: &mut fidl::encoding::Decoder<
11386                '_,
11387                fidl::encoding::DefaultFuchsiaResourceDialect,
11388            >,
11389            offset: usize,
11390            _depth: fidl::encoding::Depth,
11391        ) -> fidl::Result<()> {
11392            decoder.debug_check_bounds::<Self>(offset);
11393            // Verify that padding bytes are zero.
11394            fidl::decode!(
11395                fidl::encoding::Endpoint<
11396                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
11397                >,
11398                fidl::encoding::DefaultFuchsiaResourceDialect,
11399                &mut self.channel,
11400                decoder,
11401                offset + 0,
11402                _depth
11403            )?;
11404            Ok(())
11405        }
11406    }
11407
11408    impl fidl::encoding::ResourceTypeMarker for ConnectionRequestGattClientRequest {
11409        type Borrowed<'a> = &'a mut Self;
11410        fn take_or_borrow<'a>(
11411            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11412        ) -> Self::Borrowed<'a> {
11413            value
11414        }
11415    }
11416
11417    unsafe impl fidl::encoding::TypeMarker for ConnectionRequestGattClientRequest {
11418        type Owned = Self;
11419
11420        #[inline(always)]
11421        fn inline_align(_context: fidl::encoding::Context) -> usize {
11422            4
11423        }
11424
11425        #[inline(always)]
11426        fn inline_size(_context: fidl::encoding::Context) -> usize {
11427            4
11428        }
11429    }
11430
11431    unsafe impl
11432        fidl::encoding::Encode<
11433            ConnectionRequestGattClientRequest,
11434            fidl::encoding::DefaultFuchsiaResourceDialect,
11435        > for &mut ConnectionRequestGattClientRequest
11436    {
11437        #[inline]
11438        unsafe fn encode(
11439            self,
11440            encoder: &mut fidl::encoding::Encoder<
11441                '_,
11442                fidl::encoding::DefaultFuchsiaResourceDialect,
11443            >,
11444            offset: usize,
11445            _depth: fidl::encoding::Depth,
11446        ) -> fidl::Result<()> {
11447            encoder.debug_check_bounds::<ConnectionRequestGattClientRequest>(offset);
11448            // Delegate to tuple encoding.
11449            fidl::encoding::Encode::<
11450                ConnectionRequestGattClientRequest,
11451                fidl::encoding::DefaultFuchsiaResourceDialect,
11452            >::encode(
11453                (<fidl::encoding::Endpoint<
11454                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
11455                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11456                    &mut self.client
11457                ),),
11458                encoder,
11459                offset,
11460                _depth,
11461            )
11462        }
11463    }
11464    unsafe impl<
11465        T0: fidl::encoding::Encode<
11466                fidl::encoding::Endpoint<
11467                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
11468                >,
11469                fidl::encoding::DefaultFuchsiaResourceDialect,
11470            >,
11471    >
11472        fidl::encoding::Encode<
11473            ConnectionRequestGattClientRequest,
11474            fidl::encoding::DefaultFuchsiaResourceDialect,
11475        > for (T0,)
11476    {
11477        #[inline]
11478        unsafe fn encode(
11479            self,
11480            encoder: &mut fidl::encoding::Encoder<
11481                '_,
11482                fidl::encoding::DefaultFuchsiaResourceDialect,
11483            >,
11484            offset: usize,
11485            depth: fidl::encoding::Depth,
11486        ) -> fidl::Result<()> {
11487            encoder.debug_check_bounds::<ConnectionRequestGattClientRequest>(offset);
11488            // Zero out padding regions. There's no need to apply masks
11489            // because the unmasked parts will be overwritten by fields.
11490            // Write the fields.
11491            self.0.encode(encoder, offset + 0, depth)?;
11492            Ok(())
11493        }
11494    }
11495
11496    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11497        for ConnectionRequestGattClientRequest
11498    {
11499        #[inline(always)]
11500        fn new_empty() -> Self {
11501            Self {
11502                client: fidl::new_empty!(
11503                    fidl::encoding::Endpoint<
11504                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
11505                    >,
11506                    fidl::encoding::DefaultFuchsiaResourceDialect
11507                ),
11508            }
11509        }
11510
11511        #[inline]
11512        unsafe fn decode(
11513            &mut self,
11514            decoder: &mut fidl::encoding::Decoder<
11515                '_,
11516                fidl::encoding::DefaultFuchsiaResourceDialect,
11517            >,
11518            offset: usize,
11519            _depth: fidl::encoding::Depth,
11520        ) -> fidl::Result<()> {
11521            decoder.debug_check_bounds::<Self>(offset);
11522            // Verify that padding bytes are zero.
11523            fidl::decode!(
11524                fidl::encoding::Endpoint<
11525                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
11526                >,
11527                fidl::encoding::DefaultFuchsiaResourceDialect,
11528                &mut self.client,
11529                decoder,
11530                offset + 0,
11531                _depth
11532            )?;
11533            Ok(())
11534        }
11535    }
11536
11537    impl fidl::encoding::ResourceTypeMarker for PeripheralAdvertiseRequest {
11538        type Borrowed<'a> = &'a mut Self;
11539        fn take_or_borrow<'a>(
11540            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11541        ) -> Self::Borrowed<'a> {
11542            value
11543        }
11544    }
11545
11546    unsafe impl fidl::encoding::TypeMarker for PeripheralAdvertiseRequest {
11547        type Owned = Self;
11548
11549        #[inline(always)]
11550        fn inline_align(_context: fidl::encoding::Context) -> usize {
11551            8
11552        }
11553
11554        #[inline(always)]
11555        fn inline_size(_context: fidl::encoding::Context) -> usize {
11556            24
11557        }
11558    }
11559
11560    unsafe impl
11561        fidl::encoding::Encode<
11562            PeripheralAdvertiseRequest,
11563            fidl::encoding::DefaultFuchsiaResourceDialect,
11564        > for &mut PeripheralAdvertiseRequest
11565    {
11566        #[inline]
11567        unsafe fn encode(
11568            self,
11569            encoder: &mut fidl::encoding::Encoder<
11570                '_,
11571                fidl::encoding::DefaultFuchsiaResourceDialect,
11572            >,
11573            offset: usize,
11574            _depth: fidl::encoding::Depth,
11575        ) -> fidl::Result<()> {
11576            encoder.debug_check_bounds::<PeripheralAdvertiseRequest>(offset);
11577            // Delegate to tuple encoding.
11578            fidl::encoding::Encode::<
11579                PeripheralAdvertiseRequest,
11580                fidl::encoding::DefaultFuchsiaResourceDialect,
11581            >::encode(
11582                (
11583                    <AdvertisingParameters as fidl::encoding::ValueTypeMarker>::borrow(
11584                        &self.parameters,
11585                    ),
11586                    <fidl::encoding::Endpoint<
11587                        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
11588                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11589                        &mut self.advertised_peripheral,
11590                    ),
11591                ),
11592                encoder,
11593                offset,
11594                _depth,
11595            )
11596        }
11597    }
11598    unsafe impl<
11599        T0: fidl::encoding::Encode<
11600                AdvertisingParameters,
11601                fidl::encoding::DefaultFuchsiaResourceDialect,
11602            >,
11603        T1: fidl::encoding::Encode<
11604                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>>,
11605                fidl::encoding::DefaultFuchsiaResourceDialect,
11606            >,
11607    >
11608        fidl::encoding::Encode<
11609            PeripheralAdvertiseRequest,
11610            fidl::encoding::DefaultFuchsiaResourceDialect,
11611        > for (T0, T1)
11612    {
11613        #[inline]
11614        unsafe fn encode(
11615            self,
11616            encoder: &mut fidl::encoding::Encoder<
11617                '_,
11618                fidl::encoding::DefaultFuchsiaResourceDialect,
11619            >,
11620            offset: usize,
11621            depth: fidl::encoding::Depth,
11622        ) -> fidl::Result<()> {
11623            encoder.debug_check_bounds::<PeripheralAdvertiseRequest>(offset);
11624            // Zero out padding regions. There's no need to apply masks
11625            // because the unmasked parts will be overwritten by fields.
11626            unsafe {
11627                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
11628                (ptr as *mut u64).write_unaligned(0);
11629            }
11630            // Write the fields.
11631            self.0.encode(encoder, offset + 0, depth)?;
11632            self.1.encode(encoder, offset + 16, depth)?;
11633            Ok(())
11634        }
11635    }
11636
11637    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11638        for PeripheralAdvertiseRequest
11639    {
11640        #[inline(always)]
11641        fn new_empty() -> Self {
11642            Self {
11643                parameters: fidl::new_empty!(
11644                    AdvertisingParameters,
11645                    fidl::encoding::DefaultFuchsiaResourceDialect
11646                ),
11647                advertised_peripheral: fidl::new_empty!(
11648                    fidl::encoding::Endpoint<
11649                        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
11650                    >,
11651                    fidl::encoding::DefaultFuchsiaResourceDialect
11652                ),
11653            }
11654        }
11655
11656        #[inline]
11657        unsafe fn decode(
11658            &mut self,
11659            decoder: &mut fidl::encoding::Decoder<
11660                '_,
11661                fidl::encoding::DefaultFuchsiaResourceDialect,
11662            >,
11663            offset: usize,
11664            _depth: fidl::encoding::Depth,
11665        ) -> fidl::Result<()> {
11666            decoder.debug_check_bounds::<Self>(offset);
11667            // Verify that padding bytes are zero.
11668            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
11669            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11670            let mask = 0xffffffff00000000u64;
11671            let maskedval = padval & mask;
11672            if maskedval != 0 {
11673                return Err(fidl::Error::NonZeroPadding {
11674                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
11675                });
11676            }
11677            fidl::decode!(
11678                AdvertisingParameters,
11679                fidl::encoding::DefaultFuchsiaResourceDialect,
11680                &mut self.parameters,
11681                decoder,
11682                offset + 0,
11683                _depth
11684            )?;
11685            fidl::decode!(
11686                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>>,
11687                fidl::encoding::DefaultFuchsiaResourceDialect,
11688                &mut self.advertised_peripheral,
11689                decoder,
11690                offset + 16,
11691                _depth
11692            )?;
11693            Ok(())
11694        }
11695    }
11696
11697    impl fidl::encoding::ResourceTypeMarker for PeripheralOnPeerConnectedRequest {
11698        type Borrowed<'a> = &'a mut Self;
11699        fn take_or_borrow<'a>(
11700            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11701        ) -> Self::Borrowed<'a> {
11702            value
11703        }
11704    }
11705
11706    unsafe impl fidl::encoding::TypeMarker for PeripheralOnPeerConnectedRequest {
11707        type Owned = Self;
11708
11709        #[inline(always)]
11710        fn inline_align(_context: fidl::encoding::Context) -> usize {
11711            8
11712        }
11713
11714        #[inline(always)]
11715        fn inline_size(_context: fidl::encoding::Context) -> usize {
11716            24
11717        }
11718    }
11719
11720    unsafe impl
11721        fidl::encoding::Encode<
11722            PeripheralOnPeerConnectedRequest,
11723            fidl::encoding::DefaultFuchsiaResourceDialect,
11724        > for &mut PeripheralOnPeerConnectedRequest
11725    {
11726        #[inline]
11727        unsafe fn encode(
11728            self,
11729            encoder: &mut fidl::encoding::Encoder<
11730                '_,
11731                fidl::encoding::DefaultFuchsiaResourceDialect,
11732            >,
11733            offset: usize,
11734            _depth: fidl::encoding::Depth,
11735        ) -> fidl::Result<()> {
11736            encoder.debug_check_bounds::<PeripheralOnPeerConnectedRequest>(offset);
11737            // Delegate to tuple encoding.
11738            fidl::encoding::Encode::<PeripheralOnPeerConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
11739                (
11740                    <Peer as fidl::encoding::ValueTypeMarker>::borrow(&self.peer),
11741                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.connection),
11742                ),
11743                encoder, offset, _depth
11744            )
11745        }
11746    }
11747    unsafe impl<
11748        T0: fidl::encoding::Encode<Peer, fidl::encoding::DefaultFuchsiaResourceDialect>,
11749        T1: fidl::encoding::Encode<
11750                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
11751                fidl::encoding::DefaultFuchsiaResourceDialect,
11752            >,
11753    >
11754        fidl::encoding::Encode<
11755            PeripheralOnPeerConnectedRequest,
11756            fidl::encoding::DefaultFuchsiaResourceDialect,
11757        > for (T0, T1)
11758    {
11759        #[inline]
11760        unsafe fn encode(
11761            self,
11762            encoder: &mut fidl::encoding::Encoder<
11763                '_,
11764                fidl::encoding::DefaultFuchsiaResourceDialect,
11765            >,
11766            offset: usize,
11767            depth: fidl::encoding::Depth,
11768        ) -> fidl::Result<()> {
11769            encoder.debug_check_bounds::<PeripheralOnPeerConnectedRequest>(offset);
11770            // Zero out padding regions. There's no need to apply masks
11771            // because the unmasked parts will be overwritten by fields.
11772            unsafe {
11773                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
11774                (ptr as *mut u64).write_unaligned(0);
11775            }
11776            // Write the fields.
11777            self.0.encode(encoder, offset + 0, depth)?;
11778            self.1.encode(encoder, offset + 16, depth)?;
11779            Ok(())
11780        }
11781    }
11782
11783    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11784        for PeripheralOnPeerConnectedRequest
11785    {
11786        #[inline(always)]
11787        fn new_empty() -> Self {
11788            Self {
11789                peer: fidl::new_empty!(Peer, fidl::encoding::DefaultFuchsiaResourceDialect),
11790                connection: fidl::new_empty!(
11791                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
11792                    fidl::encoding::DefaultFuchsiaResourceDialect
11793                ),
11794            }
11795        }
11796
11797        #[inline]
11798        unsafe fn decode(
11799            &mut self,
11800            decoder: &mut fidl::encoding::Decoder<
11801                '_,
11802                fidl::encoding::DefaultFuchsiaResourceDialect,
11803            >,
11804            offset: usize,
11805            _depth: fidl::encoding::Depth,
11806        ) -> fidl::Result<()> {
11807            decoder.debug_check_bounds::<Self>(offset);
11808            // Verify that padding bytes are zero.
11809            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
11810            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11811            let mask = 0xffffffff00000000u64;
11812            let maskedval = padval & mask;
11813            if maskedval != 0 {
11814                return Err(fidl::Error::NonZeroPadding {
11815                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
11816                });
11817            }
11818            fidl::decode!(
11819                Peer,
11820                fidl::encoding::DefaultFuchsiaResourceDialect,
11821                &mut self.peer,
11822                decoder,
11823                offset + 0,
11824                _depth
11825            )?;
11826            fidl::decode!(
11827                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
11828                fidl::encoding::DefaultFuchsiaResourceDialect,
11829                &mut self.connection,
11830                decoder,
11831                offset + 16,
11832                _depth
11833            )?;
11834            Ok(())
11835        }
11836    }
11837
11838    impl fidl::encoding::ResourceTypeMarker for PeripheralStartAdvertisingRequest {
11839        type Borrowed<'a> = &'a mut Self;
11840        fn take_or_borrow<'a>(
11841            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11842        ) -> Self::Borrowed<'a> {
11843            value
11844        }
11845    }
11846
11847    unsafe impl fidl::encoding::TypeMarker for PeripheralStartAdvertisingRequest {
11848        type Owned = Self;
11849
11850        #[inline(always)]
11851        fn inline_align(_context: fidl::encoding::Context) -> usize {
11852            8
11853        }
11854
11855        #[inline(always)]
11856        fn inline_size(_context: fidl::encoding::Context) -> usize {
11857            24
11858        }
11859    }
11860
11861    unsafe impl
11862        fidl::encoding::Encode<
11863            PeripheralStartAdvertisingRequest,
11864            fidl::encoding::DefaultFuchsiaResourceDialect,
11865        > for &mut PeripheralStartAdvertisingRequest
11866    {
11867        #[inline]
11868        unsafe fn encode(
11869            self,
11870            encoder: &mut fidl::encoding::Encoder<
11871                '_,
11872                fidl::encoding::DefaultFuchsiaResourceDialect,
11873            >,
11874            offset: usize,
11875            _depth: fidl::encoding::Depth,
11876        ) -> fidl::Result<()> {
11877            encoder.debug_check_bounds::<PeripheralStartAdvertisingRequest>(offset);
11878            // Delegate to tuple encoding.
11879            fidl::encoding::Encode::<PeripheralStartAdvertisingRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
11880                (
11881                    <AdvertisingParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.parameters),
11882                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
11883                ),
11884                encoder, offset, _depth
11885            )
11886        }
11887    }
11888    unsafe impl<
11889        T0: fidl::encoding::Encode<
11890                AdvertisingParameters,
11891                fidl::encoding::DefaultFuchsiaResourceDialect,
11892            >,
11893        T1: fidl::encoding::Encode<
11894                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
11895                fidl::encoding::DefaultFuchsiaResourceDialect,
11896            >,
11897    >
11898        fidl::encoding::Encode<
11899            PeripheralStartAdvertisingRequest,
11900            fidl::encoding::DefaultFuchsiaResourceDialect,
11901        > for (T0, T1)
11902    {
11903        #[inline]
11904        unsafe fn encode(
11905            self,
11906            encoder: &mut fidl::encoding::Encoder<
11907                '_,
11908                fidl::encoding::DefaultFuchsiaResourceDialect,
11909            >,
11910            offset: usize,
11911            depth: fidl::encoding::Depth,
11912        ) -> fidl::Result<()> {
11913            encoder.debug_check_bounds::<PeripheralStartAdvertisingRequest>(offset);
11914            // Zero out padding regions. There's no need to apply masks
11915            // because the unmasked parts will be overwritten by fields.
11916            unsafe {
11917                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
11918                (ptr as *mut u64).write_unaligned(0);
11919            }
11920            // Write the fields.
11921            self.0.encode(encoder, offset + 0, depth)?;
11922            self.1.encode(encoder, offset + 16, depth)?;
11923            Ok(())
11924        }
11925    }
11926
11927    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11928        for PeripheralStartAdvertisingRequest
11929    {
11930        #[inline(always)]
11931        fn new_empty() -> Self {
11932            Self {
11933                parameters: fidl::new_empty!(
11934                    AdvertisingParameters,
11935                    fidl::encoding::DefaultFuchsiaResourceDialect
11936                ),
11937                handle: fidl::new_empty!(
11938                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
11939                    fidl::encoding::DefaultFuchsiaResourceDialect
11940                ),
11941            }
11942        }
11943
11944        #[inline]
11945        unsafe fn decode(
11946            &mut self,
11947            decoder: &mut fidl::encoding::Decoder<
11948                '_,
11949                fidl::encoding::DefaultFuchsiaResourceDialect,
11950            >,
11951            offset: usize,
11952            _depth: fidl::encoding::Depth,
11953        ) -> fidl::Result<()> {
11954            decoder.debug_check_bounds::<Self>(offset);
11955            // Verify that padding bytes are zero.
11956            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
11957            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11958            let mask = 0xffffffff00000000u64;
11959            let maskedval = padval & mask;
11960            if maskedval != 0 {
11961                return Err(fidl::Error::NonZeroPadding {
11962                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
11963                });
11964            }
11965            fidl::decode!(
11966                AdvertisingParameters,
11967                fidl::encoding::DefaultFuchsiaResourceDialect,
11968                &mut self.parameters,
11969                decoder,
11970                offset + 0,
11971                _depth
11972            )?;
11973            fidl::decode!(
11974                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
11975                fidl::encoding::DefaultFuchsiaResourceDialect,
11976                &mut self.handle,
11977                decoder,
11978                offset + 16,
11979                _depth
11980            )?;
11981            Ok(())
11982        }
11983    }
11984
11985    impl CentralCreateConnectedIsochronousGroupRequest {
11986        #[inline(always)]
11987        fn max_ordinal_present(&self) -> u64 {
11988            if let Some(_) = self.cig {
11989                return 3;
11990            }
11991            if let Some(_) = self.cis_requested_parameters {
11992                return 2;
11993            }
11994            if let Some(_) = self.cig_parameters {
11995                return 1;
11996            }
11997            0
11998        }
11999    }
12000
12001    impl fidl::encoding::ResourceTypeMarker for CentralCreateConnectedIsochronousGroupRequest {
12002        type Borrowed<'a> = &'a mut Self;
12003        fn take_or_borrow<'a>(
12004            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12005        ) -> Self::Borrowed<'a> {
12006            value
12007        }
12008    }
12009
12010    unsafe impl fidl::encoding::TypeMarker for CentralCreateConnectedIsochronousGroupRequest {
12011        type Owned = Self;
12012
12013        #[inline(always)]
12014        fn inline_align(_context: fidl::encoding::Context) -> usize {
12015            8
12016        }
12017
12018        #[inline(always)]
12019        fn inline_size(_context: fidl::encoding::Context) -> usize {
12020            16
12021        }
12022    }
12023
12024    unsafe impl
12025        fidl::encoding::Encode<
12026            CentralCreateConnectedIsochronousGroupRequest,
12027            fidl::encoding::DefaultFuchsiaResourceDialect,
12028        > for &mut CentralCreateConnectedIsochronousGroupRequest
12029    {
12030        unsafe fn encode(
12031            self,
12032            encoder: &mut fidl::encoding::Encoder<
12033                '_,
12034                fidl::encoding::DefaultFuchsiaResourceDialect,
12035            >,
12036            offset: usize,
12037            mut depth: fidl::encoding::Depth,
12038        ) -> fidl::Result<()> {
12039            encoder.debug_check_bounds::<CentralCreateConnectedIsochronousGroupRequest>(offset);
12040            // Vector header
12041            let max_ordinal: u64 = self.max_ordinal_present();
12042            encoder.write_num(max_ordinal, offset);
12043            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12044            // Calling encoder.out_of_line_offset(0) is not allowed.
12045            if max_ordinal == 0 {
12046                return Ok(());
12047            }
12048            depth.increment()?;
12049            let envelope_size = 8;
12050            let bytes_len = max_ordinal as usize * envelope_size;
12051            #[allow(unused_variables)]
12052            let offset = encoder.out_of_line_offset(bytes_len);
12053            let mut _prev_end_offset: usize = 0;
12054            if 1 > max_ordinal {
12055                return Ok(());
12056            }
12057
12058            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12059            // are envelope_size bytes.
12060            let cur_offset: usize = (1 - 1) * envelope_size;
12061
12062            // Zero reserved fields.
12063            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12064
12065            // Safety:
12066            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12067            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12068            //   envelope_size bytes, there is always sufficient room.
12069            fidl::encoding::encode_in_envelope_optional::<
12070                CigParameters,
12071                fidl::encoding::DefaultFuchsiaResourceDialect,
12072            >(
12073                self.cig_parameters
12074                    .as_ref()
12075                    .map(<CigParameters as fidl::encoding::ValueTypeMarker>::borrow),
12076                encoder,
12077                offset + cur_offset,
12078                depth,
12079            )?;
12080
12081            _prev_end_offset = cur_offset + envelope_size;
12082            if 2 > max_ordinal {
12083                return Ok(());
12084            }
12085
12086            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12087            // are envelope_size bytes.
12088            let cur_offset: usize = (2 - 1) * envelope_size;
12089
12090            // Zero reserved fields.
12091            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12092
12093            // Safety:
12094            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12095            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12096            //   envelope_size bytes, there is always sufficient room.
12097            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect>(
12098            self.cis_requested_parameters.as_mut().map(<fidl::encoding::Vector<CisRequestedParameters, 31> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
12099            encoder, offset + cur_offset, depth
12100        )?;
12101
12102            _prev_end_offset = cur_offset + envelope_size;
12103            if 3 > max_ordinal {
12104                return Ok(());
12105            }
12106
12107            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12108            // are envelope_size bytes.
12109            let cur_offset: usize = (3 - 1) * envelope_size;
12110
12111            // Zero reserved fields.
12112            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12113
12114            // Safety:
12115            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12116            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12117            //   envelope_size bytes, there is always sufficient room.
12118            fidl::encoding::encode_in_envelope_optional::<
12119                fidl::encoding::Endpoint<
12120                    fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
12121                >,
12122                fidl::encoding::DefaultFuchsiaResourceDialect,
12123            >(
12124                self.cig.as_mut().map(
12125                    <fidl::encoding::Endpoint<
12126                        fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
12127                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12128                ),
12129                encoder,
12130                offset + cur_offset,
12131                depth,
12132            )?;
12133
12134            _prev_end_offset = cur_offset + envelope_size;
12135
12136            Ok(())
12137        }
12138    }
12139
12140    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12141        for CentralCreateConnectedIsochronousGroupRequest
12142    {
12143        #[inline(always)]
12144        fn new_empty() -> Self {
12145            Self::default()
12146        }
12147
12148        unsafe fn decode(
12149            &mut self,
12150            decoder: &mut fidl::encoding::Decoder<
12151                '_,
12152                fidl::encoding::DefaultFuchsiaResourceDialect,
12153            >,
12154            offset: usize,
12155            mut depth: fidl::encoding::Depth,
12156        ) -> fidl::Result<()> {
12157            decoder.debug_check_bounds::<Self>(offset);
12158            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12159                None => return Err(fidl::Error::NotNullable),
12160                Some(len) => len,
12161            };
12162            // Calling decoder.out_of_line_offset(0) is not allowed.
12163            if len == 0 {
12164                return Ok(());
12165            };
12166            depth.increment()?;
12167            let envelope_size = 8;
12168            let bytes_len = len * envelope_size;
12169            let offset = decoder.out_of_line_offset(bytes_len)?;
12170            // Decode the envelope for each type.
12171            let mut _next_ordinal_to_read = 0;
12172            let mut next_offset = offset;
12173            let end_offset = offset + bytes_len;
12174            _next_ordinal_to_read += 1;
12175            if next_offset >= end_offset {
12176                return Ok(());
12177            }
12178
12179            // Decode unknown envelopes for gaps in ordinals.
12180            while _next_ordinal_to_read < 1 {
12181                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12182                _next_ordinal_to_read += 1;
12183                next_offset += envelope_size;
12184            }
12185
12186            let next_out_of_line = decoder.next_out_of_line();
12187            let handles_before = decoder.remaining_handles();
12188            if let Some((inlined, num_bytes, num_handles)) =
12189                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12190            {
12191                let member_inline_size =
12192                    <CigParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12193                if inlined != (member_inline_size <= 4) {
12194                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12195                }
12196                let inner_offset;
12197                let mut inner_depth = depth.clone();
12198                if inlined {
12199                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12200                    inner_offset = next_offset;
12201                } else {
12202                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12203                    inner_depth.increment()?;
12204                }
12205                let val_ref = self.cig_parameters.get_or_insert_with(|| {
12206                    fidl::new_empty!(CigParameters, fidl::encoding::DefaultFuchsiaResourceDialect)
12207                });
12208                fidl::decode!(
12209                    CigParameters,
12210                    fidl::encoding::DefaultFuchsiaResourceDialect,
12211                    val_ref,
12212                    decoder,
12213                    inner_offset,
12214                    inner_depth
12215                )?;
12216                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12217                {
12218                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12219                }
12220                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12221                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12222                }
12223            }
12224
12225            next_offset += envelope_size;
12226            _next_ordinal_to_read += 1;
12227            if next_offset >= end_offset {
12228                return Ok(());
12229            }
12230
12231            // Decode unknown envelopes for gaps in ordinals.
12232            while _next_ordinal_to_read < 2 {
12233                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12234                _next_ordinal_to_read += 1;
12235                next_offset += envelope_size;
12236            }
12237
12238            let next_out_of_line = decoder.next_out_of_line();
12239            let handles_before = decoder.remaining_handles();
12240            if let Some((inlined, num_bytes, num_handles)) =
12241                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12242            {
12243                let member_inline_size = <fidl::encoding::Vector<CisRequestedParameters, 31> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12244                if inlined != (member_inline_size <= 4) {
12245                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12246                }
12247                let inner_offset;
12248                let mut inner_depth = depth.clone();
12249                if inlined {
12250                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12251                    inner_offset = next_offset;
12252                } else {
12253                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12254                    inner_depth.increment()?;
12255                }
12256                let val_ref =
12257                self.cis_requested_parameters.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect));
12258                fidl::decode!(fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12259                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12260                {
12261                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12262                }
12263                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12264                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12265                }
12266            }
12267
12268            next_offset += envelope_size;
12269            _next_ordinal_to_read += 1;
12270            if next_offset >= end_offset {
12271                return Ok(());
12272            }
12273
12274            // Decode unknown envelopes for gaps in ordinals.
12275            while _next_ordinal_to_read < 3 {
12276                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12277                _next_ordinal_to_read += 1;
12278                next_offset += envelope_size;
12279            }
12280
12281            let next_out_of_line = decoder.next_out_of_line();
12282            let handles_before = decoder.remaining_handles();
12283            if let Some((inlined, num_bytes, num_handles)) =
12284                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12285            {
12286                let member_inline_size = <fidl::encoding::Endpoint<
12287                    fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
12288                > as fidl::encoding::TypeMarker>::inline_size(
12289                    decoder.context
12290                );
12291                if inlined != (member_inline_size <= 4) {
12292                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12293                }
12294                let inner_offset;
12295                let mut inner_depth = depth.clone();
12296                if inlined {
12297                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12298                    inner_offset = next_offset;
12299                } else {
12300                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12301                    inner_depth.increment()?;
12302                }
12303                let val_ref = self.cig.get_or_insert_with(|| {
12304                    fidl::new_empty!(
12305                        fidl::encoding::Endpoint<
12306                            fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
12307                        >,
12308                        fidl::encoding::DefaultFuchsiaResourceDialect
12309                    )
12310                });
12311                fidl::decode!(
12312                    fidl::encoding::Endpoint<
12313                        fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
12314                    >,
12315                    fidl::encoding::DefaultFuchsiaResourceDialect,
12316                    val_ref,
12317                    decoder,
12318                    inner_offset,
12319                    inner_depth
12320                )?;
12321                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12322                {
12323                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12324                }
12325                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12326                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12327                }
12328            }
12329
12330            next_offset += envelope_size;
12331
12332            // Decode the remaining unknown envelopes.
12333            while next_offset < end_offset {
12334                _next_ordinal_to_read += 1;
12335                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12336                next_offset += envelope_size;
12337            }
12338
12339            Ok(())
12340        }
12341    }
12342
12343    impl CentralSyncToPeriodicAdvertisingRequest {
12344        #[inline(always)]
12345        fn max_ordinal_present(&self) -> u64 {
12346            if let Some(_) = self.config {
12347                return 4;
12348            }
12349            if let Some(_) = self.sync {
12350                return 3;
12351            }
12352            if let Some(_) = self.advertising_sid {
12353                return 2;
12354            }
12355            if let Some(_) = self.peer_id {
12356                return 1;
12357            }
12358            0
12359        }
12360    }
12361
12362    impl fidl::encoding::ResourceTypeMarker for CentralSyncToPeriodicAdvertisingRequest {
12363        type Borrowed<'a> = &'a mut Self;
12364        fn take_or_borrow<'a>(
12365            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12366        ) -> Self::Borrowed<'a> {
12367            value
12368        }
12369    }
12370
12371    unsafe impl fidl::encoding::TypeMarker for CentralSyncToPeriodicAdvertisingRequest {
12372        type Owned = Self;
12373
12374        #[inline(always)]
12375        fn inline_align(_context: fidl::encoding::Context) -> usize {
12376            8
12377        }
12378
12379        #[inline(always)]
12380        fn inline_size(_context: fidl::encoding::Context) -> usize {
12381            16
12382        }
12383    }
12384
12385    unsafe impl
12386        fidl::encoding::Encode<
12387            CentralSyncToPeriodicAdvertisingRequest,
12388            fidl::encoding::DefaultFuchsiaResourceDialect,
12389        > for &mut CentralSyncToPeriodicAdvertisingRequest
12390    {
12391        unsafe fn encode(
12392            self,
12393            encoder: &mut fidl::encoding::Encoder<
12394                '_,
12395                fidl::encoding::DefaultFuchsiaResourceDialect,
12396            >,
12397            offset: usize,
12398            mut depth: fidl::encoding::Depth,
12399        ) -> fidl::Result<()> {
12400            encoder.debug_check_bounds::<CentralSyncToPeriodicAdvertisingRequest>(offset);
12401            // Vector header
12402            let max_ordinal: u64 = self.max_ordinal_present();
12403            encoder.write_num(max_ordinal, offset);
12404            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12405            // Calling encoder.out_of_line_offset(0) is not allowed.
12406            if max_ordinal == 0 {
12407                return Ok(());
12408            }
12409            depth.increment()?;
12410            let envelope_size = 8;
12411            let bytes_len = max_ordinal as usize * envelope_size;
12412            #[allow(unused_variables)]
12413            let offset = encoder.out_of_line_offset(bytes_len);
12414            let mut _prev_end_offset: usize = 0;
12415            if 1 > max_ordinal {
12416                return Ok(());
12417            }
12418
12419            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12420            // are envelope_size bytes.
12421            let cur_offset: usize = (1 - 1) * envelope_size;
12422
12423            // Zero reserved fields.
12424            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12425
12426            // Safety:
12427            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12428            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12429            //   envelope_size bytes, there is always sufficient room.
12430            fidl::encoding::encode_in_envelope_optional::<
12431                fidl_fuchsia_bluetooth::PeerId,
12432                fidl::encoding::DefaultFuchsiaResourceDialect,
12433            >(
12434                self.peer_id.as_ref().map(
12435                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow,
12436                ),
12437                encoder,
12438                offset + cur_offset,
12439                depth,
12440            )?;
12441
12442            _prev_end_offset = cur_offset + envelope_size;
12443            if 2 > max_ordinal {
12444                return Ok(());
12445            }
12446
12447            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12448            // are envelope_size bytes.
12449            let cur_offset: usize = (2 - 1) * envelope_size;
12450
12451            // Zero reserved fields.
12452            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12453
12454            // Safety:
12455            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12456            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12457            //   envelope_size bytes, there is always sufficient room.
12458            fidl::encoding::encode_in_envelope_optional::<
12459                u8,
12460                fidl::encoding::DefaultFuchsiaResourceDialect,
12461            >(
12462                self.advertising_sid.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
12463                encoder,
12464                offset + cur_offset,
12465                depth,
12466            )?;
12467
12468            _prev_end_offset = cur_offset + envelope_size;
12469            if 3 > max_ordinal {
12470                return Ok(());
12471            }
12472
12473            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12474            // are envelope_size bytes.
12475            let cur_offset: usize = (3 - 1) * envelope_size;
12476
12477            // Zero reserved fields.
12478            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12479
12480            // Safety:
12481            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12482            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12483            //   envelope_size bytes, there is always sufficient room.
12484            fidl::encoding::encode_in_envelope_optional::<
12485                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>>,
12486                fidl::encoding::DefaultFuchsiaResourceDialect,
12487            >(
12488                self.sync.as_mut().map(
12489                    <fidl::encoding::Endpoint<
12490                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
12491                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12492                ),
12493                encoder,
12494                offset + cur_offset,
12495                depth,
12496            )?;
12497
12498            _prev_end_offset = cur_offset + envelope_size;
12499            if 4 > max_ordinal {
12500                return Ok(());
12501            }
12502
12503            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12504            // are envelope_size bytes.
12505            let cur_offset: usize = (4 - 1) * envelope_size;
12506
12507            // Zero reserved fields.
12508            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12509
12510            // Safety:
12511            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12512            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12513            //   envelope_size bytes, there is always sufficient room.
12514            fidl::encoding::encode_in_envelope_optional::<PeriodicAdvertisingSyncConfiguration, fidl::encoding::DefaultFuchsiaResourceDialect>(
12515            self.config.as_ref().map(<PeriodicAdvertisingSyncConfiguration as fidl::encoding::ValueTypeMarker>::borrow),
12516            encoder, offset + cur_offset, depth
12517        )?;
12518
12519            _prev_end_offset = cur_offset + envelope_size;
12520
12521            Ok(())
12522        }
12523    }
12524
12525    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12526        for CentralSyncToPeriodicAdvertisingRequest
12527    {
12528        #[inline(always)]
12529        fn new_empty() -> Self {
12530            Self::default()
12531        }
12532
12533        unsafe fn decode(
12534            &mut self,
12535            decoder: &mut fidl::encoding::Decoder<
12536                '_,
12537                fidl::encoding::DefaultFuchsiaResourceDialect,
12538            >,
12539            offset: usize,
12540            mut depth: fidl::encoding::Depth,
12541        ) -> fidl::Result<()> {
12542            decoder.debug_check_bounds::<Self>(offset);
12543            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12544                None => return Err(fidl::Error::NotNullable),
12545                Some(len) => len,
12546            };
12547            // Calling decoder.out_of_line_offset(0) is not allowed.
12548            if len == 0 {
12549                return Ok(());
12550            };
12551            depth.increment()?;
12552            let envelope_size = 8;
12553            let bytes_len = len * envelope_size;
12554            let offset = decoder.out_of_line_offset(bytes_len)?;
12555            // Decode the envelope for each type.
12556            let mut _next_ordinal_to_read = 0;
12557            let mut next_offset = offset;
12558            let end_offset = offset + bytes_len;
12559            _next_ordinal_to_read += 1;
12560            if next_offset >= end_offset {
12561                return Ok(());
12562            }
12563
12564            // Decode unknown envelopes for gaps in ordinals.
12565            while _next_ordinal_to_read < 1 {
12566                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12567                _next_ordinal_to_read += 1;
12568                next_offset += envelope_size;
12569            }
12570
12571            let next_out_of_line = decoder.next_out_of_line();
12572            let handles_before = decoder.remaining_handles();
12573            if let Some((inlined, num_bytes, num_handles)) =
12574                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12575            {
12576                let member_inline_size =
12577                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::TypeMarker>::inline_size(
12578                        decoder.context,
12579                    );
12580                if inlined != (member_inline_size <= 4) {
12581                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12582                }
12583                let inner_offset;
12584                let mut inner_depth = depth.clone();
12585                if inlined {
12586                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12587                    inner_offset = next_offset;
12588                } else {
12589                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12590                    inner_depth.increment()?;
12591                }
12592                let val_ref = self.peer_id.get_or_insert_with(|| {
12593                    fidl::new_empty!(
12594                        fidl_fuchsia_bluetooth::PeerId,
12595                        fidl::encoding::DefaultFuchsiaResourceDialect
12596                    )
12597                });
12598                fidl::decode!(
12599                    fidl_fuchsia_bluetooth::PeerId,
12600                    fidl::encoding::DefaultFuchsiaResourceDialect,
12601                    val_ref,
12602                    decoder,
12603                    inner_offset,
12604                    inner_depth
12605                )?;
12606                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12607                {
12608                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12609                }
12610                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12611                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12612                }
12613            }
12614
12615            next_offset += envelope_size;
12616            _next_ordinal_to_read += 1;
12617            if next_offset >= end_offset {
12618                return Ok(());
12619            }
12620
12621            // Decode unknown envelopes for gaps in ordinals.
12622            while _next_ordinal_to_read < 2 {
12623                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12624                _next_ordinal_to_read += 1;
12625                next_offset += envelope_size;
12626            }
12627
12628            let next_out_of_line = decoder.next_out_of_line();
12629            let handles_before = decoder.remaining_handles();
12630            if let Some((inlined, num_bytes, num_handles)) =
12631                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12632            {
12633                let member_inline_size =
12634                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12635                if inlined != (member_inline_size <= 4) {
12636                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12637                }
12638                let inner_offset;
12639                let mut inner_depth = depth.clone();
12640                if inlined {
12641                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12642                    inner_offset = next_offset;
12643                } else {
12644                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12645                    inner_depth.increment()?;
12646                }
12647                let val_ref = self.advertising_sid.get_or_insert_with(|| {
12648                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
12649                });
12650                fidl::decode!(
12651                    u8,
12652                    fidl::encoding::DefaultFuchsiaResourceDialect,
12653                    val_ref,
12654                    decoder,
12655                    inner_offset,
12656                    inner_depth
12657                )?;
12658                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12659                {
12660                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12661                }
12662                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12663                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12664                }
12665            }
12666
12667            next_offset += envelope_size;
12668            _next_ordinal_to_read += 1;
12669            if next_offset >= end_offset {
12670                return Ok(());
12671            }
12672
12673            // Decode unknown envelopes for gaps in ordinals.
12674            while _next_ordinal_to_read < 3 {
12675                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12676                _next_ordinal_to_read += 1;
12677                next_offset += envelope_size;
12678            }
12679
12680            let next_out_of_line = decoder.next_out_of_line();
12681            let handles_before = decoder.remaining_handles();
12682            if let Some((inlined, num_bytes, num_handles)) =
12683                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12684            {
12685                let member_inline_size = <fidl::encoding::Endpoint<
12686                    fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
12687                > as fidl::encoding::TypeMarker>::inline_size(
12688                    decoder.context
12689                );
12690                if inlined != (member_inline_size <= 4) {
12691                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12692                }
12693                let inner_offset;
12694                let mut inner_depth = depth.clone();
12695                if inlined {
12696                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12697                    inner_offset = next_offset;
12698                } else {
12699                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12700                    inner_depth.increment()?;
12701                }
12702                let val_ref = self.sync.get_or_insert_with(|| {
12703                    fidl::new_empty!(
12704                        fidl::encoding::Endpoint<
12705                            fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
12706                        >,
12707                        fidl::encoding::DefaultFuchsiaResourceDialect
12708                    )
12709                });
12710                fidl::decode!(
12711                    fidl::encoding::Endpoint<
12712                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
12713                    >,
12714                    fidl::encoding::DefaultFuchsiaResourceDialect,
12715                    val_ref,
12716                    decoder,
12717                    inner_offset,
12718                    inner_depth
12719                )?;
12720                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12721                {
12722                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12723                }
12724                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12725                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12726                }
12727            }
12728
12729            next_offset += envelope_size;
12730            _next_ordinal_to_read += 1;
12731            if next_offset >= end_offset {
12732                return Ok(());
12733            }
12734
12735            // Decode unknown envelopes for gaps in ordinals.
12736            while _next_ordinal_to_read < 4 {
12737                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12738                _next_ordinal_to_read += 1;
12739                next_offset += envelope_size;
12740            }
12741
12742            let next_out_of_line = decoder.next_out_of_line();
12743            let handles_before = decoder.remaining_handles();
12744            if let Some((inlined, num_bytes, num_handles)) =
12745                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12746            {
12747                let member_inline_size = <PeriodicAdvertisingSyncConfiguration as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12748                if inlined != (member_inline_size <= 4) {
12749                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12750                }
12751                let inner_offset;
12752                let mut inner_depth = depth.clone();
12753                if inlined {
12754                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12755                    inner_offset = next_offset;
12756                } else {
12757                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12758                    inner_depth.increment()?;
12759                }
12760                let val_ref = self.config.get_or_insert_with(|| {
12761                    fidl::new_empty!(
12762                        PeriodicAdvertisingSyncConfiguration,
12763                        fidl::encoding::DefaultFuchsiaResourceDialect
12764                    )
12765                });
12766                fidl::decode!(
12767                    PeriodicAdvertisingSyncConfiguration,
12768                    fidl::encoding::DefaultFuchsiaResourceDialect,
12769                    val_ref,
12770                    decoder,
12771                    inner_offset,
12772                    inner_depth
12773                )?;
12774                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12775                {
12776                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12777                }
12778                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12779                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12780                }
12781            }
12782
12783            next_offset += envelope_size;
12784
12785            // Decode the remaining unknown envelopes.
12786            while next_offset < end_offset {
12787                _next_ordinal_to_read += 1;
12788                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12789                next_offset += envelope_size;
12790            }
12791
12792            Ok(())
12793        }
12794    }
12795
12796    impl ChannelListenerRegistryListenL2capRequest {
12797        #[inline(always)]
12798        fn max_ordinal_present(&self) -> u64 {
12799            if let Some(_) = self.listener {
12800                return 2;
12801            }
12802            if let Some(_) = self.parameters {
12803                return 1;
12804            }
12805            0
12806        }
12807    }
12808
12809    impl fidl::encoding::ResourceTypeMarker for ChannelListenerRegistryListenL2capRequest {
12810        type Borrowed<'a> = &'a mut Self;
12811        fn take_or_borrow<'a>(
12812            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12813        ) -> Self::Borrowed<'a> {
12814            value
12815        }
12816    }
12817
12818    unsafe impl fidl::encoding::TypeMarker for ChannelListenerRegistryListenL2capRequest {
12819        type Owned = Self;
12820
12821        #[inline(always)]
12822        fn inline_align(_context: fidl::encoding::Context) -> usize {
12823            8
12824        }
12825
12826        #[inline(always)]
12827        fn inline_size(_context: fidl::encoding::Context) -> usize {
12828            16
12829        }
12830    }
12831
12832    unsafe impl
12833        fidl::encoding::Encode<
12834            ChannelListenerRegistryListenL2capRequest,
12835            fidl::encoding::DefaultFuchsiaResourceDialect,
12836        > for &mut ChannelListenerRegistryListenL2capRequest
12837    {
12838        unsafe fn encode(
12839            self,
12840            encoder: &mut fidl::encoding::Encoder<
12841                '_,
12842                fidl::encoding::DefaultFuchsiaResourceDialect,
12843            >,
12844            offset: usize,
12845            mut depth: fidl::encoding::Depth,
12846        ) -> fidl::Result<()> {
12847            encoder.debug_check_bounds::<ChannelListenerRegistryListenL2capRequest>(offset);
12848            // Vector header
12849            let max_ordinal: u64 = self.max_ordinal_present();
12850            encoder.write_num(max_ordinal, offset);
12851            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12852            // Calling encoder.out_of_line_offset(0) is not allowed.
12853            if max_ordinal == 0 {
12854                return Ok(());
12855            }
12856            depth.increment()?;
12857            let envelope_size = 8;
12858            let bytes_len = max_ordinal as usize * envelope_size;
12859            #[allow(unused_variables)]
12860            let offset = encoder.out_of_line_offset(bytes_len);
12861            let mut _prev_end_offset: usize = 0;
12862            if 1 > max_ordinal {
12863                return Ok(());
12864            }
12865
12866            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12867            // are envelope_size bytes.
12868            let cur_offset: usize = (1 - 1) * envelope_size;
12869
12870            // Zero reserved fields.
12871            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12872
12873            // Safety:
12874            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12875            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12876            //   envelope_size bytes, there is always sufficient room.
12877            fidl::encoding::encode_in_envelope_optional::<
12878                AcceptedChannelParameters,
12879                fidl::encoding::DefaultFuchsiaResourceDialect,
12880            >(
12881                self.parameters
12882                    .as_ref()
12883                    .map(<AcceptedChannelParameters as fidl::encoding::ValueTypeMarker>::borrow),
12884                encoder,
12885                offset + cur_offset,
12886                depth,
12887            )?;
12888
12889            _prev_end_offset = cur_offset + envelope_size;
12890            if 2 > max_ordinal {
12891                return Ok(());
12892            }
12893
12894            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12895            // are envelope_size bytes.
12896            let cur_offset: usize = (2 - 1) * envelope_size;
12897
12898            // Zero reserved fields.
12899            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12900
12901            // Safety:
12902            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12903            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12904            //   envelope_size bytes, there is always sufficient room.
12905            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
12906            self.listener.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
12907            encoder, offset + cur_offset, depth
12908        )?;
12909
12910            _prev_end_offset = cur_offset + envelope_size;
12911
12912            Ok(())
12913        }
12914    }
12915
12916    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12917        for ChannelListenerRegistryListenL2capRequest
12918    {
12919        #[inline(always)]
12920        fn new_empty() -> Self {
12921            Self::default()
12922        }
12923
12924        unsafe fn decode(
12925            &mut self,
12926            decoder: &mut fidl::encoding::Decoder<
12927                '_,
12928                fidl::encoding::DefaultFuchsiaResourceDialect,
12929            >,
12930            offset: usize,
12931            mut depth: fidl::encoding::Depth,
12932        ) -> fidl::Result<()> {
12933            decoder.debug_check_bounds::<Self>(offset);
12934            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12935                None => return Err(fidl::Error::NotNullable),
12936                Some(len) => len,
12937            };
12938            // Calling decoder.out_of_line_offset(0) is not allowed.
12939            if len == 0 {
12940                return Ok(());
12941            };
12942            depth.increment()?;
12943            let envelope_size = 8;
12944            let bytes_len = len * envelope_size;
12945            let offset = decoder.out_of_line_offset(bytes_len)?;
12946            // Decode the envelope for each type.
12947            let mut _next_ordinal_to_read = 0;
12948            let mut next_offset = offset;
12949            let end_offset = offset + bytes_len;
12950            _next_ordinal_to_read += 1;
12951            if next_offset >= end_offset {
12952                return Ok(());
12953            }
12954
12955            // Decode unknown envelopes for gaps in ordinals.
12956            while _next_ordinal_to_read < 1 {
12957                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12958                _next_ordinal_to_read += 1;
12959                next_offset += envelope_size;
12960            }
12961
12962            let next_out_of_line = decoder.next_out_of_line();
12963            let handles_before = decoder.remaining_handles();
12964            if let Some((inlined, num_bytes, num_handles)) =
12965                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12966            {
12967                let member_inline_size =
12968                    <AcceptedChannelParameters as fidl::encoding::TypeMarker>::inline_size(
12969                        decoder.context,
12970                    );
12971                if inlined != (member_inline_size <= 4) {
12972                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12973                }
12974                let inner_offset;
12975                let mut inner_depth = depth.clone();
12976                if inlined {
12977                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12978                    inner_offset = next_offset;
12979                } else {
12980                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12981                    inner_depth.increment()?;
12982                }
12983                let val_ref = self.parameters.get_or_insert_with(|| {
12984                    fidl::new_empty!(
12985                        AcceptedChannelParameters,
12986                        fidl::encoding::DefaultFuchsiaResourceDialect
12987                    )
12988                });
12989                fidl::decode!(
12990                    AcceptedChannelParameters,
12991                    fidl::encoding::DefaultFuchsiaResourceDialect,
12992                    val_ref,
12993                    decoder,
12994                    inner_offset,
12995                    inner_depth
12996                )?;
12997                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12998                {
12999                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13000                }
13001                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13002                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13003                }
13004            }
13005
13006            next_offset += envelope_size;
13007            _next_ordinal_to_read += 1;
13008            if next_offset >= end_offset {
13009                return Ok(());
13010            }
13011
13012            // Decode unknown envelopes for gaps in ordinals.
13013            while _next_ordinal_to_read < 2 {
13014                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13015                _next_ordinal_to_read += 1;
13016                next_offset += envelope_size;
13017            }
13018
13019            let next_out_of_line = decoder.next_out_of_line();
13020            let handles_before = decoder.remaining_handles();
13021            if let Some((inlined, num_bytes, num_handles)) =
13022                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13023            {
13024                let member_inline_size = <fidl::encoding::Endpoint<
13025                    fidl::endpoints::ClientEnd<ChannelListenerMarker>,
13026                > as fidl::encoding::TypeMarker>::inline_size(
13027                    decoder.context
13028                );
13029                if inlined != (member_inline_size <= 4) {
13030                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13031                }
13032                let inner_offset;
13033                let mut inner_depth = depth.clone();
13034                if inlined {
13035                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13036                    inner_offset = next_offset;
13037                } else {
13038                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13039                    inner_depth.increment()?;
13040                }
13041                let val_ref = self.listener.get_or_insert_with(|| {
13042                    fidl::new_empty!(
13043                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
13044                        fidl::encoding::DefaultFuchsiaResourceDialect
13045                    )
13046                });
13047                fidl::decode!(
13048                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
13049                    fidl::encoding::DefaultFuchsiaResourceDialect,
13050                    val_ref,
13051                    decoder,
13052                    inner_offset,
13053                    inner_depth
13054                )?;
13055                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13056                {
13057                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13058                }
13059                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13060                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13061                }
13062            }
13063
13064            next_offset += envelope_size;
13065
13066            // Decode the remaining unknown envelopes.
13067            while next_offset < end_offset {
13068                _next_ordinal_to_read += 1;
13069                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13070                next_offset += envelope_size;
13071            }
13072
13073            Ok(())
13074        }
13075    }
13076
13077    impl CisRequestedParameters {
13078        #[inline(always)]
13079        fn max_ordinal_present(&self) -> u64 {
13080            if let Some(_) = self.max_sdu_size_incoming {
13081                return 4;
13082            }
13083            if let Some(_) = self.max_sdu_size_outgoing {
13084                return 3;
13085            }
13086            if let Some(_) = self.connection_stream {
13087                return 2;
13088            }
13089            if let Some(_) = self.cis_id {
13090                return 1;
13091            }
13092            0
13093        }
13094    }
13095
13096    impl fidl::encoding::ResourceTypeMarker for CisRequestedParameters {
13097        type Borrowed<'a> = &'a mut Self;
13098        fn take_or_borrow<'a>(
13099            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13100        ) -> Self::Borrowed<'a> {
13101            value
13102        }
13103    }
13104
13105    unsafe impl fidl::encoding::TypeMarker for CisRequestedParameters {
13106        type Owned = Self;
13107
13108        #[inline(always)]
13109        fn inline_align(_context: fidl::encoding::Context) -> usize {
13110            8
13111        }
13112
13113        #[inline(always)]
13114        fn inline_size(_context: fidl::encoding::Context) -> usize {
13115            16
13116        }
13117    }
13118
13119    unsafe impl
13120        fidl::encoding::Encode<
13121            CisRequestedParameters,
13122            fidl::encoding::DefaultFuchsiaResourceDialect,
13123        > for &mut CisRequestedParameters
13124    {
13125        unsafe fn encode(
13126            self,
13127            encoder: &mut fidl::encoding::Encoder<
13128                '_,
13129                fidl::encoding::DefaultFuchsiaResourceDialect,
13130            >,
13131            offset: usize,
13132            mut depth: fidl::encoding::Depth,
13133        ) -> fidl::Result<()> {
13134            encoder.debug_check_bounds::<CisRequestedParameters>(offset);
13135            // Vector header
13136            let max_ordinal: u64 = self.max_ordinal_present();
13137            encoder.write_num(max_ordinal, offset);
13138            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13139            // Calling encoder.out_of_line_offset(0) is not allowed.
13140            if max_ordinal == 0 {
13141                return Ok(());
13142            }
13143            depth.increment()?;
13144            let envelope_size = 8;
13145            let bytes_len = max_ordinal as usize * envelope_size;
13146            #[allow(unused_variables)]
13147            let offset = encoder.out_of_line_offset(bytes_len);
13148            let mut _prev_end_offset: usize = 0;
13149            if 1 > max_ordinal {
13150                return Ok(());
13151            }
13152
13153            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13154            // are envelope_size bytes.
13155            let cur_offset: usize = (1 - 1) * envelope_size;
13156
13157            // Zero reserved fields.
13158            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13159
13160            // Safety:
13161            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13162            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13163            //   envelope_size bytes, there is always sufficient room.
13164            fidl::encoding::encode_in_envelope_optional::<
13165                u8,
13166                fidl::encoding::DefaultFuchsiaResourceDialect,
13167            >(
13168                self.cis_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
13169                encoder,
13170                offset + cur_offset,
13171                depth,
13172            )?;
13173
13174            _prev_end_offset = cur_offset + envelope_size;
13175            if 2 > max_ordinal {
13176                return Ok(());
13177            }
13178
13179            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13180            // are envelope_size bytes.
13181            let cur_offset: usize = (2 - 1) * envelope_size;
13182
13183            // Zero reserved fields.
13184            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13185
13186            // Safety:
13187            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13188            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13189            //   envelope_size bytes, there is always sufficient room.
13190            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
13191            self.connection_stream.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
13192            encoder, offset + cur_offset, depth
13193        )?;
13194
13195            _prev_end_offset = cur_offset + envelope_size;
13196            if 3 > max_ordinal {
13197                return Ok(());
13198            }
13199
13200            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13201            // are envelope_size bytes.
13202            let cur_offset: usize = (3 - 1) * envelope_size;
13203
13204            // Zero reserved fields.
13205            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13206
13207            // Safety:
13208            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13209            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13210            //   envelope_size bytes, there is always sufficient room.
13211            fidl::encoding::encode_in_envelope_optional::<
13212                u16,
13213                fidl::encoding::DefaultFuchsiaResourceDialect,
13214            >(
13215                self.max_sdu_size_outgoing
13216                    .as_ref()
13217                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
13218                encoder,
13219                offset + cur_offset,
13220                depth,
13221            )?;
13222
13223            _prev_end_offset = cur_offset + envelope_size;
13224            if 4 > max_ordinal {
13225                return Ok(());
13226            }
13227
13228            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13229            // are envelope_size bytes.
13230            let cur_offset: usize = (4 - 1) * envelope_size;
13231
13232            // Zero reserved fields.
13233            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13234
13235            // Safety:
13236            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13237            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13238            //   envelope_size bytes, there is always sufficient room.
13239            fidl::encoding::encode_in_envelope_optional::<
13240                u16,
13241                fidl::encoding::DefaultFuchsiaResourceDialect,
13242            >(
13243                self.max_sdu_size_incoming
13244                    .as_ref()
13245                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
13246                encoder,
13247                offset + cur_offset,
13248                depth,
13249            )?;
13250
13251            _prev_end_offset = cur_offset + envelope_size;
13252
13253            Ok(())
13254        }
13255    }
13256
13257    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13258        for CisRequestedParameters
13259    {
13260        #[inline(always)]
13261        fn new_empty() -> Self {
13262            Self::default()
13263        }
13264
13265        unsafe fn decode(
13266            &mut self,
13267            decoder: &mut fidl::encoding::Decoder<
13268                '_,
13269                fidl::encoding::DefaultFuchsiaResourceDialect,
13270            >,
13271            offset: usize,
13272            mut depth: fidl::encoding::Depth,
13273        ) -> fidl::Result<()> {
13274            decoder.debug_check_bounds::<Self>(offset);
13275            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13276                None => return Err(fidl::Error::NotNullable),
13277                Some(len) => len,
13278            };
13279            // Calling decoder.out_of_line_offset(0) is not allowed.
13280            if len == 0 {
13281                return Ok(());
13282            };
13283            depth.increment()?;
13284            let envelope_size = 8;
13285            let bytes_len = len * envelope_size;
13286            let offset = decoder.out_of_line_offset(bytes_len)?;
13287            // Decode the envelope for each type.
13288            let mut _next_ordinal_to_read = 0;
13289            let mut next_offset = offset;
13290            let end_offset = offset + bytes_len;
13291            _next_ordinal_to_read += 1;
13292            if next_offset >= end_offset {
13293                return Ok(());
13294            }
13295
13296            // Decode unknown envelopes for gaps in ordinals.
13297            while _next_ordinal_to_read < 1 {
13298                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13299                _next_ordinal_to_read += 1;
13300                next_offset += envelope_size;
13301            }
13302
13303            let next_out_of_line = decoder.next_out_of_line();
13304            let handles_before = decoder.remaining_handles();
13305            if let Some((inlined, num_bytes, num_handles)) =
13306                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13307            {
13308                let member_inline_size =
13309                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13310                if inlined != (member_inline_size <= 4) {
13311                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13312                }
13313                let inner_offset;
13314                let mut inner_depth = depth.clone();
13315                if inlined {
13316                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13317                    inner_offset = next_offset;
13318                } else {
13319                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13320                    inner_depth.increment()?;
13321                }
13322                let val_ref = self.cis_id.get_or_insert_with(|| {
13323                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
13324                });
13325                fidl::decode!(
13326                    u8,
13327                    fidl::encoding::DefaultFuchsiaResourceDialect,
13328                    val_ref,
13329                    decoder,
13330                    inner_offset,
13331                    inner_depth
13332                )?;
13333                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13334                {
13335                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13336                }
13337                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13338                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13339                }
13340            }
13341
13342            next_offset += envelope_size;
13343            _next_ordinal_to_read += 1;
13344            if next_offset >= end_offset {
13345                return Ok(());
13346            }
13347
13348            // Decode unknown envelopes for gaps in ordinals.
13349            while _next_ordinal_to_read < 2 {
13350                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13351                _next_ordinal_to_read += 1;
13352                next_offset += envelope_size;
13353            }
13354
13355            let next_out_of_line = decoder.next_out_of_line();
13356            let handles_before = decoder.remaining_handles();
13357            if let Some((inlined, num_bytes, num_handles)) =
13358                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13359            {
13360                let member_inline_size = <fidl::encoding::Endpoint<
13361                    fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
13362                > as fidl::encoding::TypeMarker>::inline_size(
13363                    decoder.context
13364                );
13365                if inlined != (member_inline_size <= 4) {
13366                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13367                }
13368                let inner_offset;
13369                let mut inner_depth = depth.clone();
13370                if inlined {
13371                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13372                    inner_offset = next_offset;
13373                } else {
13374                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13375                    inner_depth.increment()?;
13376                }
13377                let val_ref = self.connection_stream.get_or_insert_with(|| {
13378                    fidl::new_empty!(
13379                        fidl::encoding::Endpoint<
13380                            fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
13381                        >,
13382                        fidl::encoding::DefaultFuchsiaResourceDialect
13383                    )
13384                });
13385                fidl::decode!(
13386                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
13387                    fidl::encoding::DefaultFuchsiaResourceDialect,
13388                    val_ref,
13389                    decoder,
13390                    inner_offset,
13391                    inner_depth
13392                )?;
13393                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13394                {
13395                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13396                }
13397                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13398                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13399                }
13400            }
13401
13402            next_offset += envelope_size;
13403            _next_ordinal_to_read += 1;
13404            if next_offset >= end_offset {
13405                return Ok(());
13406            }
13407
13408            // Decode unknown envelopes for gaps in ordinals.
13409            while _next_ordinal_to_read < 3 {
13410                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13411                _next_ordinal_to_read += 1;
13412                next_offset += envelope_size;
13413            }
13414
13415            let next_out_of_line = decoder.next_out_of_line();
13416            let handles_before = decoder.remaining_handles();
13417            if let Some((inlined, num_bytes, num_handles)) =
13418                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13419            {
13420                let member_inline_size =
13421                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13422                if inlined != (member_inline_size <= 4) {
13423                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13424                }
13425                let inner_offset;
13426                let mut inner_depth = depth.clone();
13427                if inlined {
13428                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13429                    inner_offset = next_offset;
13430                } else {
13431                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13432                    inner_depth.increment()?;
13433                }
13434                let val_ref = self.max_sdu_size_outgoing.get_or_insert_with(|| {
13435                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
13436                });
13437                fidl::decode!(
13438                    u16,
13439                    fidl::encoding::DefaultFuchsiaResourceDialect,
13440                    val_ref,
13441                    decoder,
13442                    inner_offset,
13443                    inner_depth
13444                )?;
13445                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13446                {
13447                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13448                }
13449                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13450                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13451                }
13452            }
13453
13454            next_offset += envelope_size;
13455            _next_ordinal_to_read += 1;
13456            if next_offset >= end_offset {
13457                return Ok(());
13458            }
13459
13460            // Decode unknown envelopes for gaps in ordinals.
13461            while _next_ordinal_to_read < 4 {
13462                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13463                _next_ordinal_to_read += 1;
13464                next_offset += envelope_size;
13465            }
13466
13467            let next_out_of_line = decoder.next_out_of_line();
13468            let handles_before = decoder.remaining_handles();
13469            if let Some((inlined, num_bytes, num_handles)) =
13470                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13471            {
13472                let member_inline_size =
13473                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13474                if inlined != (member_inline_size <= 4) {
13475                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13476                }
13477                let inner_offset;
13478                let mut inner_depth = depth.clone();
13479                if inlined {
13480                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13481                    inner_offset = next_offset;
13482                } else {
13483                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13484                    inner_depth.increment()?;
13485                }
13486                let val_ref = self.max_sdu_size_incoming.get_or_insert_with(|| {
13487                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
13488                });
13489                fidl::decode!(
13490                    u16,
13491                    fidl::encoding::DefaultFuchsiaResourceDialect,
13492                    val_ref,
13493                    decoder,
13494                    inner_offset,
13495                    inner_depth
13496                )?;
13497                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13498                {
13499                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13500                }
13501                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13502                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13503                }
13504            }
13505
13506            next_offset += envelope_size;
13507
13508            // Decode the remaining unknown envelopes.
13509            while next_offset < end_offset {
13510                _next_ordinal_to_read += 1;
13511                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13512                next_offset += envelope_size;
13513            }
13514
13515            Ok(())
13516        }
13517    }
13518
13519    impl ConnectionAcceptCisRequest {
13520        #[inline(always)]
13521        fn max_ordinal_present(&self) -> u64 {
13522            if let Some(_) = self.connection_stream {
13523                return 3;
13524            }
13525            if let Some(_) = self.cis_id {
13526                return 2;
13527            }
13528            if let Some(_) = self.cig_id {
13529                return 1;
13530            }
13531            0
13532        }
13533    }
13534
13535    impl fidl::encoding::ResourceTypeMarker for ConnectionAcceptCisRequest {
13536        type Borrowed<'a> = &'a mut Self;
13537        fn take_or_borrow<'a>(
13538            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13539        ) -> Self::Borrowed<'a> {
13540            value
13541        }
13542    }
13543
13544    unsafe impl fidl::encoding::TypeMarker for ConnectionAcceptCisRequest {
13545        type Owned = Self;
13546
13547        #[inline(always)]
13548        fn inline_align(_context: fidl::encoding::Context) -> usize {
13549            8
13550        }
13551
13552        #[inline(always)]
13553        fn inline_size(_context: fidl::encoding::Context) -> usize {
13554            16
13555        }
13556    }
13557
13558    unsafe impl
13559        fidl::encoding::Encode<
13560            ConnectionAcceptCisRequest,
13561            fidl::encoding::DefaultFuchsiaResourceDialect,
13562        > for &mut ConnectionAcceptCisRequest
13563    {
13564        unsafe fn encode(
13565            self,
13566            encoder: &mut fidl::encoding::Encoder<
13567                '_,
13568                fidl::encoding::DefaultFuchsiaResourceDialect,
13569            >,
13570            offset: usize,
13571            mut depth: fidl::encoding::Depth,
13572        ) -> fidl::Result<()> {
13573            encoder.debug_check_bounds::<ConnectionAcceptCisRequest>(offset);
13574            // Vector header
13575            let max_ordinal: u64 = self.max_ordinal_present();
13576            encoder.write_num(max_ordinal, offset);
13577            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13578            // Calling encoder.out_of_line_offset(0) is not allowed.
13579            if max_ordinal == 0 {
13580                return Ok(());
13581            }
13582            depth.increment()?;
13583            let envelope_size = 8;
13584            let bytes_len = max_ordinal as usize * envelope_size;
13585            #[allow(unused_variables)]
13586            let offset = encoder.out_of_line_offset(bytes_len);
13587            let mut _prev_end_offset: usize = 0;
13588            if 1 > max_ordinal {
13589                return Ok(());
13590            }
13591
13592            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13593            // are envelope_size bytes.
13594            let cur_offset: usize = (1 - 1) * envelope_size;
13595
13596            // Zero reserved fields.
13597            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13598
13599            // Safety:
13600            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13601            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13602            //   envelope_size bytes, there is always sufficient room.
13603            fidl::encoding::encode_in_envelope_optional::<
13604                u8,
13605                fidl::encoding::DefaultFuchsiaResourceDialect,
13606            >(
13607                self.cig_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
13608                encoder,
13609                offset + cur_offset,
13610                depth,
13611            )?;
13612
13613            _prev_end_offset = cur_offset + envelope_size;
13614            if 2 > max_ordinal {
13615                return Ok(());
13616            }
13617
13618            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13619            // are envelope_size bytes.
13620            let cur_offset: usize = (2 - 1) * envelope_size;
13621
13622            // Zero reserved fields.
13623            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13624
13625            // Safety:
13626            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13627            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13628            //   envelope_size bytes, there is always sufficient room.
13629            fidl::encoding::encode_in_envelope_optional::<
13630                u8,
13631                fidl::encoding::DefaultFuchsiaResourceDialect,
13632            >(
13633                self.cis_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
13634                encoder,
13635                offset + cur_offset,
13636                depth,
13637            )?;
13638
13639            _prev_end_offset = cur_offset + envelope_size;
13640            if 3 > max_ordinal {
13641                return Ok(());
13642            }
13643
13644            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13645            // are envelope_size bytes.
13646            let cur_offset: usize = (3 - 1) * envelope_size;
13647
13648            // Zero reserved fields.
13649            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13650
13651            // Safety:
13652            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13653            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13654            //   envelope_size bytes, there is always sufficient room.
13655            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
13656            self.connection_stream.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
13657            encoder, offset + cur_offset, depth
13658        )?;
13659
13660            _prev_end_offset = cur_offset + envelope_size;
13661
13662            Ok(())
13663        }
13664    }
13665
13666    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13667        for ConnectionAcceptCisRequest
13668    {
13669        #[inline(always)]
13670        fn new_empty() -> Self {
13671            Self::default()
13672        }
13673
13674        unsafe fn decode(
13675            &mut self,
13676            decoder: &mut fidl::encoding::Decoder<
13677                '_,
13678                fidl::encoding::DefaultFuchsiaResourceDialect,
13679            >,
13680            offset: usize,
13681            mut depth: fidl::encoding::Depth,
13682        ) -> fidl::Result<()> {
13683            decoder.debug_check_bounds::<Self>(offset);
13684            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13685                None => return Err(fidl::Error::NotNullable),
13686                Some(len) => len,
13687            };
13688            // Calling decoder.out_of_line_offset(0) is not allowed.
13689            if len == 0 {
13690                return Ok(());
13691            };
13692            depth.increment()?;
13693            let envelope_size = 8;
13694            let bytes_len = len * envelope_size;
13695            let offset = decoder.out_of_line_offset(bytes_len)?;
13696            // Decode the envelope for each type.
13697            let mut _next_ordinal_to_read = 0;
13698            let mut next_offset = offset;
13699            let end_offset = offset + bytes_len;
13700            _next_ordinal_to_read += 1;
13701            if next_offset >= end_offset {
13702                return Ok(());
13703            }
13704
13705            // Decode unknown envelopes for gaps in ordinals.
13706            while _next_ordinal_to_read < 1 {
13707                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13708                _next_ordinal_to_read += 1;
13709                next_offset += envelope_size;
13710            }
13711
13712            let next_out_of_line = decoder.next_out_of_line();
13713            let handles_before = decoder.remaining_handles();
13714            if let Some((inlined, num_bytes, num_handles)) =
13715                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13716            {
13717                let member_inline_size =
13718                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13719                if inlined != (member_inline_size <= 4) {
13720                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13721                }
13722                let inner_offset;
13723                let mut inner_depth = depth.clone();
13724                if inlined {
13725                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13726                    inner_offset = next_offset;
13727                } else {
13728                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13729                    inner_depth.increment()?;
13730                }
13731                let val_ref = self.cig_id.get_or_insert_with(|| {
13732                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
13733                });
13734                fidl::decode!(
13735                    u8,
13736                    fidl::encoding::DefaultFuchsiaResourceDialect,
13737                    val_ref,
13738                    decoder,
13739                    inner_offset,
13740                    inner_depth
13741                )?;
13742                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13743                {
13744                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13745                }
13746                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13747                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13748                }
13749            }
13750
13751            next_offset += envelope_size;
13752            _next_ordinal_to_read += 1;
13753            if next_offset >= end_offset {
13754                return Ok(());
13755            }
13756
13757            // Decode unknown envelopes for gaps in ordinals.
13758            while _next_ordinal_to_read < 2 {
13759                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13760                _next_ordinal_to_read += 1;
13761                next_offset += envelope_size;
13762            }
13763
13764            let next_out_of_line = decoder.next_out_of_line();
13765            let handles_before = decoder.remaining_handles();
13766            if let Some((inlined, num_bytes, num_handles)) =
13767                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13768            {
13769                let member_inline_size =
13770                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13771                if inlined != (member_inline_size <= 4) {
13772                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13773                }
13774                let inner_offset;
13775                let mut inner_depth = depth.clone();
13776                if inlined {
13777                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13778                    inner_offset = next_offset;
13779                } else {
13780                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13781                    inner_depth.increment()?;
13782                }
13783                let val_ref = self.cis_id.get_or_insert_with(|| {
13784                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
13785                });
13786                fidl::decode!(
13787                    u8,
13788                    fidl::encoding::DefaultFuchsiaResourceDialect,
13789                    val_ref,
13790                    decoder,
13791                    inner_offset,
13792                    inner_depth
13793                )?;
13794                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13795                {
13796                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13797                }
13798                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13799                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13800                }
13801            }
13802
13803            next_offset += envelope_size;
13804            _next_ordinal_to_read += 1;
13805            if next_offset >= end_offset {
13806                return Ok(());
13807            }
13808
13809            // Decode unknown envelopes for gaps in ordinals.
13810            while _next_ordinal_to_read < 3 {
13811                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13812                _next_ordinal_to_read += 1;
13813                next_offset += envelope_size;
13814            }
13815
13816            let next_out_of_line = decoder.next_out_of_line();
13817            let handles_before = decoder.remaining_handles();
13818            if let Some((inlined, num_bytes, num_handles)) =
13819                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13820            {
13821                let member_inline_size = <fidl::encoding::Endpoint<
13822                    fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
13823                > as fidl::encoding::TypeMarker>::inline_size(
13824                    decoder.context
13825                );
13826                if inlined != (member_inline_size <= 4) {
13827                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13828                }
13829                let inner_offset;
13830                let mut inner_depth = depth.clone();
13831                if inlined {
13832                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13833                    inner_offset = next_offset;
13834                } else {
13835                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13836                    inner_depth.increment()?;
13837                }
13838                let val_ref = self.connection_stream.get_or_insert_with(|| {
13839                    fidl::new_empty!(
13840                        fidl::encoding::Endpoint<
13841                            fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
13842                        >,
13843                        fidl::encoding::DefaultFuchsiaResourceDialect
13844                    )
13845                });
13846                fidl::decode!(
13847                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
13848                    fidl::encoding::DefaultFuchsiaResourceDialect,
13849                    val_ref,
13850                    decoder,
13851                    inner_offset,
13852                    inner_depth
13853                )?;
13854                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13855                {
13856                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13857                }
13858                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13859                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13860                }
13861            }
13862
13863            next_offset += envelope_size;
13864
13865            // Decode the remaining unknown envelopes.
13866            while next_offset < end_offset {
13867                _next_ordinal_to_read += 1;
13868                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13869                next_offset += envelope_size;
13870            }
13871
13872            Ok(())
13873        }
13874    }
13875
13876    impl ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
13877        #[inline(always)]
13878        fn max_ordinal_present(&self) -> u64 {
13879            if let Some(_) = self.config {
13880                return 2;
13881            }
13882            if let Some(_) = self.sync {
13883                return 1;
13884            }
13885            0
13886        }
13887    }
13888
13889    impl fidl::encoding::ResourceTypeMarker for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
13890        type Borrowed<'a> = &'a mut Self;
13891        fn take_or_borrow<'a>(
13892            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13893        ) -> Self::Borrowed<'a> {
13894            value
13895        }
13896    }
13897
13898    unsafe impl fidl::encoding::TypeMarker for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
13899        type Owned = Self;
13900
13901        #[inline(always)]
13902        fn inline_align(_context: fidl::encoding::Context) -> usize {
13903            8
13904        }
13905
13906        #[inline(always)]
13907        fn inline_size(_context: fidl::encoding::Context) -> usize {
13908            16
13909        }
13910    }
13911
13912    unsafe impl
13913        fidl::encoding::Encode<
13914            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
13915            fidl::encoding::DefaultFuchsiaResourceDialect,
13916        > for &mut ConnectionAcceptPeriodicAdvertisingSyncTransferRequest
13917    {
13918        unsafe fn encode(
13919            self,
13920            encoder: &mut fidl::encoding::Encoder<
13921                '_,
13922                fidl::encoding::DefaultFuchsiaResourceDialect,
13923            >,
13924            offset: usize,
13925            mut depth: fidl::encoding::Depth,
13926        ) -> fidl::Result<()> {
13927            encoder.debug_check_bounds::<ConnectionAcceptPeriodicAdvertisingSyncTransferRequest>(
13928                offset,
13929            );
13930            // Vector header
13931            let max_ordinal: u64 = self.max_ordinal_present();
13932            encoder.write_num(max_ordinal, offset);
13933            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13934            // Calling encoder.out_of_line_offset(0) is not allowed.
13935            if max_ordinal == 0 {
13936                return Ok(());
13937            }
13938            depth.increment()?;
13939            let envelope_size = 8;
13940            let bytes_len = max_ordinal as usize * envelope_size;
13941            #[allow(unused_variables)]
13942            let offset = encoder.out_of_line_offset(bytes_len);
13943            let mut _prev_end_offset: usize = 0;
13944            if 1 > max_ordinal {
13945                return Ok(());
13946            }
13947
13948            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13949            // are envelope_size bytes.
13950            let cur_offset: usize = (1 - 1) * envelope_size;
13951
13952            // Zero reserved fields.
13953            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13954
13955            // Safety:
13956            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13957            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13958            //   envelope_size bytes, there is always sufficient room.
13959            fidl::encoding::encode_in_envelope_optional::<
13960                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>>,
13961                fidl::encoding::DefaultFuchsiaResourceDialect,
13962            >(
13963                self.sync.as_mut().map(
13964                    <fidl::encoding::Endpoint<
13965                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
13966                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13967                ),
13968                encoder,
13969                offset + cur_offset,
13970                depth,
13971            )?;
13972
13973            _prev_end_offset = cur_offset + envelope_size;
13974            if 2 > max_ordinal {
13975                return Ok(());
13976            }
13977
13978            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13979            // are envelope_size bytes.
13980            let cur_offset: usize = (2 - 1) * envelope_size;
13981
13982            // Zero reserved fields.
13983            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13984
13985            // Safety:
13986            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13987            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13988            //   envelope_size bytes, there is always sufficient room.
13989            fidl::encoding::encode_in_envelope_optional::<PeriodicAdvertisingSyncConfiguration, fidl::encoding::DefaultFuchsiaResourceDialect>(
13990            self.config.as_ref().map(<PeriodicAdvertisingSyncConfiguration as fidl::encoding::ValueTypeMarker>::borrow),
13991            encoder, offset + cur_offset, depth
13992        )?;
13993
13994            _prev_end_offset = cur_offset + envelope_size;
13995
13996            Ok(())
13997        }
13998    }
13999
14000    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14001        for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest
14002    {
14003        #[inline(always)]
14004        fn new_empty() -> Self {
14005            Self::default()
14006        }
14007
14008        unsafe fn decode(
14009            &mut self,
14010            decoder: &mut fidl::encoding::Decoder<
14011                '_,
14012                fidl::encoding::DefaultFuchsiaResourceDialect,
14013            >,
14014            offset: usize,
14015            mut depth: fidl::encoding::Depth,
14016        ) -> fidl::Result<()> {
14017            decoder.debug_check_bounds::<Self>(offset);
14018            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14019                None => return Err(fidl::Error::NotNullable),
14020                Some(len) => len,
14021            };
14022            // Calling decoder.out_of_line_offset(0) is not allowed.
14023            if len == 0 {
14024                return Ok(());
14025            };
14026            depth.increment()?;
14027            let envelope_size = 8;
14028            let bytes_len = len * envelope_size;
14029            let offset = decoder.out_of_line_offset(bytes_len)?;
14030            // Decode the envelope for each type.
14031            let mut _next_ordinal_to_read = 0;
14032            let mut next_offset = offset;
14033            let end_offset = offset + bytes_len;
14034            _next_ordinal_to_read += 1;
14035            if next_offset >= end_offset {
14036                return Ok(());
14037            }
14038
14039            // Decode unknown envelopes for gaps in ordinals.
14040            while _next_ordinal_to_read < 1 {
14041                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14042                _next_ordinal_to_read += 1;
14043                next_offset += envelope_size;
14044            }
14045
14046            let next_out_of_line = decoder.next_out_of_line();
14047            let handles_before = decoder.remaining_handles();
14048            if let Some((inlined, num_bytes, num_handles)) =
14049                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14050            {
14051                let member_inline_size = <fidl::encoding::Endpoint<
14052                    fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
14053                > as fidl::encoding::TypeMarker>::inline_size(
14054                    decoder.context
14055                );
14056                if inlined != (member_inline_size <= 4) {
14057                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14058                }
14059                let inner_offset;
14060                let mut inner_depth = depth.clone();
14061                if inlined {
14062                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14063                    inner_offset = next_offset;
14064                } else {
14065                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14066                    inner_depth.increment()?;
14067                }
14068                let val_ref = self.sync.get_or_insert_with(|| {
14069                    fidl::new_empty!(
14070                        fidl::encoding::Endpoint<
14071                            fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
14072                        >,
14073                        fidl::encoding::DefaultFuchsiaResourceDialect
14074                    )
14075                });
14076                fidl::decode!(
14077                    fidl::encoding::Endpoint<
14078                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
14079                    >,
14080                    fidl::encoding::DefaultFuchsiaResourceDialect,
14081                    val_ref,
14082                    decoder,
14083                    inner_offset,
14084                    inner_depth
14085                )?;
14086                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14087                {
14088                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14089                }
14090                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14091                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14092                }
14093            }
14094
14095            next_offset += envelope_size;
14096            _next_ordinal_to_read += 1;
14097            if next_offset >= end_offset {
14098                return Ok(());
14099            }
14100
14101            // Decode unknown envelopes for gaps in ordinals.
14102            while _next_ordinal_to_read < 2 {
14103                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14104                _next_ordinal_to_read += 1;
14105                next_offset += envelope_size;
14106            }
14107
14108            let next_out_of_line = decoder.next_out_of_line();
14109            let handles_before = decoder.remaining_handles();
14110            if let Some((inlined, num_bytes, num_handles)) =
14111                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14112            {
14113                let member_inline_size = <PeriodicAdvertisingSyncConfiguration as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14114                if inlined != (member_inline_size <= 4) {
14115                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14116                }
14117                let inner_offset;
14118                let mut inner_depth = depth.clone();
14119                if inlined {
14120                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14121                    inner_offset = next_offset;
14122                } else {
14123                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14124                    inner_depth.increment()?;
14125                }
14126                let val_ref = self.config.get_or_insert_with(|| {
14127                    fidl::new_empty!(
14128                        PeriodicAdvertisingSyncConfiguration,
14129                        fidl::encoding::DefaultFuchsiaResourceDialect
14130                    )
14131                });
14132                fidl::decode!(
14133                    PeriodicAdvertisingSyncConfiguration,
14134                    fidl::encoding::DefaultFuchsiaResourceDialect,
14135                    val_ref,
14136                    decoder,
14137                    inner_offset,
14138                    inner_depth
14139                )?;
14140                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14141                {
14142                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14143                }
14144                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14145                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14146                }
14147            }
14148
14149            next_offset += envelope_size;
14150
14151            // Decode the remaining unknown envelopes.
14152            while next_offset < end_offset {
14153                _next_ordinal_to_read += 1;
14154                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14155                next_offset += envelope_size;
14156            }
14157
14158            Ok(())
14159        }
14160    }
14161
14162    impl ConnectionConnectL2capRequest {
14163        #[inline(always)]
14164        fn max_ordinal_present(&self) -> u64 {
14165            if let Some(_) = self.psm {
14166                return 3;
14167            }
14168            if let Some(_) = self.channel {
14169                return 2;
14170            }
14171            if let Some(_) = self.parameters {
14172                return 1;
14173            }
14174            0
14175        }
14176    }
14177
14178    impl fidl::encoding::ResourceTypeMarker for ConnectionConnectL2capRequest {
14179        type Borrowed<'a> = &'a mut Self;
14180        fn take_or_borrow<'a>(
14181            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14182        ) -> Self::Borrowed<'a> {
14183            value
14184        }
14185    }
14186
14187    unsafe impl fidl::encoding::TypeMarker for ConnectionConnectL2capRequest {
14188        type Owned = Self;
14189
14190        #[inline(always)]
14191        fn inline_align(_context: fidl::encoding::Context) -> usize {
14192            8
14193        }
14194
14195        #[inline(always)]
14196        fn inline_size(_context: fidl::encoding::Context) -> usize {
14197            16
14198        }
14199    }
14200
14201    unsafe impl
14202        fidl::encoding::Encode<
14203            ConnectionConnectL2capRequest,
14204            fidl::encoding::DefaultFuchsiaResourceDialect,
14205        > for &mut ConnectionConnectL2capRequest
14206    {
14207        unsafe fn encode(
14208            self,
14209            encoder: &mut fidl::encoding::Encoder<
14210                '_,
14211                fidl::encoding::DefaultFuchsiaResourceDialect,
14212            >,
14213            offset: usize,
14214            mut depth: fidl::encoding::Depth,
14215        ) -> fidl::Result<()> {
14216            encoder.debug_check_bounds::<ConnectionConnectL2capRequest>(offset);
14217            // Vector header
14218            let max_ordinal: u64 = self.max_ordinal_present();
14219            encoder.write_num(max_ordinal, offset);
14220            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14221            // Calling encoder.out_of_line_offset(0) is not allowed.
14222            if max_ordinal == 0 {
14223                return Ok(());
14224            }
14225            depth.increment()?;
14226            let envelope_size = 8;
14227            let bytes_len = max_ordinal as usize * envelope_size;
14228            #[allow(unused_variables)]
14229            let offset = encoder.out_of_line_offset(bytes_len);
14230            let mut _prev_end_offset: usize = 0;
14231            if 1 > max_ordinal {
14232                return Ok(());
14233            }
14234
14235            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14236            // are envelope_size bytes.
14237            let cur_offset: usize = (1 - 1) * envelope_size;
14238
14239            // Zero reserved fields.
14240            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14241
14242            // Safety:
14243            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14244            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14245            //   envelope_size bytes, there is always sufficient room.
14246            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth::ChannelParameters, fidl::encoding::DefaultFuchsiaResourceDialect>(
14247            self.parameters.as_ref().map(<fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::ValueTypeMarker>::borrow),
14248            encoder, offset + cur_offset, depth
14249        )?;
14250
14251            _prev_end_offset = cur_offset + envelope_size;
14252            if 2 > max_ordinal {
14253                return Ok(());
14254            }
14255
14256            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14257            // are envelope_size bytes.
14258            let cur_offset: usize = (2 - 1) * envelope_size;
14259
14260            // Zero reserved fields.
14261            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14262
14263            // Safety:
14264            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14265            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14266            //   envelope_size bytes, there is always sufficient room.
14267            fidl::encoding::encode_in_envelope_optional::<
14268                fidl::encoding::Endpoint<
14269                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14270                >,
14271                fidl::encoding::DefaultFuchsiaResourceDialect,
14272            >(
14273                self.channel.as_mut().map(
14274                    <fidl::encoding::Endpoint<
14275                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14276                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14277                ),
14278                encoder,
14279                offset + cur_offset,
14280                depth,
14281            )?;
14282
14283            _prev_end_offset = cur_offset + envelope_size;
14284            if 3 > max_ordinal {
14285                return Ok(());
14286            }
14287
14288            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14289            // are envelope_size bytes.
14290            let cur_offset: usize = (3 - 1) * envelope_size;
14291
14292            // Zero reserved fields.
14293            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14294
14295            // Safety:
14296            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14297            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14298            //   envelope_size bytes, there is always sufficient room.
14299            fidl::encoding::encode_in_envelope_optional::<
14300                u16,
14301                fidl::encoding::DefaultFuchsiaResourceDialect,
14302            >(
14303                self.psm.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
14304                encoder,
14305                offset + cur_offset,
14306                depth,
14307            )?;
14308
14309            _prev_end_offset = cur_offset + envelope_size;
14310
14311            Ok(())
14312        }
14313    }
14314
14315    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14316        for ConnectionConnectL2capRequest
14317    {
14318        #[inline(always)]
14319        fn new_empty() -> Self {
14320            Self::default()
14321        }
14322
14323        unsafe fn decode(
14324            &mut self,
14325            decoder: &mut fidl::encoding::Decoder<
14326                '_,
14327                fidl::encoding::DefaultFuchsiaResourceDialect,
14328            >,
14329            offset: usize,
14330            mut depth: fidl::encoding::Depth,
14331        ) -> fidl::Result<()> {
14332            decoder.debug_check_bounds::<Self>(offset);
14333            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14334                None => return Err(fidl::Error::NotNullable),
14335                Some(len) => len,
14336            };
14337            // Calling decoder.out_of_line_offset(0) is not allowed.
14338            if len == 0 {
14339                return Ok(());
14340            };
14341            depth.increment()?;
14342            let envelope_size = 8;
14343            let bytes_len = len * envelope_size;
14344            let offset = decoder.out_of_line_offset(bytes_len)?;
14345            // Decode the envelope for each type.
14346            let mut _next_ordinal_to_read = 0;
14347            let mut next_offset = offset;
14348            let end_offset = offset + bytes_len;
14349            _next_ordinal_to_read += 1;
14350            if next_offset >= end_offset {
14351                return Ok(());
14352            }
14353
14354            // Decode unknown envelopes for gaps in ordinals.
14355            while _next_ordinal_to_read < 1 {
14356                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14357                _next_ordinal_to_read += 1;
14358                next_offset += envelope_size;
14359            }
14360
14361            let next_out_of_line = decoder.next_out_of_line();
14362            let handles_before = decoder.remaining_handles();
14363            if let Some((inlined, num_bytes, num_handles)) =
14364                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14365            {
14366                let member_inline_size = <fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14367                if inlined != (member_inline_size <= 4) {
14368                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14369                }
14370                let inner_offset;
14371                let mut inner_depth = depth.clone();
14372                if inlined {
14373                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14374                    inner_offset = next_offset;
14375                } else {
14376                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14377                    inner_depth.increment()?;
14378                }
14379                let val_ref = self.parameters.get_or_insert_with(|| {
14380                    fidl::new_empty!(
14381                        fidl_fuchsia_bluetooth::ChannelParameters,
14382                        fidl::encoding::DefaultFuchsiaResourceDialect
14383                    )
14384                });
14385                fidl::decode!(
14386                    fidl_fuchsia_bluetooth::ChannelParameters,
14387                    fidl::encoding::DefaultFuchsiaResourceDialect,
14388                    val_ref,
14389                    decoder,
14390                    inner_offset,
14391                    inner_depth
14392                )?;
14393                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14394                {
14395                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14396                }
14397                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14398                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14399                }
14400            }
14401
14402            next_offset += envelope_size;
14403            _next_ordinal_to_read += 1;
14404            if next_offset >= end_offset {
14405                return Ok(());
14406            }
14407
14408            // Decode unknown envelopes for gaps in ordinals.
14409            while _next_ordinal_to_read < 2 {
14410                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14411                _next_ordinal_to_read += 1;
14412                next_offset += envelope_size;
14413            }
14414
14415            let next_out_of_line = decoder.next_out_of_line();
14416            let handles_before = decoder.remaining_handles();
14417            if let Some((inlined, num_bytes, num_handles)) =
14418                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14419            {
14420                let member_inline_size = <fidl::encoding::Endpoint<
14421                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14422                > as fidl::encoding::TypeMarker>::inline_size(
14423                    decoder.context
14424                );
14425                if inlined != (member_inline_size <= 4) {
14426                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14427                }
14428                let inner_offset;
14429                let mut inner_depth = depth.clone();
14430                if inlined {
14431                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14432                    inner_offset = next_offset;
14433                } else {
14434                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14435                    inner_depth.increment()?;
14436                }
14437                let val_ref = self.channel.get_or_insert_with(|| {
14438                    fidl::new_empty!(
14439                        fidl::encoding::Endpoint<
14440                            fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14441                        >,
14442                        fidl::encoding::DefaultFuchsiaResourceDialect
14443                    )
14444                });
14445                fidl::decode!(
14446                    fidl::encoding::Endpoint<
14447                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14448                    >,
14449                    fidl::encoding::DefaultFuchsiaResourceDialect,
14450                    val_ref,
14451                    decoder,
14452                    inner_offset,
14453                    inner_depth
14454                )?;
14455                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14456                {
14457                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14458                }
14459                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14460                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14461                }
14462            }
14463
14464            next_offset += envelope_size;
14465            _next_ordinal_to_read += 1;
14466            if next_offset >= end_offset {
14467                return Ok(());
14468            }
14469
14470            // Decode unknown envelopes for gaps in ordinals.
14471            while _next_ordinal_to_read < 3 {
14472                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14473                _next_ordinal_to_read += 1;
14474                next_offset += envelope_size;
14475            }
14476
14477            let next_out_of_line = decoder.next_out_of_line();
14478            let handles_before = decoder.remaining_handles();
14479            if let Some((inlined, num_bytes, num_handles)) =
14480                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14481            {
14482                let member_inline_size =
14483                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14484                if inlined != (member_inline_size <= 4) {
14485                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14486                }
14487                let inner_offset;
14488                let mut inner_depth = depth.clone();
14489                if inlined {
14490                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14491                    inner_offset = next_offset;
14492                } else {
14493                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14494                    inner_depth.increment()?;
14495                }
14496                let val_ref = self.psm.get_or_insert_with(|| {
14497                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
14498                });
14499                fidl::decode!(
14500                    u16,
14501                    fidl::encoding::DefaultFuchsiaResourceDialect,
14502                    val_ref,
14503                    decoder,
14504                    inner_offset,
14505                    inner_depth
14506                )?;
14507                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14508                {
14509                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14510                }
14511                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14512                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14513                }
14514            }
14515
14516            next_offset += envelope_size;
14517
14518            // Decode the remaining unknown envelopes.
14519            while next_offset < end_offset {
14520                _next_ordinal_to_read += 1;
14521                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14522                next_offset += envelope_size;
14523            }
14524
14525            Ok(())
14526        }
14527    }
14528}