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::NullableHandle {
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
673    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
674        self.inner.shutdown_with_epitaph(status)
675    }
676
677    fn is_closed(&self) -> bool {
678        self.inner.channel().is_closed()
679    }
680    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
681        self.inner.channel().on_closed()
682    }
683
684    #[cfg(target_os = "fuchsia")]
685    fn signal_peer(
686        &self,
687        clear_mask: zx::Signals,
688        set_mask: zx::Signals,
689    ) -> Result<(), zx_status::Status> {
690        use fidl::Peered;
691        self.inner.channel().signal_peer(clear_mask, set_mask)
692    }
693}
694
695impl AdvertisedPeripheralControlHandle {}
696
697#[must_use = "FIDL methods require a response to be sent"]
698#[derive(Debug)]
699pub struct AdvertisedPeripheralOnConnectedResponder {
700    control_handle: std::mem::ManuallyDrop<AdvertisedPeripheralControlHandle>,
701    tx_id: u32,
702}
703
704/// Set the the channel to be shutdown (see [`AdvertisedPeripheralControlHandle::shutdown`])
705/// if the responder is dropped without sending a response, so that the client
706/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
707impl std::ops::Drop for AdvertisedPeripheralOnConnectedResponder {
708    fn drop(&mut self) {
709        self.control_handle.shutdown();
710        // Safety: drops once, never accessed again
711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
712    }
713}
714
715impl fidl::endpoints::Responder for AdvertisedPeripheralOnConnectedResponder {
716    type ControlHandle = AdvertisedPeripheralControlHandle;
717
718    fn control_handle(&self) -> &AdvertisedPeripheralControlHandle {
719        &self.control_handle
720    }
721
722    fn drop_without_shutdown(mut self) {
723        // Safety: drops once, never accessed again due to mem::forget
724        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
725        // Prevent Drop from running (which would shut down the channel)
726        std::mem::forget(self);
727    }
728}
729
730impl AdvertisedPeripheralOnConnectedResponder {
731    /// Sends a response to the FIDL transaction.
732    ///
733    /// Sets the channel to shutdown if an error occurs.
734    pub fn send(self) -> Result<(), fidl::Error> {
735        let _result = self.send_raw();
736        if _result.is_err() {
737            self.control_handle.shutdown();
738        }
739        self.drop_without_shutdown();
740        _result
741    }
742
743    /// Similar to "send" but does not shutdown the channel if an error occurs.
744    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
745        let _result = self.send_raw();
746        self.drop_without_shutdown();
747        _result
748    }
749
750    fn send_raw(&self) -> Result<(), fidl::Error> {
751        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
752            (),
753            self.tx_id,
754            0x607b7716457eb178,
755            fidl::encoding::DynamicFlags::empty(),
756        )
757    }
758}
759
760#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
761pub struct AdvertisingHandleMarker;
762
763impl fidl::endpoints::ProtocolMarker for AdvertisingHandleMarker {
764    type Proxy = AdvertisingHandleProxy;
765    type RequestStream = AdvertisingHandleRequestStream;
766    #[cfg(target_os = "fuchsia")]
767    type SynchronousProxy = AdvertisingHandleSynchronousProxy;
768
769    const DEBUG_NAME: &'static str = "(anonymous) AdvertisingHandle";
770}
771
772pub trait AdvertisingHandleProxyInterface: Send + Sync {}
773#[derive(Debug)]
774#[cfg(target_os = "fuchsia")]
775pub struct AdvertisingHandleSynchronousProxy {
776    client: fidl::client::sync::Client,
777}
778
779#[cfg(target_os = "fuchsia")]
780impl fidl::endpoints::SynchronousProxy for AdvertisingHandleSynchronousProxy {
781    type Proxy = AdvertisingHandleProxy;
782    type Protocol = AdvertisingHandleMarker;
783
784    fn from_channel(inner: fidl::Channel) -> Self {
785        Self::new(inner)
786    }
787
788    fn into_channel(self) -> fidl::Channel {
789        self.client.into_channel()
790    }
791
792    fn as_channel(&self) -> &fidl::Channel {
793        self.client.as_channel()
794    }
795}
796
797#[cfg(target_os = "fuchsia")]
798impl AdvertisingHandleSynchronousProxy {
799    pub fn new(channel: fidl::Channel) -> Self {
800        let protocol_name =
801            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
802        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
803    }
804
805    pub fn into_channel(self) -> fidl::Channel {
806        self.client.into_channel()
807    }
808
809    /// Waits until an event arrives and returns it. It is safe for other
810    /// threads to make concurrent requests while waiting for an event.
811    pub fn wait_for_event(
812        &self,
813        deadline: zx::MonotonicInstant,
814    ) -> Result<AdvertisingHandleEvent, fidl::Error> {
815        AdvertisingHandleEvent::decode(self.client.wait_for_event(deadline)?)
816    }
817}
818
819#[cfg(target_os = "fuchsia")]
820impl From<AdvertisingHandleSynchronousProxy> for zx::NullableHandle {
821    fn from(value: AdvertisingHandleSynchronousProxy) -> Self {
822        value.into_channel().into()
823    }
824}
825
826#[cfg(target_os = "fuchsia")]
827impl From<fidl::Channel> for AdvertisingHandleSynchronousProxy {
828    fn from(value: fidl::Channel) -> Self {
829        Self::new(value)
830    }
831}
832
833#[cfg(target_os = "fuchsia")]
834impl fidl::endpoints::FromClient for AdvertisingHandleSynchronousProxy {
835    type Protocol = AdvertisingHandleMarker;
836
837    fn from_client(value: fidl::endpoints::ClientEnd<AdvertisingHandleMarker>) -> Self {
838        Self::new(value.into_channel())
839    }
840}
841
842#[derive(Debug, Clone)]
843pub struct AdvertisingHandleProxy {
844    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
845}
846
847impl fidl::endpoints::Proxy for AdvertisingHandleProxy {
848    type Protocol = AdvertisingHandleMarker;
849
850    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
851        Self::new(inner)
852    }
853
854    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
855        self.client.into_channel().map_err(|client| Self { client })
856    }
857
858    fn as_channel(&self) -> &::fidl::AsyncChannel {
859        self.client.as_channel()
860    }
861}
862
863impl AdvertisingHandleProxy {
864    /// Create a new Proxy for fuchsia.bluetooth.le/AdvertisingHandle.
865    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
866        let protocol_name =
867            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
868        Self { client: fidl::client::Client::new(channel, protocol_name) }
869    }
870
871    /// Get a Stream of events from the remote end of the protocol.
872    ///
873    /// # Panics
874    ///
875    /// Panics if the event stream was already taken.
876    pub fn take_event_stream(&self) -> AdvertisingHandleEventStream {
877        AdvertisingHandleEventStream { event_receiver: self.client.take_event_receiver() }
878    }
879}
880
881impl AdvertisingHandleProxyInterface for AdvertisingHandleProxy {}
882
883pub struct AdvertisingHandleEventStream {
884    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
885}
886
887impl std::marker::Unpin for AdvertisingHandleEventStream {}
888
889impl futures::stream::FusedStream for AdvertisingHandleEventStream {
890    fn is_terminated(&self) -> bool {
891        self.event_receiver.is_terminated()
892    }
893}
894
895impl futures::Stream for AdvertisingHandleEventStream {
896    type Item = Result<AdvertisingHandleEvent, fidl::Error>;
897
898    fn poll_next(
899        mut self: std::pin::Pin<&mut Self>,
900        cx: &mut std::task::Context<'_>,
901    ) -> std::task::Poll<Option<Self::Item>> {
902        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
903            &mut self.event_receiver,
904            cx
905        )?) {
906            Some(buf) => std::task::Poll::Ready(Some(AdvertisingHandleEvent::decode(buf))),
907            None => std::task::Poll::Ready(None),
908        }
909    }
910}
911
912#[derive(Debug)]
913pub enum AdvertisingHandleEvent {}
914
915impl AdvertisingHandleEvent {
916    /// Decodes a message buffer as a [`AdvertisingHandleEvent`].
917    fn decode(
918        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
919    ) -> Result<AdvertisingHandleEvent, fidl::Error> {
920        let (bytes, _handles) = buf.split_mut();
921        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
922        debug_assert_eq!(tx_header.tx_id, 0);
923        match tx_header.ordinal {
924            _ => Err(fidl::Error::UnknownOrdinal {
925                ordinal: tx_header.ordinal,
926                protocol_name:
927                    <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
928            }),
929        }
930    }
931}
932
933/// A Stream of incoming requests for fuchsia.bluetooth.le/AdvertisingHandle.
934pub struct AdvertisingHandleRequestStream {
935    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
936    is_terminated: bool,
937}
938
939impl std::marker::Unpin for AdvertisingHandleRequestStream {}
940
941impl futures::stream::FusedStream for AdvertisingHandleRequestStream {
942    fn is_terminated(&self) -> bool {
943        self.is_terminated
944    }
945}
946
947impl fidl::endpoints::RequestStream for AdvertisingHandleRequestStream {
948    type Protocol = AdvertisingHandleMarker;
949    type ControlHandle = AdvertisingHandleControlHandle;
950
951    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
952        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
953    }
954
955    fn control_handle(&self) -> Self::ControlHandle {
956        AdvertisingHandleControlHandle { inner: self.inner.clone() }
957    }
958
959    fn into_inner(
960        self,
961    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
962    {
963        (self.inner, self.is_terminated)
964    }
965
966    fn from_inner(
967        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
968        is_terminated: bool,
969    ) -> Self {
970        Self { inner, is_terminated }
971    }
972}
973
974impl futures::Stream for AdvertisingHandleRequestStream {
975    type Item = Result<AdvertisingHandleRequest, fidl::Error>;
976
977    fn poll_next(
978        mut self: std::pin::Pin<&mut Self>,
979        cx: &mut std::task::Context<'_>,
980    ) -> std::task::Poll<Option<Self::Item>> {
981        let this = &mut *self;
982        if this.inner.check_shutdown(cx) {
983            this.is_terminated = true;
984            return std::task::Poll::Ready(None);
985        }
986        if this.is_terminated {
987            panic!("polled AdvertisingHandleRequestStream after completion");
988        }
989        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
990            |bytes, handles| {
991                match this.inner.channel().read_etc(cx, bytes, handles) {
992                    std::task::Poll::Ready(Ok(())) => {}
993                    std::task::Poll::Pending => return std::task::Poll::Pending,
994                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
995                        this.is_terminated = true;
996                        return std::task::Poll::Ready(None);
997                    }
998                    std::task::Poll::Ready(Err(e)) => {
999                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1000                            e.into(),
1001                        ))));
1002                    }
1003                }
1004
1005                // A message has been received from the channel
1006                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1007
1008                std::task::Poll::Ready(Some(match header.ordinal {
1009                    _ => Err(fidl::Error::UnknownOrdinal {
1010                        ordinal: header.ordinal,
1011                        protocol_name:
1012                            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1013                    }),
1014                }))
1015            },
1016        )
1017    }
1018}
1019
1020/// Capability that is valid for the duration of advertising. The caller can close the handle to
1021/// stop advertising. If the system internally stops advertising for any reason, the handle will be
1022/// closed to communicate this to the client.
1023#[derive(Debug)]
1024pub enum AdvertisingHandleRequest {}
1025
1026impl AdvertisingHandleRequest {
1027    /// Name of the method defined in FIDL
1028    pub fn method_name(&self) -> &'static str {
1029        match *self {}
1030    }
1031}
1032
1033#[derive(Debug, Clone)]
1034pub struct AdvertisingHandleControlHandle {
1035    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1036}
1037
1038impl fidl::endpoints::ControlHandle for AdvertisingHandleControlHandle {
1039    fn shutdown(&self) {
1040        self.inner.shutdown()
1041    }
1042
1043    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1044        self.inner.shutdown_with_epitaph(status)
1045    }
1046
1047    fn is_closed(&self) -> bool {
1048        self.inner.channel().is_closed()
1049    }
1050    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1051        self.inner.channel().on_closed()
1052    }
1053
1054    #[cfg(target_os = "fuchsia")]
1055    fn signal_peer(
1056        &self,
1057        clear_mask: zx::Signals,
1058        set_mask: zx::Signals,
1059    ) -> Result<(), zx_status::Status> {
1060        use fidl::Peered;
1061        self.inner.channel().signal_peer(clear_mask, set_mask)
1062    }
1063}
1064
1065impl AdvertisingHandleControlHandle {}
1066
1067#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1068pub struct CentralMarker;
1069
1070impl fidl::endpoints::ProtocolMarker for CentralMarker {
1071    type Proxy = CentralProxy;
1072    type RequestStream = CentralRequestStream;
1073    #[cfg(target_os = "fuchsia")]
1074    type SynchronousProxy = CentralSynchronousProxy;
1075
1076    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.Central";
1077}
1078impl fidl::endpoints::DiscoverableProtocolMarker for CentralMarker {}
1079pub type CentralCreateConnectedIsochronousGroupResult =
1080    Result<CentralCreateConnectedIsochronousGroupResponse, CreateCigError>;
1081
1082pub trait CentralProxyInterface: Send + Sync {
1083    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
1084        + Send;
1085    fn r#listen_l2cap(
1086        &self,
1087        payload: ChannelListenerRegistryListenL2capRequest,
1088    ) -> Self::ListenL2capResponseFut;
1089    type ScanResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1090    fn r#scan(
1091        &self,
1092        options: &ScanOptions,
1093        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1094    ) -> Self::ScanResponseFut;
1095    fn r#connect(
1096        &self,
1097        id: &fidl_fuchsia_bluetooth::PeerId,
1098        options: &ConnectionOptions,
1099        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1100    ) -> Result<(), fidl::Error>;
1101    fn r#sync_to_periodic_advertising(
1102        &self,
1103        payload: CentralSyncToPeriodicAdvertisingRequest,
1104    ) -> Result<(), fidl::Error>;
1105    type CreateConnectedIsochronousGroupResponseFut: std::future::Future<
1106            Output = Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error>,
1107        > + Send;
1108    fn r#create_connected_isochronous_group(
1109        &self,
1110        payload: CentralCreateConnectedIsochronousGroupRequest,
1111    ) -> Self::CreateConnectedIsochronousGroupResponseFut;
1112    type GetPeripheralsResponseFut: std::future::Future<Output = Result<Vec<RemoteDevice>, fidl::Error>>
1113        + Send;
1114    fn r#get_peripherals(
1115        &self,
1116        service_uuids: Option<&[String]>,
1117    ) -> Self::GetPeripheralsResponseFut;
1118    type GetPeripheralResponseFut: std::future::Future<Output = Result<Option<Box<RemoteDevice>>, fidl::Error>>
1119        + Send;
1120    fn r#get_peripheral(&self, identifier: &str) -> Self::GetPeripheralResponseFut;
1121    type StartScanResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1122        + Send;
1123    fn r#start_scan(&self, filter: Option<&ScanFilter>) -> Self::StartScanResponseFut;
1124    fn r#stop_scan(&self) -> Result<(), fidl::Error>;
1125    type ConnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1126        + Send;
1127    fn r#connect_peripheral(
1128        &self,
1129        identifier: &str,
1130        options: &ConnectionOptions,
1131        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1132    ) -> Self::ConnectPeripheralResponseFut;
1133    type DisconnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1134        + Send;
1135    fn r#disconnect_peripheral(&self, identifier: &str) -> Self::DisconnectPeripheralResponseFut;
1136}
1137#[derive(Debug)]
1138#[cfg(target_os = "fuchsia")]
1139pub struct CentralSynchronousProxy {
1140    client: fidl::client::sync::Client,
1141}
1142
1143#[cfg(target_os = "fuchsia")]
1144impl fidl::endpoints::SynchronousProxy for CentralSynchronousProxy {
1145    type Proxy = CentralProxy;
1146    type Protocol = CentralMarker;
1147
1148    fn from_channel(inner: fidl::Channel) -> Self {
1149        Self::new(inner)
1150    }
1151
1152    fn into_channel(self) -> fidl::Channel {
1153        self.client.into_channel()
1154    }
1155
1156    fn as_channel(&self) -> &fidl::Channel {
1157        self.client.as_channel()
1158    }
1159}
1160
1161#[cfg(target_os = "fuchsia")]
1162impl CentralSynchronousProxy {
1163    pub fn new(channel: fidl::Channel) -> Self {
1164        let protocol_name = <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1165        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1166    }
1167
1168    pub fn into_channel(self) -> fidl::Channel {
1169        self.client.into_channel()
1170    }
1171
1172    /// Waits until an event arrives and returns it. It is safe for other
1173    /// threads to make concurrent requests while waiting for an event.
1174    pub fn wait_for_event(
1175        &self,
1176        deadline: zx::MonotonicInstant,
1177    ) -> Result<CentralEvent, fidl::Error> {
1178        CentralEvent::decode(self.client.wait_for_event(deadline)?)
1179    }
1180
1181    /// Register a listener for incoming channels. The registry will assign a
1182    /// PSM value that is unique for the local device, as well as open a
1183    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
1184    /// event that all PSMs have been assigned, this call will fail with
1185    /// `ZX_ERR_NO_RESOURCES`.
1186    ///
1187    /// Note that the method of service discovery or advertising is defined by
1188    /// the service or protocol, so it is the responsibility of the caller to
1189    /// communicate the assigned PSM to any clients.
1190    pub fn r#listen_l2cap(
1191        &self,
1192        mut payload: ChannelListenerRegistryListenL2capRequest,
1193        ___deadline: zx::MonotonicInstant,
1194    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
1195        let _response = self.client.send_query::<
1196            ChannelListenerRegistryListenL2capRequest,
1197            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
1198        >(
1199            &mut payload,
1200            0x39c6e9001d102338,
1201            fidl::encoding::DynamicFlags::empty(),
1202            ___deadline,
1203        )?;
1204        Ok(_response.map(|x| x))
1205    }
1206
1207    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
1208    /// initiated, then `result_watcher` will be closed with an epitaph.
1209    ///
1210    /// A Central client is allowed to have only one active scan at a time.
1211    /// Accordingly, only one Scan request can be outstanding at a time.
1212    /// Additional calls to Scan will fail.
1213    ///
1214    /// The lifetime of the scan session is tied to the `result_watcher`
1215    /// protocol provided. The scan will be stopped if the channel is closed.
1216    ///
1217    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
1218    /// can be used to watch for scan results.
1219    ///
1220    /// + request `options` Options used to configure the scan session.
1221    /// + request `result_watcher` Protocol that remains valid for the duration
1222    ///   of this scan session.
1223    /// - response An empty response will be sent to acknowledge the scan has
1224    ///   stopped.
1225    ///
1226    /// The following epitaphs may be sent by the server on error:
1227    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
1228    ///   protocol is only allowed 1 active scan.
1229    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
1230    ///   `ScanOptions` documentation.
1231    /// * error `INTERNAL`: An internal error occurred and a scan could not be
1232    ///   started.
1233    pub fn r#scan(
1234        &self,
1235        mut options: &ScanOptions,
1236        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1237        ___deadline: zx::MonotonicInstant,
1238    ) -> Result<(), fidl::Error> {
1239        let _response =
1240            self.client.send_query::<CentralScanRequest, fidl::encoding::EmptyPayload>(
1241                (options, result_watcher),
1242                0x41f7121798dfe15f,
1243                fidl::encoding::DynamicFlags::empty(),
1244                ___deadline,
1245            )?;
1246        Ok(_response)
1247    }
1248
1249    /// Connect to the peer with the given identifier.
1250    ///
1251    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
1252    /// client's interest on the LE connection to the peer. Closing the channel
1253    /// removes interest, but may not result in disconnection if another client
1254    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
1255    ///
1256    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
1257    /// system if the connection to the peer is lost or an error occurs.
1258    ///
1259    /// The following epitaphs may be sent by the server on error:
1260    /// + `INVALID_ARGS`: Some of the parameters are invalid.
1261    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
1262    ///                    Connection should be used.
1263    /// + `NOT_CONNECTED`: A connection could not be established.
1264    /// + `CONNECTION_RESET`: The peer disconnected.
1265    ///
1266    /// + request `id` Identifier of the peer to initiate a connection to.
1267    /// + request `options` Options used to configure the connection.
1268    /// + request `handle` Handle that remains valid for the duration of this
1269    ///   connection.
1270    pub fn r#connect(
1271        &self,
1272        mut id: &fidl_fuchsia_bluetooth::PeerId,
1273        mut options: &ConnectionOptions,
1274        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1275    ) -> Result<(), fidl::Error> {
1276        self.client.send::<CentralConnectRequest>(
1277            (id, options, handle),
1278            0x31a3065f2a6913c4,
1279            fidl::encoding::DynamicFlags::empty(),
1280        )
1281    }
1282
1283    /// Synchronize to a periodic advertising train. Reports will be delivered via the
1284    /// `PeriodicAdvertisingSync` protocol.
1285    pub fn r#sync_to_periodic_advertising(
1286        &self,
1287        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1288    ) -> Result<(), fidl::Error> {
1289        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
1290            &mut payload,
1291            0x1db6df126a00c5b9,
1292            fidl::encoding::DynamicFlags::empty(),
1293        )
1294    }
1295
1296    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
1297    /// operation is only valid when operating in the Central role for a connection.
1298    ///
1299    /// If the Central channel is closed before the CIG is explicitly removed, the group will
1300    /// be removed and disconnected.
1301    ///
1302    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
1303    /// id allocated by the host.
1304    pub fn r#create_connected_isochronous_group(
1305        &self,
1306        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1307        ___deadline: zx::MonotonicInstant,
1308    ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
1309        let _response = self
1310            .client
1311            .send_query::<CentralCreateConnectedIsochronousGroupRequest, fidl::encoding::ResultType<
1312                CentralCreateConnectedIsochronousGroupResponse,
1313                CreateCigError,
1314            >>(
1315                &mut payload,
1316                0x60323e70ae22e13,
1317                fidl::encoding::DynamicFlags::empty(),
1318                ___deadline,
1319            )?;
1320        Ok(_response.map(|x| x))
1321    }
1322
1323    /// Returns the list of peripherals that are known to the system from previous scan, connection,
1324    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
1325    /// be present on the peripheral.
1326    ///
1327    /// This method only returns peripherals (i.e. connectable devices).
1328    pub fn r#get_peripherals(
1329        &self,
1330        mut service_uuids: Option<&[String]>,
1331        ___deadline: zx::MonotonicInstant,
1332    ) -> Result<Vec<RemoteDevice>, fidl::Error> {
1333        let _response =
1334            self.client.send_query::<CentralGetPeripheralsRequest, CentralGetPeripheralsResponse>(
1335                (service_uuids,),
1336                0x37ba777499c683a8,
1337                fidl::encoding::DynamicFlags::empty(),
1338                ___deadline,
1339            )?;
1340        Ok(_response.peripherals)
1341    }
1342
1343    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
1344    ///
1345    /// Returns information about a single peripheral that is known to the system from previous scan,
1346    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
1347    /// `identifier` is not recognized.
1348    pub fn r#get_peripheral(
1349        &self,
1350        mut identifier: &str,
1351        ___deadline: zx::MonotonicInstant,
1352    ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
1353        let _response =
1354            self.client.send_query::<CentralGetPeripheralRequest, CentralGetPeripheralResponse>(
1355                (identifier,),
1356                0x97f5a2f2d9c13da,
1357                fidl::encoding::DynamicFlags::empty(),
1358                ___deadline,
1359            )?;
1360        Ok(_response.peripheral)
1361    }
1362
1363    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
1364    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
1365    /// `filter` will replace the existing session's filter.
1366    ///
1367    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
1368    /// will be notified for all discoverable devices that are found. This is not recommended; clients
1369    /// should generally filter results by at least one of `filter.service_uuids`,
1370    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
1371    pub fn r#start_scan(
1372        &self,
1373        mut filter: Option<&ScanFilter>,
1374        ___deadline: zx::MonotonicInstant,
1375    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1376        let _response =
1377            self.client.send_query::<CentralStartScanRequest, CentralStartScanResponse>(
1378                (filter,),
1379                0xeb4cf0cd0e1132b,
1380                fidl::encoding::DynamicFlags::empty(),
1381                ___deadline,
1382            )?;
1383        Ok(_response.status)
1384    }
1385
1386    /// Terminate a previously started scan session.
1387    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1388        self.client.send::<fidl::encoding::EmptyPayload>(
1389            (),
1390            0x5f79ee6a0bb037a0,
1391            fidl::encoding::DynamicFlags::empty(),
1392        )
1393    }
1394
1395    /// Creates a connection to the peripheral device with the given identifier.
1396    /// Returns the status of the operation in `status`.
1397    ///
1398    /// On success, `gatt_client` will be bound and can be used for GATT client
1399    /// role procedures. On failure, `gatt_client` will be closed and `status` will
1400    /// indicate an error.
1401    pub fn r#connect_peripheral(
1402        &self,
1403        mut identifier: &str,
1404        mut options: &ConnectionOptions,
1405        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1406        ___deadline: zx::MonotonicInstant,
1407    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1408        let _response = self
1409            .client
1410            .send_query::<CentralConnectPeripheralRequest, CentralConnectPeripheralResponse>(
1411                (identifier, options, gatt_client),
1412                0x714d6c32d066d75a,
1413                fidl::encoding::DynamicFlags::empty(),
1414                ___deadline,
1415            )?;
1416        Ok(_response.status)
1417    }
1418
1419    /// Disconnects this Central's connection to the peripheral with the given identifier.
1420    pub fn r#disconnect_peripheral(
1421        &self,
1422        mut identifier: &str,
1423        ___deadline: zx::MonotonicInstant,
1424    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1425        let _response = self
1426            .client
1427            .send_query::<CentralDisconnectPeripheralRequest, CentralDisconnectPeripheralResponse>(
1428                (identifier,),
1429                0xa9430da197362fd,
1430                fidl::encoding::DynamicFlags::empty(),
1431                ___deadline,
1432            )?;
1433        Ok(_response.status)
1434    }
1435}
1436
1437#[cfg(target_os = "fuchsia")]
1438impl From<CentralSynchronousProxy> for zx::NullableHandle {
1439    fn from(value: CentralSynchronousProxy) -> Self {
1440        value.into_channel().into()
1441    }
1442}
1443
1444#[cfg(target_os = "fuchsia")]
1445impl From<fidl::Channel> for CentralSynchronousProxy {
1446    fn from(value: fidl::Channel) -> Self {
1447        Self::new(value)
1448    }
1449}
1450
1451#[cfg(target_os = "fuchsia")]
1452impl fidl::endpoints::FromClient for CentralSynchronousProxy {
1453    type Protocol = CentralMarker;
1454
1455    fn from_client(value: fidl::endpoints::ClientEnd<CentralMarker>) -> Self {
1456        Self::new(value.into_channel())
1457    }
1458}
1459
1460#[derive(Debug, Clone)]
1461pub struct CentralProxy {
1462    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1463}
1464
1465impl fidl::endpoints::Proxy for CentralProxy {
1466    type Protocol = CentralMarker;
1467
1468    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1469        Self::new(inner)
1470    }
1471
1472    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1473        self.client.into_channel().map_err(|client| Self { client })
1474    }
1475
1476    fn as_channel(&self) -> &::fidl::AsyncChannel {
1477        self.client.as_channel()
1478    }
1479}
1480
1481impl CentralProxy {
1482    /// Create a new Proxy for fuchsia.bluetooth.le/Central.
1483    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1484        let protocol_name = <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1485        Self { client: fidl::client::Client::new(channel, protocol_name) }
1486    }
1487
1488    /// Get a Stream of events from the remote end of the protocol.
1489    ///
1490    /// # Panics
1491    ///
1492    /// Panics if the event stream was already taken.
1493    pub fn take_event_stream(&self) -> CentralEventStream {
1494        CentralEventStream { event_receiver: self.client.take_event_receiver() }
1495    }
1496
1497    /// Register a listener for incoming channels. The registry will assign a
1498    /// PSM value that is unique for the local device, as well as open a
1499    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
1500    /// event that all PSMs have been assigned, this call will fail with
1501    /// `ZX_ERR_NO_RESOURCES`.
1502    ///
1503    /// Note that the method of service discovery or advertising is defined by
1504    /// the service or protocol, so it is the responsibility of the caller to
1505    /// communicate the assigned PSM to any clients.
1506    pub fn r#listen_l2cap(
1507        &self,
1508        mut payload: ChannelListenerRegistryListenL2capRequest,
1509    ) -> fidl::client::QueryResponseFut<
1510        ChannelListenerRegistryListenL2capResult,
1511        fidl::encoding::DefaultFuchsiaResourceDialect,
1512    > {
1513        CentralProxyInterface::r#listen_l2cap(self, payload)
1514    }
1515
1516    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
1517    /// initiated, then `result_watcher` will be closed with an epitaph.
1518    ///
1519    /// A Central client is allowed to have only one active scan at a time.
1520    /// Accordingly, only one Scan request can be outstanding at a time.
1521    /// Additional calls to Scan will fail.
1522    ///
1523    /// The lifetime of the scan session is tied to the `result_watcher`
1524    /// protocol provided. The scan will be stopped if the channel is closed.
1525    ///
1526    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
1527    /// can be used to watch for scan results.
1528    ///
1529    /// + request `options` Options used to configure the scan session.
1530    /// + request `result_watcher` Protocol that remains valid for the duration
1531    ///   of this scan session.
1532    /// - response An empty response will be sent to acknowledge the scan has
1533    ///   stopped.
1534    ///
1535    /// The following epitaphs may be sent by the server on error:
1536    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
1537    ///   protocol is only allowed 1 active scan.
1538    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
1539    ///   `ScanOptions` documentation.
1540    /// * error `INTERNAL`: An internal error occurred and a scan could not be
1541    ///   started.
1542    pub fn r#scan(
1543        &self,
1544        mut options: &ScanOptions,
1545        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1546    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1547        CentralProxyInterface::r#scan(self, options, result_watcher)
1548    }
1549
1550    /// Connect to the peer with the given identifier.
1551    ///
1552    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
1553    /// client's interest on the LE connection to the peer. Closing the channel
1554    /// removes interest, but may not result in disconnection if another client
1555    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
1556    ///
1557    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
1558    /// system if the connection to the peer is lost or an error occurs.
1559    ///
1560    /// The following epitaphs may be sent by the server on error:
1561    /// + `INVALID_ARGS`: Some of the parameters are invalid.
1562    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
1563    ///                    Connection should be used.
1564    /// + `NOT_CONNECTED`: A connection could not be established.
1565    /// + `CONNECTION_RESET`: The peer disconnected.
1566    ///
1567    /// + request `id` Identifier of the peer to initiate a connection to.
1568    /// + request `options` Options used to configure the connection.
1569    /// + request `handle` Handle that remains valid for the duration of this
1570    ///   connection.
1571    pub fn r#connect(
1572        &self,
1573        mut id: &fidl_fuchsia_bluetooth::PeerId,
1574        mut options: &ConnectionOptions,
1575        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1576    ) -> Result<(), fidl::Error> {
1577        CentralProxyInterface::r#connect(self, id, options, handle)
1578    }
1579
1580    /// Synchronize to a periodic advertising train. Reports will be delivered via the
1581    /// `PeriodicAdvertisingSync` protocol.
1582    pub fn r#sync_to_periodic_advertising(
1583        &self,
1584        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1585    ) -> Result<(), fidl::Error> {
1586        CentralProxyInterface::r#sync_to_periodic_advertising(self, payload)
1587    }
1588
1589    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
1590    /// operation is only valid when operating in the Central role for a connection.
1591    ///
1592    /// If the Central channel is closed before the CIG is explicitly removed, the group will
1593    /// be removed and disconnected.
1594    ///
1595    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
1596    /// id allocated by the host.
1597    pub fn r#create_connected_isochronous_group(
1598        &self,
1599        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1600    ) -> fidl::client::QueryResponseFut<
1601        CentralCreateConnectedIsochronousGroupResult,
1602        fidl::encoding::DefaultFuchsiaResourceDialect,
1603    > {
1604        CentralProxyInterface::r#create_connected_isochronous_group(self, payload)
1605    }
1606
1607    /// Returns the list of peripherals that are known to the system from previous scan, connection,
1608    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
1609    /// be present on the peripheral.
1610    ///
1611    /// This method only returns peripherals (i.e. connectable devices).
1612    pub fn r#get_peripherals(
1613        &self,
1614        mut service_uuids: Option<&[String]>,
1615    ) -> fidl::client::QueryResponseFut<
1616        Vec<RemoteDevice>,
1617        fidl::encoding::DefaultFuchsiaResourceDialect,
1618    > {
1619        CentralProxyInterface::r#get_peripherals(self, service_uuids)
1620    }
1621
1622    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
1623    ///
1624    /// Returns information about a single peripheral that is known to the system from previous scan,
1625    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
1626    /// `identifier` is not recognized.
1627    pub fn r#get_peripheral(
1628        &self,
1629        mut identifier: &str,
1630    ) -> fidl::client::QueryResponseFut<
1631        Option<Box<RemoteDevice>>,
1632        fidl::encoding::DefaultFuchsiaResourceDialect,
1633    > {
1634        CentralProxyInterface::r#get_peripheral(self, identifier)
1635    }
1636
1637    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
1638    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
1639    /// `filter` will replace the existing session's filter.
1640    ///
1641    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
1642    /// will be notified for all discoverable devices that are found. This is not recommended; clients
1643    /// should generally filter results by at least one of `filter.service_uuids`,
1644    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
1645    pub fn r#start_scan(
1646        &self,
1647        mut filter: Option<&ScanFilter>,
1648    ) -> fidl::client::QueryResponseFut<
1649        fidl_fuchsia_bluetooth::Status,
1650        fidl::encoding::DefaultFuchsiaResourceDialect,
1651    > {
1652        CentralProxyInterface::r#start_scan(self, filter)
1653    }
1654
1655    /// Terminate a previously started scan session.
1656    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1657        CentralProxyInterface::r#stop_scan(self)
1658    }
1659
1660    /// Creates a connection to the peripheral device with the given identifier.
1661    /// Returns the status of the operation in `status`.
1662    ///
1663    /// On success, `gatt_client` will be bound and can be used for GATT client
1664    /// role procedures. On failure, `gatt_client` will be closed and `status` will
1665    /// indicate an error.
1666    pub fn r#connect_peripheral(
1667        &self,
1668        mut identifier: &str,
1669        mut options: &ConnectionOptions,
1670        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1671    ) -> fidl::client::QueryResponseFut<
1672        fidl_fuchsia_bluetooth::Status,
1673        fidl::encoding::DefaultFuchsiaResourceDialect,
1674    > {
1675        CentralProxyInterface::r#connect_peripheral(self, identifier, options, gatt_client)
1676    }
1677
1678    /// Disconnects this Central's connection to the peripheral with the given identifier.
1679    pub fn r#disconnect_peripheral(
1680        &self,
1681        mut identifier: &str,
1682    ) -> fidl::client::QueryResponseFut<
1683        fidl_fuchsia_bluetooth::Status,
1684        fidl::encoding::DefaultFuchsiaResourceDialect,
1685    > {
1686        CentralProxyInterface::r#disconnect_peripheral(self, identifier)
1687    }
1688}
1689
1690impl CentralProxyInterface for CentralProxy {
1691    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
1692        ChannelListenerRegistryListenL2capResult,
1693        fidl::encoding::DefaultFuchsiaResourceDialect,
1694    >;
1695    fn r#listen_l2cap(
1696        &self,
1697        mut payload: ChannelListenerRegistryListenL2capRequest,
1698    ) -> Self::ListenL2capResponseFut {
1699        fn _decode(
1700            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1701        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
1702            let _response = fidl::client::decode_transaction_body::<
1703                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
1704                fidl::encoding::DefaultFuchsiaResourceDialect,
1705                0x39c6e9001d102338,
1706            >(_buf?)?;
1707            Ok(_response.map(|x| x))
1708        }
1709        self.client.send_query_and_decode::<
1710            ChannelListenerRegistryListenL2capRequest,
1711            ChannelListenerRegistryListenL2capResult,
1712        >(
1713            &mut payload,
1714            0x39c6e9001d102338,
1715            fidl::encoding::DynamicFlags::empty(),
1716            _decode,
1717        )
1718    }
1719
1720    type ScanResponseFut =
1721        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1722    fn r#scan(
1723        &self,
1724        mut options: &ScanOptions,
1725        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1726    ) -> Self::ScanResponseFut {
1727        fn _decode(
1728            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1729        ) -> Result<(), fidl::Error> {
1730            let _response = fidl::client::decode_transaction_body::<
1731                fidl::encoding::EmptyPayload,
1732                fidl::encoding::DefaultFuchsiaResourceDialect,
1733                0x41f7121798dfe15f,
1734            >(_buf?)?;
1735            Ok(_response)
1736        }
1737        self.client.send_query_and_decode::<CentralScanRequest, ()>(
1738            (options, result_watcher),
1739            0x41f7121798dfe15f,
1740            fidl::encoding::DynamicFlags::empty(),
1741            _decode,
1742        )
1743    }
1744
1745    fn r#connect(
1746        &self,
1747        mut id: &fidl_fuchsia_bluetooth::PeerId,
1748        mut options: &ConnectionOptions,
1749        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1750    ) -> Result<(), fidl::Error> {
1751        self.client.send::<CentralConnectRequest>(
1752            (id, options, handle),
1753            0x31a3065f2a6913c4,
1754            fidl::encoding::DynamicFlags::empty(),
1755        )
1756    }
1757
1758    fn r#sync_to_periodic_advertising(
1759        &self,
1760        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1761    ) -> Result<(), fidl::Error> {
1762        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
1763            &mut payload,
1764            0x1db6df126a00c5b9,
1765            fidl::encoding::DynamicFlags::empty(),
1766        )
1767    }
1768
1769    type CreateConnectedIsochronousGroupResponseFut = fidl::client::QueryResponseFut<
1770        CentralCreateConnectedIsochronousGroupResult,
1771        fidl::encoding::DefaultFuchsiaResourceDialect,
1772    >;
1773    fn r#create_connected_isochronous_group(
1774        &self,
1775        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1776    ) -> Self::CreateConnectedIsochronousGroupResponseFut {
1777        fn _decode(
1778            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1779        ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
1780            let _response = fidl::client::decode_transaction_body::<
1781                fidl::encoding::ResultType<
1782                    CentralCreateConnectedIsochronousGroupResponse,
1783                    CreateCigError,
1784                >,
1785                fidl::encoding::DefaultFuchsiaResourceDialect,
1786                0x60323e70ae22e13,
1787            >(_buf?)?;
1788            Ok(_response.map(|x| x))
1789        }
1790        self.client.send_query_and_decode::<
1791            CentralCreateConnectedIsochronousGroupRequest,
1792            CentralCreateConnectedIsochronousGroupResult,
1793        >(
1794            &mut payload,
1795            0x60323e70ae22e13,
1796            fidl::encoding::DynamicFlags::empty(),
1797            _decode,
1798        )
1799    }
1800
1801    type GetPeripheralsResponseFut = fidl::client::QueryResponseFut<
1802        Vec<RemoteDevice>,
1803        fidl::encoding::DefaultFuchsiaResourceDialect,
1804    >;
1805    fn r#get_peripherals(
1806        &self,
1807        mut service_uuids: Option<&[String]>,
1808    ) -> Self::GetPeripheralsResponseFut {
1809        fn _decode(
1810            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1811        ) -> Result<Vec<RemoteDevice>, fidl::Error> {
1812            let _response = fidl::client::decode_transaction_body::<
1813                CentralGetPeripheralsResponse,
1814                fidl::encoding::DefaultFuchsiaResourceDialect,
1815                0x37ba777499c683a8,
1816            >(_buf?)?;
1817            Ok(_response.peripherals)
1818        }
1819        self.client.send_query_and_decode::<CentralGetPeripheralsRequest, Vec<RemoteDevice>>(
1820            (service_uuids,),
1821            0x37ba777499c683a8,
1822            fidl::encoding::DynamicFlags::empty(),
1823            _decode,
1824        )
1825    }
1826
1827    type GetPeripheralResponseFut = fidl::client::QueryResponseFut<
1828        Option<Box<RemoteDevice>>,
1829        fidl::encoding::DefaultFuchsiaResourceDialect,
1830    >;
1831    fn r#get_peripheral(&self, mut identifier: &str) -> Self::GetPeripheralResponseFut {
1832        fn _decode(
1833            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1834        ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
1835            let _response = fidl::client::decode_transaction_body::<
1836                CentralGetPeripheralResponse,
1837                fidl::encoding::DefaultFuchsiaResourceDialect,
1838                0x97f5a2f2d9c13da,
1839            >(_buf?)?;
1840            Ok(_response.peripheral)
1841        }
1842        self.client.send_query_and_decode::<CentralGetPeripheralRequest, Option<Box<RemoteDevice>>>(
1843            (identifier,),
1844            0x97f5a2f2d9c13da,
1845            fidl::encoding::DynamicFlags::empty(),
1846            _decode,
1847        )
1848    }
1849
1850    type StartScanResponseFut = fidl::client::QueryResponseFut<
1851        fidl_fuchsia_bluetooth::Status,
1852        fidl::encoding::DefaultFuchsiaResourceDialect,
1853    >;
1854    fn r#start_scan(&self, mut filter: Option<&ScanFilter>) -> Self::StartScanResponseFut {
1855        fn _decode(
1856            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1857        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1858            let _response = fidl::client::decode_transaction_body::<
1859                CentralStartScanResponse,
1860                fidl::encoding::DefaultFuchsiaResourceDialect,
1861                0xeb4cf0cd0e1132b,
1862            >(_buf?)?;
1863            Ok(_response.status)
1864        }
1865        self.client
1866            .send_query_and_decode::<CentralStartScanRequest, fidl_fuchsia_bluetooth::Status>(
1867                (filter,),
1868                0xeb4cf0cd0e1132b,
1869                fidl::encoding::DynamicFlags::empty(),
1870                _decode,
1871            )
1872    }
1873
1874    fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1875        self.client.send::<fidl::encoding::EmptyPayload>(
1876            (),
1877            0x5f79ee6a0bb037a0,
1878            fidl::encoding::DynamicFlags::empty(),
1879        )
1880    }
1881
1882    type ConnectPeripheralResponseFut = fidl::client::QueryResponseFut<
1883        fidl_fuchsia_bluetooth::Status,
1884        fidl::encoding::DefaultFuchsiaResourceDialect,
1885    >;
1886    fn r#connect_peripheral(
1887        &self,
1888        mut identifier: &str,
1889        mut options: &ConnectionOptions,
1890        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1891    ) -> Self::ConnectPeripheralResponseFut {
1892        fn _decode(
1893            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1894        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1895            let _response = fidl::client::decode_transaction_body::<
1896                CentralConnectPeripheralResponse,
1897                fidl::encoding::DefaultFuchsiaResourceDialect,
1898                0x714d6c32d066d75a,
1899            >(_buf?)?;
1900            Ok(_response.status)
1901        }
1902        self.client.send_query_and_decode::<
1903            CentralConnectPeripheralRequest,
1904            fidl_fuchsia_bluetooth::Status,
1905        >(
1906            (identifier, options, gatt_client,),
1907            0x714d6c32d066d75a,
1908            fidl::encoding::DynamicFlags::empty(),
1909            _decode,
1910        )
1911    }
1912
1913    type DisconnectPeripheralResponseFut = fidl::client::QueryResponseFut<
1914        fidl_fuchsia_bluetooth::Status,
1915        fidl::encoding::DefaultFuchsiaResourceDialect,
1916    >;
1917    fn r#disconnect_peripheral(
1918        &self,
1919        mut identifier: &str,
1920    ) -> Self::DisconnectPeripheralResponseFut {
1921        fn _decode(
1922            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1923        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1924            let _response = fidl::client::decode_transaction_body::<
1925                CentralDisconnectPeripheralResponse,
1926                fidl::encoding::DefaultFuchsiaResourceDialect,
1927                0xa9430da197362fd,
1928            >(_buf?)?;
1929            Ok(_response.status)
1930        }
1931        self.client.send_query_and_decode::<
1932            CentralDisconnectPeripheralRequest,
1933            fidl_fuchsia_bluetooth::Status,
1934        >(
1935            (identifier,),
1936            0xa9430da197362fd,
1937            fidl::encoding::DynamicFlags::empty(),
1938            _decode,
1939        )
1940    }
1941}
1942
1943pub struct CentralEventStream {
1944    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1945}
1946
1947impl std::marker::Unpin for CentralEventStream {}
1948
1949impl futures::stream::FusedStream for CentralEventStream {
1950    fn is_terminated(&self) -> bool {
1951        self.event_receiver.is_terminated()
1952    }
1953}
1954
1955impl futures::Stream for CentralEventStream {
1956    type Item = Result<CentralEvent, fidl::Error>;
1957
1958    fn poll_next(
1959        mut self: std::pin::Pin<&mut Self>,
1960        cx: &mut std::task::Context<'_>,
1961    ) -> std::task::Poll<Option<Self::Item>> {
1962        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1963            &mut self.event_receiver,
1964            cx
1965        )?) {
1966            Some(buf) => std::task::Poll::Ready(Some(CentralEvent::decode(buf))),
1967            None => std::task::Poll::Ready(None),
1968        }
1969    }
1970}
1971
1972#[derive(Debug)]
1973pub enum CentralEvent {
1974    OnScanStateChanged { scanning: bool },
1975    OnDeviceDiscovered { device: RemoteDevice },
1976    OnPeripheralDisconnected { identifier: String },
1977}
1978
1979impl CentralEvent {
1980    #[allow(irrefutable_let_patterns)]
1981    pub fn into_on_scan_state_changed(self) -> Option<bool> {
1982        if let CentralEvent::OnScanStateChanged { scanning } = self {
1983            Some((scanning))
1984        } else {
1985            None
1986        }
1987    }
1988    #[allow(irrefutable_let_patterns)]
1989    pub fn into_on_device_discovered(self) -> Option<RemoteDevice> {
1990        if let CentralEvent::OnDeviceDiscovered { device } = self { Some((device)) } else { None }
1991    }
1992    #[allow(irrefutable_let_patterns)]
1993    pub fn into_on_peripheral_disconnected(self) -> Option<String> {
1994        if let CentralEvent::OnPeripheralDisconnected { identifier } = self {
1995            Some((identifier))
1996        } else {
1997            None
1998        }
1999    }
2000
2001    /// Decodes a message buffer as a [`CentralEvent`].
2002    fn decode(
2003        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2004    ) -> Result<CentralEvent, fidl::Error> {
2005        let (bytes, _handles) = buf.split_mut();
2006        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2007        debug_assert_eq!(tx_header.tx_id, 0);
2008        match tx_header.ordinal {
2009            0x5f8edc23cad04d3f => {
2010                let mut out = fidl::new_empty!(
2011                    CentralOnScanStateChangedRequest,
2012                    fidl::encoding::DefaultFuchsiaResourceDialect
2013                );
2014                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnScanStateChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2015                Ok((CentralEvent::OnScanStateChanged { scanning: out.scanning }))
2016            }
2017            0x708dadf20d66db6 => {
2018                let mut out = fidl::new_empty!(
2019                    CentralOnDeviceDiscoveredRequest,
2020                    fidl::encoding::DefaultFuchsiaResourceDialect
2021                );
2022                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnDeviceDiscoveredRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2023                Ok((CentralEvent::OnDeviceDiscovered { device: out.device }))
2024            }
2025            0x4e4c6b979b2126df => {
2026                let mut out = fidl::new_empty!(
2027                    CentralOnPeripheralDisconnectedRequest,
2028                    fidl::encoding::DefaultFuchsiaResourceDialect
2029                );
2030                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnPeripheralDisconnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2031                Ok((CentralEvent::OnPeripheralDisconnected { identifier: out.identifier }))
2032            }
2033            _ => Err(fidl::Error::UnknownOrdinal {
2034                ordinal: tx_header.ordinal,
2035                protocol_name: <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2036            }),
2037        }
2038    }
2039}
2040
2041/// A Stream of incoming requests for fuchsia.bluetooth.le/Central.
2042pub struct CentralRequestStream {
2043    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2044    is_terminated: bool,
2045}
2046
2047impl std::marker::Unpin for CentralRequestStream {}
2048
2049impl futures::stream::FusedStream for CentralRequestStream {
2050    fn is_terminated(&self) -> bool {
2051        self.is_terminated
2052    }
2053}
2054
2055impl fidl::endpoints::RequestStream for CentralRequestStream {
2056    type Protocol = CentralMarker;
2057    type ControlHandle = CentralControlHandle;
2058
2059    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2060        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2061    }
2062
2063    fn control_handle(&self) -> Self::ControlHandle {
2064        CentralControlHandle { inner: self.inner.clone() }
2065    }
2066
2067    fn into_inner(
2068        self,
2069    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2070    {
2071        (self.inner, self.is_terminated)
2072    }
2073
2074    fn from_inner(
2075        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2076        is_terminated: bool,
2077    ) -> Self {
2078        Self { inner, is_terminated }
2079    }
2080}
2081
2082impl futures::Stream for CentralRequestStream {
2083    type Item = Result<CentralRequest, fidl::Error>;
2084
2085    fn poll_next(
2086        mut self: std::pin::Pin<&mut Self>,
2087        cx: &mut std::task::Context<'_>,
2088    ) -> std::task::Poll<Option<Self::Item>> {
2089        let this = &mut *self;
2090        if this.inner.check_shutdown(cx) {
2091            this.is_terminated = true;
2092            return std::task::Poll::Ready(None);
2093        }
2094        if this.is_terminated {
2095            panic!("polled CentralRequestStream after completion");
2096        }
2097        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2098            |bytes, handles| {
2099                match this.inner.channel().read_etc(cx, bytes, handles) {
2100                    std::task::Poll::Ready(Ok(())) => {}
2101                    std::task::Poll::Pending => return std::task::Poll::Pending,
2102                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2103                        this.is_terminated = true;
2104                        return std::task::Poll::Ready(None);
2105                    }
2106                    std::task::Poll::Ready(Err(e)) => {
2107                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2108                            e.into(),
2109                        ))));
2110                    }
2111                }
2112
2113                // A message has been received from the channel
2114                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2115
2116                std::task::Poll::Ready(Some(match header.ordinal {
2117                    0x39c6e9001d102338 => {
2118                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2119                        let mut req = fidl::new_empty!(
2120                            ChannelListenerRegistryListenL2capRequest,
2121                            fidl::encoding::DefaultFuchsiaResourceDialect
2122                        );
2123                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
2124                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2125                        Ok(CentralRequest::ListenL2cap {
2126                            payload: req,
2127                            responder: CentralListenL2capResponder {
2128                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2129                                tx_id: header.tx_id,
2130                            },
2131                        })
2132                    }
2133                    0x41f7121798dfe15f => {
2134                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2135                        let mut req = fidl::new_empty!(
2136                            CentralScanRequest,
2137                            fidl::encoding::DefaultFuchsiaResourceDialect
2138                        );
2139                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralScanRequest>(&header, _body_bytes, handles, &mut req)?;
2140                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2141                        Ok(CentralRequest::Scan {
2142                            options: req.options,
2143                            result_watcher: req.result_watcher,
2144
2145                            responder: CentralScanResponder {
2146                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2147                                tx_id: header.tx_id,
2148                            },
2149                        })
2150                    }
2151                    0x31a3065f2a6913c4 => {
2152                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2153                        let mut req = fidl::new_empty!(
2154                            CentralConnectRequest,
2155                            fidl::encoding::DefaultFuchsiaResourceDialect
2156                        );
2157                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectRequest>(&header, _body_bytes, handles, &mut req)?;
2158                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2159                        Ok(CentralRequest::Connect {
2160                            id: req.id,
2161                            options: req.options,
2162                            handle: req.handle,
2163
2164                            control_handle,
2165                        })
2166                    }
2167                    0x1db6df126a00c5b9 => {
2168                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2169                        let mut req = fidl::new_empty!(
2170                            CentralSyncToPeriodicAdvertisingRequest,
2171                            fidl::encoding::DefaultFuchsiaResourceDialect
2172                        );
2173                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralSyncToPeriodicAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
2174                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2175                        Ok(CentralRequest::SyncToPeriodicAdvertising {
2176                            payload: req,
2177                            control_handle,
2178                        })
2179                    }
2180                    0x60323e70ae22e13 => {
2181                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2182                        let mut req = fidl::new_empty!(
2183                            CentralCreateConnectedIsochronousGroupRequest,
2184                            fidl::encoding::DefaultFuchsiaResourceDialect
2185                        );
2186                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralCreateConnectedIsochronousGroupRequest>(&header, _body_bytes, handles, &mut req)?;
2187                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2188                        Ok(CentralRequest::CreateConnectedIsochronousGroup {
2189                            payload: req,
2190                            responder: CentralCreateConnectedIsochronousGroupResponder {
2191                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2192                                tx_id: header.tx_id,
2193                            },
2194                        })
2195                    }
2196                    0x37ba777499c683a8 => {
2197                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2198                        let mut req = fidl::new_empty!(
2199                            CentralGetPeripheralsRequest,
2200                            fidl::encoding::DefaultFuchsiaResourceDialect
2201                        );
2202                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralsRequest>(&header, _body_bytes, handles, &mut req)?;
2203                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2204                        Ok(CentralRequest::GetPeripherals {
2205                            service_uuids: req.service_uuids,
2206
2207                            responder: CentralGetPeripheralsResponder {
2208                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2209                                tx_id: header.tx_id,
2210                            },
2211                        })
2212                    }
2213                    0x97f5a2f2d9c13da => {
2214                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2215                        let mut req = fidl::new_empty!(
2216                            CentralGetPeripheralRequest,
2217                            fidl::encoding::DefaultFuchsiaResourceDialect
2218                        );
2219                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2220                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2221                        Ok(CentralRequest::GetPeripheral {
2222                            identifier: req.identifier,
2223
2224                            responder: CentralGetPeripheralResponder {
2225                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2226                                tx_id: header.tx_id,
2227                            },
2228                        })
2229                    }
2230                    0xeb4cf0cd0e1132b => {
2231                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2232                        let mut req = fidl::new_empty!(
2233                            CentralStartScanRequest,
2234                            fidl::encoding::DefaultFuchsiaResourceDialect
2235                        );
2236                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralStartScanRequest>(&header, _body_bytes, handles, &mut req)?;
2237                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2238                        Ok(CentralRequest::StartScan {
2239                            filter: req.filter,
2240
2241                            responder: CentralStartScanResponder {
2242                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2243                                tx_id: header.tx_id,
2244                            },
2245                        })
2246                    }
2247                    0x5f79ee6a0bb037a0 => {
2248                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2249                        let mut req = fidl::new_empty!(
2250                            fidl::encoding::EmptyPayload,
2251                            fidl::encoding::DefaultFuchsiaResourceDialect
2252                        );
2253                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2254                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2255                        Ok(CentralRequest::StopScan { control_handle })
2256                    }
2257                    0x714d6c32d066d75a => {
2258                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2259                        let mut req = fidl::new_empty!(
2260                            CentralConnectPeripheralRequest,
2261                            fidl::encoding::DefaultFuchsiaResourceDialect
2262                        );
2263                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2264                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2265                        Ok(CentralRequest::ConnectPeripheral {
2266                            identifier: req.identifier,
2267                            options: req.options,
2268                            gatt_client: req.gatt_client,
2269
2270                            responder: CentralConnectPeripheralResponder {
2271                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2272                                tx_id: header.tx_id,
2273                            },
2274                        })
2275                    }
2276                    0xa9430da197362fd => {
2277                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2278                        let mut req = fidl::new_empty!(
2279                            CentralDisconnectPeripheralRequest,
2280                            fidl::encoding::DefaultFuchsiaResourceDialect
2281                        );
2282                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralDisconnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2283                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2284                        Ok(CentralRequest::DisconnectPeripheral {
2285                            identifier: req.identifier,
2286
2287                            responder: CentralDisconnectPeripheralResponder {
2288                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2289                                tx_id: header.tx_id,
2290                            },
2291                        })
2292                    }
2293                    _ => Err(fidl::Error::UnknownOrdinal {
2294                        ordinal: header.ordinal,
2295                        protocol_name:
2296                            <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2297                    }),
2298                }))
2299            },
2300        )
2301    }
2302}
2303
2304#[derive(Debug)]
2305pub enum CentralRequest {
2306    /// Register a listener for incoming channels. The registry will assign a
2307    /// PSM value that is unique for the local device, as well as open a
2308    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
2309    /// event that all PSMs have been assigned, this call will fail with
2310    /// `ZX_ERR_NO_RESOURCES`.
2311    ///
2312    /// Note that the method of service discovery or advertising is defined by
2313    /// the service or protocol, so it is the responsibility of the caller to
2314    /// communicate the assigned PSM to any clients.
2315    ListenL2cap {
2316        payload: ChannelListenerRegistryListenL2capRequest,
2317        responder: CentralListenL2capResponder,
2318    },
2319    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
2320    /// initiated, then `result_watcher` will be closed with an epitaph.
2321    ///
2322    /// A Central client is allowed to have only one active scan at a time.
2323    /// Accordingly, only one Scan request can be outstanding at a time.
2324    /// Additional calls to Scan will fail.
2325    ///
2326    /// The lifetime of the scan session is tied to the `result_watcher`
2327    /// protocol provided. The scan will be stopped if the channel is closed.
2328    ///
2329    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
2330    /// can be used to watch for scan results.
2331    ///
2332    /// + request `options` Options used to configure the scan session.
2333    /// + request `result_watcher` Protocol that remains valid for the duration
2334    ///   of this scan session.
2335    /// - response An empty response will be sent to acknowledge the scan has
2336    ///   stopped.
2337    ///
2338    /// The following epitaphs may be sent by the server on error:
2339    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
2340    ///   protocol is only allowed 1 active scan.
2341    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
2342    ///   `ScanOptions` documentation.
2343    /// * error `INTERNAL`: An internal error occurred and a scan could not be
2344    ///   started.
2345    Scan {
2346        options: ScanOptions,
2347        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
2348        responder: CentralScanResponder,
2349    },
2350    /// Connect to the peer with the given identifier.
2351    ///
2352    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
2353    /// client's interest on the LE connection to the peer. Closing the channel
2354    /// removes interest, but may not result in disconnection if another client
2355    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
2356    ///
2357    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
2358    /// system if the connection to the peer is lost or an error occurs.
2359    ///
2360    /// The following epitaphs may be sent by the server on error:
2361    /// + `INVALID_ARGS`: Some of the parameters are invalid.
2362    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
2363    ///                    Connection should be used.
2364    /// + `NOT_CONNECTED`: A connection could not be established.
2365    /// + `CONNECTION_RESET`: The peer disconnected.
2366    ///
2367    /// + request `id` Identifier of the peer to initiate a connection to.
2368    /// + request `options` Options used to configure the connection.
2369    /// + request `handle` Handle that remains valid for the duration of this
2370    ///   connection.
2371    Connect {
2372        id: fidl_fuchsia_bluetooth::PeerId,
2373        options: ConnectionOptions,
2374        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
2375        control_handle: CentralControlHandle,
2376    },
2377    /// Synchronize to a periodic advertising train. Reports will be delivered via the
2378    /// `PeriodicAdvertisingSync` protocol.
2379    SyncToPeriodicAdvertising {
2380        payload: CentralSyncToPeriodicAdvertisingRequest,
2381        control_handle: CentralControlHandle,
2382    },
2383    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
2384    /// operation is only valid when operating in the Central role for a connection.
2385    ///
2386    /// If the Central channel is closed before the CIG is explicitly removed, the group will
2387    /// be removed and disconnected.
2388    ///
2389    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
2390    /// id allocated by the host.
2391    CreateConnectedIsochronousGroup {
2392        payload: CentralCreateConnectedIsochronousGroupRequest,
2393        responder: CentralCreateConnectedIsochronousGroupResponder,
2394    },
2395    /// Returns the list of peripherals that are known to the system from previous scan, connection,
2396    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
2397    /// be present on the peripheral.
2398    ///
2399    /// This method only returns peripherals (i.e. connectable devices).
2400    GetPeripherals { service_uuids: Option<Vec<String>>, responder: CentralGetPeripheralsResponder },
2401    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
2402    ///
2403    /// Returns information about a single peripheral that is known to the system from previous scan,
2404    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
2405    /// `identifier` is not recognized.
2406    GetPeripheral { identifier: String, responder: CentralGetPeripheralResponder },
2407    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
2408    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
2409    /// `filter` will replace the existing session's filter.
2410    ///
2411    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
2412    /// will be notified for all discoverable devices that are found. This is not recommended; clients
2413    /// should generally filter results by at least one of `filter.service_uuids`,
2414    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
2415    StartScan { filter: Option<Box<ScanFilter>>, responder: CentralStartScanResponder },
2416    /// Terminate a previously started scan session.
2417    StopScan { control_handle: CentralControlHandle },
2418    /// Creates a connection to the peripheral device with the given identifier.
2419    /// Returns the status of the operation in `status`.
2420    ///
2421    /// On success, `gatt_client` will be bound and can be used for GATT client
2422    /// role procedures. On failure, `gatt_client` will be closed and `status` will
2423    /// indicate an error.
2424    ConnectPeripheral {
2425        identifier: String,
2426        options: ConnectionOptions,
2427        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
2428        responder: CentralConnectPeripheralResponder,
2429    },
2430    /// Disconnects this Central's connection to the peripheral with the given identifier.
2431    DisconnectPeripheral { identifier: String, responder: CentralDisconnectPeripheralResponder },
2432}
2433
2434impl CentralRequest {
2435    #[allow(irrefutable_let_patterns)]
2436    pub fn into_listen_l2cap(
2437        self,
2438    ) -> Option<(ChannelListenerRegistryListenL2capRequest, CentralListenL2capResponder)> {
2439        if let CentralRequest::ListenL2cap { payload, responder } = self {
2440            Some((payload, responder))
2441        } else {
2442            None
2443        }
2444    }
2445
2446    #[allow(irrefutable_let_patterns)]
2447    pub fn into_scan(
2448        self,
2449    ) -> Option<(
2450        ScanOptions,
2451        fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
2452        CentralScanResponder,
2453    )> {
2454        if let CentralRequest::Scan { options, result_watcher, responder } = self {
2455            Some((options, result_watcher, responder))
2456        } else {
2457            None
2458        }
2459    }
2460
2461    #[allow(irrefutable_let_patterns)]
2462    pub fn into_connect(
2463        self,
2464    ) -> Option<(
2465        fidl_fuchsia_bluetooth::PeerId,
2466        ConnectionOptions,
2467        fidl::endpoints::ServerEnd<ConnectionMarker>,
2468        CentralControlHandle,
2469    )> {
2470        if let CentralRequest::Connect { id, options, handle, control_handle } = self {
2471            Some((id, options, handle, control_handle))
2472        } else {
2473            None
2474        }
2475    }
2476
2477    #[allow(irrefutable_let_patterns)]
2478    pub fn into_sync_to_periodic_advertising(
2479        self,
2480    ) -> Option<(CentralSyncToPeriodicAdvertisingRequest, CentralControlHandle)> {
2481        if let CentralRequest::SyncToPeriodicAdvertising { payload, control_handle } = self {
2482            Some((payload, control_handle))
2483        } else {
2484            None
2485        }
2486    }
2487
2488    #[allow(irrefutable_let_patterns)]
2489    pub fn into_create_connected_isochronous_group(
2490        self,
2491    ) -> Option<(
2492        CentralCreateConnectedIsochronousGroupRequest,
2493        CentralCreateConnectedIsochronousGroupResponder,
2494    )> {
2495        if let CentralRequest::CreateConnectedIsochronousGroup { payload, responder } = self {
2496            Some((payload, responder))
2497        } else {
2498            None
2499        }
2500    }
2501
2502    #[allow(irrefutable_let_patterns)]
2503    pub fn into_get_peripherals(
2504        self,
2505    ) -> Option<(Option<Vec<String>>, CentralGetPeripheralsResponder)> {
2506        if let CentralRequest::GetPeripherals { service_uuids, responder } = self {
2507            Some((service_uuids, responder))
2508        } else {
2509            None
2510        }
2511    }
2512
2513    #[allow(irrefutable_let_patterns)]
2514    pub fn into_get_peripheral(self) -> Option<(String, CentralGetPeripheralResponder)> {
2515        if let CentralRequest::GetPeripheral { identifier, responder } = self {
2516            Some((identifier, responder))
2517        } else {
2518            None
2519        }
2520    }
2521
2522    #[allow(irrefutable_let_patterns)]
2523    pub fn into_start_scan(self) -> Option<(Option<Box<ScanFilter>>, CentralStartScanResponder)> {
2524        if let CentralRequest::StartScan { filter, responder } = self {
2525            Some((filter, responder))
2526        } else {
2527            None
2528        }
2529    }
2530
2531    #[allow(irrefutable_let_patterns)]
2532    pub fn into_stop_scan(self) -> Option<(CentralControlHandle)> {
2533        if let CentralRequest::StopScan { control_handle } = self {
2534            Some((control_handle))
2535        } else {
2536            None
2537        }
2538    }
2539
2540    #[allow(irrefutable_let_patterns)]
2541    pub fn into_connect_peripheral(
2542        self,
2543    ) -> Option<(
2544        String,
2545        ConnectionOptions,
2546        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
2547        CentralConnectPeripheralResponder,
2548    )> {
2549        if let CentralRequest::ConnectPeripheral { identifier, options, gatt_client, responder } =
2550            self
2551        {
2552            Some((identifier, options, gatt_client, responder))
2553        } else {
2554            None
2555        }
2556    }
2557
2558    #[allow(irrefutable_let_patterns)]
2559    pub fn into_disconnect_peripheral(
2560        self,
2561    ) -> Option<(String, CentralDisconnectPeripheralResponder)> {
2562        if let CentralRequest::DisconnectPeripheral { identifier, responder } = self {
2563            Some((identifier, responder))
2564        } else {
2565            None
2566        }
2567    }
2568
2569    /// Name of the method defined in FIDL
2570    pub fn method_name(&self) -> &'static str {
2571        match *self {
2572            CentralRequest::ListenL2cap { .. } => "listen_l2cap",
2573            CentralRequest::Scan { .. } => "scan",
2574            CentralRequest::Connect { .. } => "connect",
2575            CentralRequest::SyncToPeriodicAdvertising { .. } => "sync_to_periodic_advertising",
2576            CentralRequest::CreateConnectedIsochronousGroup { .. } => {
2577                "create_connected_isochronous_group"
2578            }
2579            CentralRequest::GetPeripherals { .. } => "get_peripherals",
2580            CentralRequest::GetPeripheral { .. } => "get_peripheral",
2581            CentralRequest::StartScan { .. } => "start_scan",
2582            CentralRequest::StopScan { .. } => "stop_scan",
2583            CentralRequest::ConnectPeripheral { .. } => "connect_peripheral",
2584            CentralRequest::DisconnectPeripheral { .. } => "disconnect_peripheral",
2585        }
2586    }
2587}
2588
2589#[derive(Debug, Clone)]
2590pub struct CentralControlHandle {
2591    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2592}
2593
2594impl fidl::endpoints::ControlHandle for CentralControlHandle {
2595    fn shutdown(&self) {
2596        self.inner.shutdown()
2597    }
2598
2599    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2600        self.inner.shutdown_with_epitaph(status)
2601    }
2602
2603    fn is_closed(&self) -> bool {
2604        self.inner.channel().is_closed()
2605    }
2606    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2607        self.inner.channel().on_closed()
2608    }
2609
2610    #[cfg(target_os = "fuchsia")]
2611    fn signal_peer(
2612        &self,
2613        clear_mask: zx::Signals,
2614        set_mask: zx::Signals,
2615    ) -> Result<(), zx_status::Status> {
2616        use fidl::Peered;
2617        self.inner.channel().signal_peer(clear_mask, set_mask)
2618    }
2619}
2620
2621impl CentralControlHandle {
2622    pub fn send_on_scan_state_changed(&self, mut scanning: bool) -> Result<(), fidl::Error> {
2623        self.inner.send::<CentralOnScanStateChangedRequest>(
2624            (scanning,),
2625            0,
2626            0x5f8edc23cad04d3f,
2627            fidl::encoding::DynamicFlags::empty(),
2628        )
2629    }
2630
2631    pub fn send_on_device_discovered(&self, mut device: &RemoteDevice) -> Result<(), fidl::Error> {
2632        self.inner.send::<CentralOnDeviceDiscoveredRequest>(
2633            (device,),
2634            0,
2635            0x708dadf20d66db6,
2636            fidl::encoding::DynamicFlags::empty(),
2637        )
2638    }
2639
2640    pub fn send_on_peripheral_disconnected(&self, mut identifier: &str) -> Result<(), fidl::Error> {
2641        self.inner.send::<CentralOnPeripheralDisconnectedRequest>(
2642            (identifier,),
2643            0,
2644            0x4e4c6b979b2126df,
2645            fidl::encoding::DynamicFlags::empty(),
2646        )
2647    }
2648}
2649
2650#[must_use = "FIDL methods require a response to be sent"]
2651#[derive(Debug)]
2652pub struct CentralListenL2capResponder {
2653    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2654    tx_id: u32,
2655}
2656
2657/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2658/// if the responder is dropped without sending a response, so that the client
2659/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2660impl std::ops::Drop for CentralListenL2capResponder {
2661    fn drop(&mut self) {
2662        self.control_handle.shutdown();
2663        // Safety: drops once, never accessed again
2664        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2665    }
2666}
2667
2668impl fidl::endpoints::Responder for CentralListenL2capResponder {
2669    type ControlHandle = CentralControlHandle;
2670
2671    fn control_handle(&self) -> &CentralControlHandle {
2672        &self.control_handle
2673    }
2674
2675    fn drop_without_shutdown(mut self) {
2676        // Safety: drops once, never accessed again due to mem::forget
2677        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2678        // Prevent Drop from running (which would shut down the channel)
2679        std::mem::forget(self);
2680    }
2681}
2682
2683impl CentralListenL2capResponder {
2684    /// Sends a response to the FIDL transaction.
2685    ///
2686    /// Sets the channel to shutdown if an error occurs.
2687    pub fn send(
2688        self,
2689        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2690    ) -> Result<(), fidl::Error> {
2691        let _result = self.send_raw(result);
2692        if _result.is_err() {
2693            self.control_handle.shutdown();
2694        }
2695        self.drop_without_shutdown();
2696        _result
2697    }
2698
2699    /// Similar to "send" but does not shutdown the channel if an error occurs.
2700    pub fn send_no_shutdown_on_err(
2701        self,
2702        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2703    ) -> Result<(), fidl::Error> {
2704        let _result = self.send_raw(result);
2705        self.drop_without_shutdown();
2706        _result
2707    }
2708
2709    fn send_raw(
2710        &self,
2711        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2712    ) -> Result<(), fidl::Error> {
2713        self.control_handle.inner.send::<fidl::encoding::ResultType<
2714            ChannelListenerRegistryListenL2capResponse,
2715            i32,
2716        >>(
2717            result,
2718            self.tx_id,
2719            0x39c6e9001d102338,
2720            fidl::encoding::DynamicFlags::empty(),
2721        )
2722    }
2723}
2724
2725#[must_use = "FIDL methods require a response to be sent"]
2726#[derive(Debug)]
2727pub struct CentralScanResponder {
2728    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2729    tx_id: u32,
2730}
2731
2732/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2733/// if the responder is dropped without sending a response, so that the client
2734/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2735impl std::ops::Drop for CentralScanResponder {
2736    fn drop(&mut self) {
2737        self.control_handle.shutdown();
2738        // Safety: drops once, never accessed again
2739        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2740    }
2741}
2742
2743impl fidl::endpoints::Responder for CentralScanResponder {
2744    type ControlHandle = CentralControlHandle;
2745
2746    fn control_handle(&self) -> &CentralControlHandle {
2747        &self.control_handle
2748    }
2749
2750    fn drop_without_shutdown(mut self) {
2751        // Safety: drops once, never accessed again due to mem::forget
2752        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2753        // Prevent Drop from running (which would shut down the channel)
2754        std::mem::forget(self);
2755    }
2756}
2757
2758impl CentralScanResponder {
2759    /// Sends a response to the FIDL transaction.
2760    ///
2761    /// Sets the channel to shutdown if an error occurs.
2762    pub fn send(self) -> Result<(), fidl::Error> {
2763        let _result = self.send_raw();
2764        if _result.is_err() {
2765            self.control_handle.shutdown();
2766        }
2767        self.drop_without_shutdown();
2768        _result
2769    }
2770
2771    /// Similar to "send" but does not shutdown the channel if an error occurs.
2772    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2773        let _result = self.send_raw();
2774        self.drop_without_shutdown();
2775        _result
2776    }
2777
2778    fn send_raw(&self) -> Result<(), fidl::Error> {
2779        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2780            (),
2781            self.tx_id,
2782            0x41f7121798dfe15f,
2783            fidl::encoding::DynamicFlags::empty(),
2784        )
2785    }
2786}
2787
2788#[must_use = "FIDL methods require a response to be sent"]
2789#[derive(Debug)]
2790pub struct CentralCreateConnectedIsochronousGroupResponder {
2791    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2792    tx_id: u32,
2793}
2794
2795/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2796/// if the responder is dropped without sending a response, so that the client
2797/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2798impl std::ops::Drop for CentralCreateConnectedIsochronousGroupResponder {
2799    fn drop(&mut self) {
2800        self.control_handle.shutdown();
2801        // Safety: drops once, never accessed again
2802        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2803    }
2804}
2805
2806impl fidl::endpoints::Responder for CentralCreateConnectedIsochronousGroupResponder {
2807    type ControlHandle = CentralControlHandle;
2808
2809    fn control_handle(&self) -> &CentralControlHandle {
2810        &self.control_handle
2811    }
2812
2813    fn drop_without_shutdown(mut self) {
2814        // Safety: drops once, never accessed again due to mem::forget
2815        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2816        // Prevent Drop from running (which would shut down the channel)
2817        std::mem::forget(self);
2818    }
2819}
2820
2821impl CentralCreateConnectedIsochronousGroupResponder {
2822    /// Sends a response to the FIDL transaction.
2823    ///
2824    /// Sets the channel to shutdown if an error occurs.
2825    pub fn send(
2826        self,
2827        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2828    ) -> Result<(), fidl::Error> {
2829        let _result = self.send_raw(result);
2830        if _result.is_err() {
2831            self.control_handle.shutdown();
2832        }
2833        self.drop_without_shutdown();
2834        _result
2835    }
2836
2837    /// Similar to "send" but does not shutdown the channel if an error occurs.
2838    pub fn send_no_shutdown_on_err(
2839        self,
2840        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2841    ) -> Result<(), fidl::Error> {
2842        let _result = self.send_raw(result);
2843        self.drop_without_shutdown();
2844        _result
2845    }
2846
2847    fn send_raw(
2848        &self,
2849        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2850    ) -> Result<(), fidl::Error> {
2851        self.control_handle.inner.send::<fidl::encoding::ResultType<
2852            CentralCreateConnectedIsochronousGroupResponse,
2853            CreateCigError,
2854        >>(
2855            result,
2856            self.tx_id,
2857            0x60323e70ae22e13,
2858            fidl::encoding::DynamicFlags::empty(),
2859        )
2860    }
2861}
2862
2863#[must_use = "FIDL methods require a response to be sent"]
2864#[derive(Debug)]
2865pub struct CentralGetPeripheralsResponder {
2866    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2867    tx_id: u32,
2868}
2869
2870/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2871/// if the responder is dropped without sending a response, so that the client
2872/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2873impl std::ops::Drop for CentralGetPeripheralsResponder {
2874    fn drop(&mut self) {
2875        self.control_handle.shutdown();
2876        // Safety: drops once, never accessed again
2877        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2878    }
2879}
2880
2881impl fidl::endpoints::Responder for CentralGetPeripheralsResponder {
2882    type ControlHandle = CentralControlHandle;
2883
2884    fn control_handle(&self) -> &CentralControlHandle {
2885        &self.control_handle
2886    }
2887
2888    fn drop_without_shutdown(mut self) {
2889        // Safety: drops once, never accessed again due to mem::forget
2890        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2891        // Prevent Drop from running (which would shut down the channel)
2892        std::mem::forget(self);
2893    }
2894}
2895
2896impl CentralGetPeripheralsResponder {
2897    /// Sends a response to the FIDL transaction.
2898    ///
2899    /// Sets the channel to shutdown if an error occurs.
2900    pub fn send(self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
2901        let _result = self.send_raw(peripherals);
2902        if _result.is_err() {
2903            self.control_handle.shutdown();
2904        }
2905        self.drop_without_shutdown();
2906        _result
2907    }
2908
2909    /// Similar to "send" but does not shutdown the channel if an error occurs.
2910    pub fn send_no_shutdown_on_err(
2911        self,
2912        mut peripherals: &[RemoteDevice],
2913    ) -> Result<(), fidl::Error> {
2914        let _result = self.send_raw(peripherals);
2915        self.drop_without_shutdown();
2916        _result
2917    }
2918
2919    fn send_raw(&self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
2920        self.control_handle.inner.send::<CentralGetPeripheralsResponse>(
2921            (peripherals,),
2922            self.tx_id,
2923            0x37ba777499c683a8,
2924            fidl::encoding::DynamicFlags::empty(),
2925        )
2926    }
2927}
2928
2929#[must_use = "FIDL methods require a response to be sent"]
2930#[derive(Debug)]
2931pub struct CentralGetPeripheralResponder {
2932    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2933    tx_id: u32,
2934}
2935
2936/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2937/// if the responder is dropped without sending a response, so that the client
2938/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2939impl std::ops::Drop for CentralGetPeripheralResponder {
2940    fn drop(&mut self) {
2941        self.control_handle.shutdown();
2942        // Safety: drops once, never accessed again
2943        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2944    }
2945}
2946
2947impl fidl::endpoints::Responder for CentralGetPeripheralResponder {
2948    type ControlHandle = CentralControlHandle;
2949
2950    fn control_handle(&self) -> &CentralControlHandle {
2951        &self.control_handle
2952    }
2953
2954    fn drop_without_shutdown(mut self) {
2955        // Safety: drops once, never accessed again due to mem::forget
2956        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2957        // Prevent Drop from running (which would shut down the channel)
2958        std::mem::forget(self);
2959    }
2960}
2961
2962impl CentralGetPeripheralResponder {
2963    /// Sends a response to the FIDL transaction.
2964    ///
2965    /// Sets the channel to shutdown if an error occurs.
2966    pub fn send(self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
2967        let _result = self.send_raw(peripheral);
2968        if _result.is_err() {
2969            self.control_handle.shutdown();
2970        }
2971        self.drop_without_shutdown();
2972        _result
2973    }
2974
2975    /// Similar to "send" but does not shutdown the channel if an error occurs.
2976    pub fn send_no_shutdown_on_err(
2977        self,
2978        mut peripheral: Option<&RemoteDevice>,
2979    ) -> Result<(), fidl::Error> {
2980        let _result = self.send_raw(peripheral);
2981        self.drop_without_shutdown();
2982        _result
2983    }
2984
2985    fn send_raw(&self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
2986        self.control_handle.inner.send::<CentralGetPeripheralResponse>(
2987            (peripheral,),
2988            self.tx_id,
2989            0x97f5a2f2d9c13da,
2990            fidl::encoding::DynamicFlags::empty(),
2991        )
2992    }
2993}
2994
2995#[must_use = "FIDL methods require a response to be sent"]
2996#[derive(Debug)]
2997pub struct CentralStartScanResponder {
2998    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2999    tx_id: u32,
3000}
3001
3002/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3003/// if the responder is dropped without sending a response, so that the client
3004/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3005impl std::ops::Drop for CentralStartScanResponder {
3006    fn drop(&mut self) {
3007        self.control_handle.shutdown();
3008        // Safety: drops once, never accessed again
3009        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3010    }
3011}
3012
3013impl fidl::endpoints::Responder for CentralStartScanResponder {
3014    type ControlHandle = CentralControlHandle;
3015
3016    fn control_handle(&self) -> &CentralControlHandle {
3017        &self.control_handle
3018    }
3019
3020    fn drop_without_shutdown(mut self) {
3021        // Safety: drops once, never accessed again due to mem::forget
3022        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3023        // Prevent Drop from running (which would shut down the channel)
3024        std::mem::forget(self);
3025    }
3026}
3027
3028impl CentralStartScanResponder {
3029    /// Sends a response to the FIDL transaction.
3030    ///
3031    /// Sets the channel to shutdown if an error occurs.
3032    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3033        let _result = self.send_raw(status);
3034        if _result.is_err() {
3035            self.control_handle.shutdown();
3036        }
3037        self.drop_without_shutdown();
3038        _result
3039    }
3040
3041    /// Similar to "send" but does not shutdown the channel if an error occurs.
3042    pub fn send_no_shutdown_on_err(
3043        self,
3044        mut status: &fidl_fuchsia_bluetooth::Status,
3045    ) -> Result<(), fidl::Error> {
3046        let _result = self.send_raw(status);
3047        self.drop_without_shutdown();
3048        _result
3049    }
3050
3051    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3052        self.control_handle.inner.send::<CentralStartScanResponse>(
3053            (status,),
3054            self.tx_id,
3055            0xeb4cf0cd0e1132b,
3056            fidl::encoding::DynamicFlags::empty(),
3057        )
3058    }
3059}
3060
3061#[must_use = "FIDL methods require a response to be sent"]
3062#[derive(Debug)]
3063pub struct CentralConnectPeripheralResponder {
3064    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
3065    tx_id: u32,
3066}
3067
3068/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3069/// if the responder is dropped without sending a response, so that the client
3070/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3071impl std::ops::Drop for CentralConnectPeripheralResponder {
3072    fn drop(&mut self) {
3073        self.control_handle.shutdown();
3074        // Safety: drops once, never accessed again
3075        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3076    }
3077}
3078
3079impl fidl::endpoints::Responder for CentralConnectPeripheralResponder {
3080    type ControlHandle = CentralControlHandle;
3081
3082    fn control_handle(&self) -> &CentralControlHandle {
3083        &self.control_handle
3084    }
3085
3086    fn drop_without_shutdown(mut self) {
3087        // Safety: drops once, never accessed again due to mem::forget
3088        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3089        // Prevent Drop from running (which would shut down the channel)
3090        std::mem::forget(self);
3091    }
3092}
3093
3094impl CentralConnectPeripheralResponder {
3095    /// Sends a response to the FIDL transaction.
3096    ///
3097    /// Sets the channel to shutdown if an error occurs.
3098    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3099        let _result = self.send_raw(status);
3100        if _result.is_err() {
3101            self.control_handle.shutdown();
3102        }
3103        self.drop_without_shutdown();
3104        _result
3105    }
3106
3107    /// Similar to "send" but does not shutdown the channel if an error occurs.
3108    pub fn send_no_shutdown_on_err(
3109        self,
3110        mut status: &fidl_fuchsia_bluetooth::Status,
3111    ) -> Result<(), fidl::Error> {
3112        let _result = self.send_raw(status);
3113        self.drop_without_shutdown();
3114        _result
3115    }
3116
3117    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3118        self.control_handle.inner.send::<CentralConnectPeripheralResponse>(
3119            (status,),
3120            self.tx_id,
3121            0x714d6c32d066d75a,
3122            fidl::encoding::DynamicFlags::empty(),
3123        )
3124    }
3125}
3126
3127#[must_use = "FIDL methods require a response to be sent"]
3128#[derive(Debug)]
3129pub struct CentralDisconnectPeripheralResponder {
3130    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
3131    tx_id: u32,
3132}
3133
3134/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3135/// if the responder is dropped without sending a response, so that the client
3136/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3137impl std::ops::Drop for CentralDisconnectPeripheralResponder {
3138    fn drop(&mut self) {
3139        self.control_handle.shutdown();
3140        // Safety: drops once, never accessed again
3141        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3142    }
3143}
3144
3145impl fidl::endpoints::Responder for CentralDisconnectPeripheralResponder {
3146    type ControlHandle = CentralControlHandle;
3147
3148    fn control_handle(&self) -> &CentralControlHandle {
3149        &self.control_handle
3150    }
3151
3152    fn drop_without_shutdown(mut self) {
3153        // Safety: drops once, never accessed again due to mem::forget
3154        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3155        // Prevent Drop from running (which would shut down the channel)
3156        std::mem::forget(self);
3157    }
3158}
3159
3160impl CentralDisconnectPeripheralResponder {
3161    /// Sends a response to the FIDL transaction.
3162    ///
3163    /// Sets the channel to shutdown if an error occurs.
3164    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3165        let _result = self.send_raw(status);
3166        if _result.is_err() {
3167            self.control_handle.shutdown();
3168        }
3169        self.drop_without_shutdown();
3170        _result
3171    }
3172
3173    /// Similar to "send" but does not shutdown the channel if an error occurs.
3174    pub fn send_no_shutdown_on_err(
3175        self,
3176        mut status: &fidl_fuchsia_bluetooth::Status,
3177    ) -> Result<(), fidl::Error> {
3178        let _result = self.send_raw(status);
3179        self.drop_without_shutdown();
3180        _result
3181    }
3182
3183    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3184        self.control_handle.inner.send::<CentralDisconnectPeripheralResponse>(
3185            (status,),
3186            self.tx_id,
3187            0xa9430da197362fd,
3188            fidl::encoding::DynamicFlags::empty(),
3189        )
3190    }
3191}
3192
3193#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3194pub struct ChannelListenerMarker;
3195
3196impl fidl::endpoints::ProtocolMarker for ChannelListenerMarker {
3197    type Proxy = ChannelListenerProxy;
3198    type RequestStream = ChannelListenerRequestStream;
3199    #[cfg(target_os = "fuchsia")]
3200    type SynchronousProxy = ChannelListenerSynchronousProxy;
3201
3202    const DEBUG_NAME: &'static str = "(anonymous) ChannelListener";
3203}
3204
3205pub trait ChannelListenerProxyInterface: Send + Sync {
3206    type AcceptResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3207    fn r#accept(
3208        &self,
3209        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3210    ) -> Self::AcceptResponseFut;
3211}
3212#[derive(Debug)]
3213#[cfg(target_os = "fuchsia")]
3214pub struct ChannelListenerSynchronousProxy {
3215    client: fidl::client::sync::Client,
3216}
3217
3218#[cfg(target_os = "fuchsia")]
3219impl fidl::endpoints::SynchronousProxy for ChannelListenerSynchronousProxy {
3220    type Proxy = ChannelListenerProxy;
3221    type Protocol = ChannelListenerMarker;
3222
3223    fn from_channel(inner: fidl::Channel) -> Self {
3224        Self::new(inner)
3225    }
3226
3227    fn into_channel(self) -> fidl::Channel {
3228        self.client.into_channel()
3229    }
3230
3231    fn as_channel(&self) -> &fidl::Channel {
3232        self.client.as_channel()
3233    }
3234}
3235
3236#[cfg(target_os = "fuchsia")]
3237impl ChannelListenerSynchronousProxy {
3238    pub fn new(channel: fidl::Channel) -> Self {
3239        let protocol_name = <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3240        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3241    }
3242
3243    pub fn into_channel(self) -> fidl::Channel {
3244        self.client.into_channel()
3245    }
3246
3247    /// Waits until an event arrives and returns it. It is safe for other
3248    /// threads to make concurrent requests while waiting for an event.
3249    pub fn wait_for_event(
3250        &self,
3251        deadline: zx::MonotonicInstant,
3252    ) -> Result<ChannelListenerEvent, fidl::Error> {
3253        ChannelListenerEvent::decode(self.client.wait_for_event(deadline)?)
3254    }
3255
3256    pub fn r#accept(
3257        &self,
3258        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3259        ___deadline: zx::MonotonicInstant,
3260    ) -> Result<(), fidl::Error> {
3261        let _response = self.client.send_query::<
3262            ChannelListenerAcceptRequest,
3263            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3264        >(
3265            (channel,),
3266            0x6f535bd36b20fc7b,
3267            fidl::encoding::DynamicFlags::FLEXIBLE,
3268            ___deadline,
3269        )?
3270        .into_result::<ChannelListenerMarker>("accept")?;
3271        Ok(_response)
3272    }
3273}
3274
3275#[cfg(target_os = "fuchsia")]
3276impl From<ChannelListenerSynchronousProxy> for zx::NullableHandle {
3277    fn from(value: ChannelListenerSynchronousProxy) -> Self {
3278        value.into_channel().into()
3279    }
3280}
3281
3282#[cfg(target_os = "fuchsia")]
3283impl From<fidl::Channel> for ChannelListenerSynchronousProxy {
3284    fn from(value: fidl::Channel) -> Self {
3285        Self::new(value)
3286    }
3287}
3288
3289#[cfg(target_os = "fuchsia")]
3290impl fidl::endpoints::FromClient for ChannelListenerSynchronousProxy {
3291    type Protocol = ChannelListenerMarker;
3292
3293    fn from_client(value: fidl::endpoints::ClientEnd<ChannelListenerMarker>) -> Self {
3294        Self::new(value.into_channel())
3295    }
3296}
3297
3298#[derive(Debug, Clone)]
3299pub struct ChannelListenerProxy {
3300    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3301}
3302
3303impl fidl::endpoints::Proxy for ChannelListenerProxy {
3304    type Protocol = ChannelListenerMarker;
3305
3306    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3307        Self::new(inner)
3308    }
3309
3310    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3311        self.client.into_channel().map_err(|client| Self { client })
3312    }
3313
3314    fn as_channel(&self) -> &::fidl::AsyncChannel {
3315        self.client.as_channel()
3316    }
3317}
3318
3319impl ChannelListenerProxy {
3320    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelListener.
3321    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3322        let protocol_name = <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3323        Self { client: fidl::client::Client::new(channel, protocol_name) }
3324    }
3325
3326    /// Get a Stream of events from the remote end of the protocol.
3327    ///
3328    /// # Panics
3329    ///
3330    /// Panics if the event stream was already taken.
3331    pub fn take_event_stream(&self) -> ChannelListenerEventStream {
3332        ChannelListenerEventStream { event_receiver: self.client.take_event_receiver() }
3333    }
3334
3335    pub fn r#accept(
3336        &self,
3337        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3338    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3339        ChannelListenerProxyInterface::r#accept(self, channel)
3340    }
3341}
3342
3343impl ChannelListenerProxyInterface for ChannelListenerProxy {
3344    type AcceptResponseFut =
3345        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3346    fn r#accept(
3347        &self,
3348        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3349    ) -> Self::AcceptResponseFut {
3350        fn _decode(
3351            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3352        ) -> Result<(), fidl::Error> {
3353            let _response = fidl::client::decode_transaction_body::<
3354                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3355                fidl::encoding::DefaultFuchsiaResourceDialect,
3356                0x6f535bd36b20fc7b,
3357            >(_buf?)?
3358            .into_result::<ChannelListenerMarker>("accept")?;
3359            Ok(_response)
3360        }
3361        self.client.send_query_and_decode::<ChannelListenerAcceptRequest, ()>(
3362            (channel,),
3363            0x6f535bd36b20fc7b,
3364            fidl::encoding::DynamicFlags::FLEXIBLE,
3365            _decode,
3366        )
3367    }
3368}
3369
3370pub struct ChannelListenerEventStream {
3371    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3372}
3373
3374impl std::marker::Unpin for ChannelListenerEventStream {}
3375
3376impl futures::stream::FusedStream for ChannelListenerEventStream {
3377    fn is_terminated(&self) -> bool {
3378        self.event_receiver.is_terminated()
3379    }
3380}
3381
3382impl futures::Stream for ChannelListenerEventStream {
3383    type Item = Result<ChannelListenerEvent, fidl::Error>;
3384
3385    fn poll_next(
3386        mut self: std::pin::Pin<&mut Self>,
3387        cx: &mut std::task::Context<'_>,
3388    ) -> std::task::Poll<Option<Self::Item>> {
3389        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3390            &mut self.event_receiver,
3391            cx
3392        )?) {
3393            Some(buf) => std::task::Poll::Ready(Some(ChannelListenerEvent::decode(buf))),
3394            None => std::task::Poll::Ready(None),
3395        }
3396    }
3397}
3398
3399#[derive(Debug)]
3400pub enum ChannelListenerEvent {
3401    #[non_exhaustive]
3402    _UnknownEvent {
3403        /// Ordinal of the event that was sent.
3404        ordinal: u64,
3405    },
3406}
3407
3408impl ChannelListenerEvent {
3409    /// Decodes a message buffer as a [`ChannelListenerEvent`].
3410    fn decode(
3411        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3412    ) -> Result<ChannelListenerEvent, fidl::Error> {
3413        let (bytes, _handles) = buf.split_mut();
3414        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3415        debug_assert_eq!(tx_header.tx_id, 0);
3416        match tx_header.ordinal {
3417            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3418                Ok(ChannelListenerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3419            }
3420            _ => Err(fidl::Error::UnknownOrdinal {
3421                ordinal: tx_header.ordinal,
3422                protocol_name:
3423                    <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3424            }),
3425        }
3426    }
3427}
3428
3429/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelListener.
3430pub struct ChannelListenerRequestStream {
3431    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3432    is_terminated: bool,
3433}
3434
3435impl std::marker::Unpin for ChannelListenerRequestStream {}
3436
3437impl futures::stream::FusedStream for ChannelListenerRequestStream {
3438    fn is_terminated(&self) -> bool {
3439        self.is_terminated
3440    }
3441}
3442
3443impl fidl::endpoints::RequestStream for ChannelListenerRequestStream {
3444    type Protocol = ChannelListenerMarker;
3445    type ControlHandle = ChannelListenerControlHandle;
3446
3447    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3448        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3449    }
3450
3451    fn control_handle(&self) -> Self::ControlHandle {
3452        ChannelListenerControlHandle { inner: self.inner.clone() }
3453    }
3454
3455    fn into_inner(
3456        self,
3457    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3458    {
3459        (self.inner, self.is_terminated)
3460    }
3461
3462    fn from_inner(
3463        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3464        is_terminated: bool,
3465    ) -> Self {
3466        Self { inner, is_terminated }
3467    }
3468}
3469
3470impl futures::Stream for ChannelListenerRequestStream {
3471    type Item = Result<ChannelListenerRequest, fidl::Error>;
3472
3473    fn poll_next(
3474        mut self: std::pin::Pin<&mut Self>,
3475        cx: &mut std::task::Context<'_>,
3476    ) -> std::task::Poll<Option<Self::Item>> {
3477        let this = &mut *self;
3478        if this.inner.check_shutdown(cx) {
3479            this.is_terminated = true;
3480            return std::task::Poll::Ready(None);
3481        }
3482        if this.is_terminated {
3483            panic!("polled ChannelListenerRequestStream after completion");
3484        }
3485        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3486            |bytes, handles| {
3487                match this.inner.channel().read_etc(cx, bytes, handles) {
3488                    std::task::Poll::Ready(Ok(())) => {}
3489                    std::task::Poll::Pending => return std::task::Poll::Pending,
3490                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3491                        this.is_terminated = true;
3492                        return std::task::Poll::Ready(None);
3493                    }
3494                    std::task::Poll::Ready(Err(e)) => {
3495                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3496                            e.into(),
3497                        ))));
3498                    }
3499                }
3500
3501                // A message has been received from the channel
3502                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3503
3504                std::task::Poll::Ready(Some(match header.ordinal {
3505                    0x6f535bd36b20fc7b => {
3506                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3507                        let mut req = fidl::new_empty!(
3508                            ChannelListenerAcceptRequest,
3509                            fidl::encoding::DefaultFuchsiaResourceDialect
3510                        );
3511                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
3512                        let control_handle =
3513                            ChannelListenerControlHandle { inner: this.inner.clone() };
3514                        Ok(ChannelListenerRequest::Accept {
3515                            channel: req.channel,
3516
3517                            responder: ChannelListenerAcceptResponder {
3518                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3519                                tx_id: header.tx_id,
3520                            },
3521                        })
3522                    }
3523                    _ if header.tx_id == 0
3524                        && header
3525                            .dynamic_flags()
3526                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3527                    {
3528                        Ok(ChannelListenerRequest::_UnknownMethod {
3529                            ordinal: header.ordinal,
3530                            control_handle: ChannelListenerControlHandle {
3531                                inner: this.inner.clone(),
3532                            },
3533                            method_type: fidl::MethodType::OneWay,
3534                        })
3535                    }
3536                    _ if header
3537                        .dynamic_flags()
3538                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3539                    {
3540                        this.inner.send_framework_err(
3541                            fidl::encoding::FrameworkErr::UnknownMethod,
3542                            header.tx_id,
3543                            header.ordinal,
3544                            header.dynamic_flags(),
3545                            (bytes, handles),
3546                        )?;
3547                        Ok(ChannelListenerRequest::_UnknownMethod {
3548                            ordinal: header.ordinal,
3549                            control_handle: ChannelListenerControlHandle {
3550                                inner: this.inner.clone(),
3551                            },
3552                            method_type: fidl::MethodType::TwoWay,
3553                        })
3554                    }
3555                    _ => Err(fidl::Error::UnknownOrdinal {
3556                        ordinal: header.ordinal,
3557                        protocol_name:
3558                            <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3559                    }),
3560                }))
3561            },
3562        )
3563    }
3564}
3565
3566/// Represents a service or protocol that accepts incoming channel requests.
3567/// Incoming channel requests for the associated PSM will be connected via this
3568/// protocol. Closing this protocol will also cease accepting any incoming
3569/// channel requests, but existing established channels will not be affected.
3570/// Additionally, once this protocol is closed the implementation is free to
3571/// reuse the PSM that was previously assigned for this instance.
3572#[derive(Debug)]
3573pub enum ChannelListenerRequest {
3574    Accept {
3575        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3576        responder: ChannelListenerAcceptResponder,
3577    },
3578    /// An interaction was received which does not match any known method.
3579    #[non_exhaustive]
3580    _UnknownMethod {
3581        /// Ordinal of the method that was called.
3582        ordinal: u64,
3583        control_handle: ChannelListenerControlHandle,
3584        method_type: fidl::MethodType,
3585    },
3586}
3587
3588impl ChannelListenerRequest {
3589    #[allow(irrefutable_let_patterns)]
3590    pub fn into_accept(
3591        self,
3592    ) -> Option<(
3593        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3594        ChannelListenerAcceptResponder,
3595    )> {
3596        if let ChannelListenerRequest::Accept { channel, responder } = self {
3597            Some((channel, responder))
3598        } else {
3599            None
3600        }
3601    }
3602
3603    /// Name of the method defined in FIDL
3604    pub fn method_name(&self) -> &'static str {
3605        match *self {
3606            ChannelListenerRequest::Accept { .. } => "accept",
3607            ChannelListenerRequest::_UnknownMethod {
3608                method_type: fidl::MethodType::OneWay,
3609                ..
3610            } => "unknown one-way method",
3611            ChannelListenerRequest::_UnknownMethod {
3612                method_type: fidl::MethodType::TwoWay,
3613                ..
3614            } => "unknown two-way method",
3615        }
3616    }
3617}
3618
3619#[derive(Debug, Clone)]
3620pub struct ChannelListenerControlHandle {
3621    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3622}
3623
3624impl fidl::endpoints::ControlHandle for ChannelListenerControlHandle {
3625    fn shutdown(&self) {
3626        self.inner.shutdown()
3627    }
3628
3629    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3630        self.inner.shutdown_with_epitaph(status)
3631    }
3632
3633    fn is_closed(&self) -> bool {
3634        self.inner.channel().is_closed()
3635    }
3636    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3637        self.inner.channel().on_closed()
3638    }
3639
3640    #[cfg(target_os = "fuchsia")]
3641    fn signal_peer(
3642        &self,
3643        clear_mask: zx::Signals,
3644        set_mask: zx::Signals,
3645    ) -> Result<(), zx_status::Status> {
3646        use fidl::Peered;
3647        self.inner.channel().signal_peer(clear_mask, set_mask)
3648    }
3649}
3650
3651impl ChannelListenerControlHandle {}
3652
3653#[must_use = "FIDL methods require a response to be sent"]
3654#[derive(Debug)]
3655pub struct ChannelListenerAcceptResponder {
3656    control_handle: std::mem::ManuallyDrop<ChannelListenerControlHandle>,
3657    tx_id: u32,
3658}
3659
3660/// Set the the channel to be shutdown (see [`ChannelListenerControlHandle::shutdown`])
3661/// if the responder is dropped without sending a response, so that the client
3662/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3663impl std::ops::Drop for ChannelListenerAcceptResponder {
3664    fn drop(&mut self) {
3665        self.control_handle.shutdown();
3666        // Safety: drops once, never accessed again
3667        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3668    }
3669}
3670
3671impl fidl::endpoints::Responder for ChannelListenerAcceptResponder {
3672    type ControlHandle = ChannelListenerControlHandle;
3673
3674    fn control_handle(&self) -> &ChannelListenerControlHandle {
3675        &self.control_handle
3676    }
3677
3678    fn drop_without_shutdown(mut self) {
3679        // Safety: drops once, never accessed again due to mem::forget
3680        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3681        // Prevent Drop from running (which would shut down the channel)
3682        std::mem::forget(self);
3683    }
3684}
3685
3686impl ChannelListenerAcceptResponder {
3687    /// Sends a response to the FIDL transaction.
3688    ///
3689    /// Sets the channel to shutdown if an error occurs.
3690    pub fn send(self) -> Result<(), fidl::Error> {
3691        let _result = self.send_raw();
3692        if _result.is_err() {
3693            self.control_handle.shutdown();
3694        }
3695        self.drop_without_shutdown();
3696        _result
3697    }
3698
3699    /// Similar to "send" but does not shutdown the channel if an error occurs.
3700    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3701        let _result = self.send_raw();
3702        self.drop_without_shutdown();
3703        _result
3704    }
3705
3706    fn send_raw(&self) -> Result<(), fidl::Error> {
3707        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3708            fidl::encoding::Flexible::new(()),
3709            self.tx_id,
3710            0x6f535bd36b20fc7b,
3711            fidl::encoding::DynamicFlags::FLEXIBLE,
3712        )
3713    }
3714}
3715
3716#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3717pub struct ChannelListenerRegistryMarker;
3718
3719impl fidl::endpoints::ProtocolMarker for ChannelListenerRegistryMarker {
3720    type Proxy = ChannelListenerRegistryProxy;
3721    type RequestStream = ChannelListenerRegistryRequestStream;
3722    #[cfg(target_os = "fuchsia")]
3723    type SynchronousProxy = ChannelListenerRegistrySynchronousProxy;
3724
3725    const DEBUG_NAME: &'static str = "(anonymous) ChannelListenerRegistry";
3726}
3727pub type ChannelListenerRegistryListenL2capResult =
3728    Result<ChannelListenerRegistryListenL2capResponse, i32>;
3729
3730pub trait ChannelListenerRegistryProxyInterface: Send + Sync {
3731    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
3732        + Send;
3733    fn r#listen_l2cap(
3734        &self,
3735        payload: ChannelListenerRegistryListenL2capRequest,
3736    ) -> Self::ListenL2capResponseFut;
3737}
3738#[derive(Debug)]
3739#[cfg(target_os = "fuchsia")]
3740pub struct ChannelListenerRegistrySynchronousProxy {
3741    client: fidl::client::sync::Client,
3742}
3743
3744#[cfg(target_os = "fuchsia")]
3745impl fidl::endpoints::SynchronousProxy for ChannelListenerRegistrySynchronousProxy {
3746    type Proxy = ChannelListenerRegistryProxy;
3747    type Protocol = ChannelListenerRegistryMarker;
3748
3749    fn from_channel(inner: fidl::Channel) -> Self {
3750        Self::new(inner)
3751    }
3752
3753    fn into_channel(self) -> fidl::Channel {
3754        self.client.into_channel()
3755    }
3756
3757    fn as_channel(&self) -> &fidl::Channel {
3758        self.client.as_channel()
3759    }
3760}
3761
3762#[cfg(target_os = "fuchsia")]
3763impl ChannelListenerRegistrySynchronousProxy {
3764    pub fn new(channel: fidl::Channel) -> Self {
3765        let protocol_name =
3766            <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3767        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3768    }
3769
3770    pub fn into_channel(self) -> fidl::Channel {
3771        self.client.into_channel()
3772    }
3773
3774    /// Waits until an event arrives and returns it. It is safe for other
3775    /// threads to make concurrent requests while waiting for an event.
3776    pub fn wait_for_event(
3777        &self,
3778        deadline: zx::MonotonicInstant,
3779    ) -> Result<ChannelListenerRegistryEvent, fidl::Error> {
3780        ChannelListenerRegistryEvent::decode(self.client.wait_for_event(deadline)?)
3781    }
3782
3783    /// Register a listener for incoming channels. The registry will assign a
3784    /// PSM value that is unique for the local device, as well as open a
3785    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
3786    /// event that all PSMs have been assigned, this call will fail with
3787    /// `ZX_ERR_NO_RESOURCES`.
3788    ///
3789    /// Note that the method of service discovery or advertising is defined by
3790    /// the service or protocol, so it is the responsibility of the caller to
3791    /// communicate the assigned PSM to any clients.
3792    pub fn r#listen_l2cap(
3793        &self,
3794        mut payload: ChannelListenerRegistryListenL2capRequest,
3795        ___deadline: zx::MonotonicInstant,
3796    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
3797        let _response = self.client.send_query::<
3798            ChannelListenerRegistryListenL2capRequest,
3799            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
3800        >(
3801            &mut payload,
3802            0x39c6e9001d102338,
3803            fidl::encoding::DynamicFlags::empty(),
3804            ___deadline,
3805        )?;
3806        Ok(_response.map(|x| x))
3807    }
3808}
3809
3810#[cfg(target_os = "fuchsia")]
3811impl From<ChannelListenerRegistrySynchronousProxy> for zx::NullableHandle {
3812    fn from(value: ChannelListenerRegistrySynchronousProxy) -> Self {
3813        value.into_channel().into()
3814    }
3815}
3816
3817#[cfg(target_os = "fuchsia")]
3818impl From<fidl::Channel> for ChannelListenerRegistrySynchronousProxy {
3819    fn from(value: fidl::Channel) -> Self {
3820        Self::new(value)
3821    }
3822}
3823
3824#[cfg(target_os = "fuchsia")]
3825impl fidl::endpoints::FromClient for ChannelListenerRegistrySynchronousProxy {
3826    type Protocol = ChannelListenerRegistryMarker;
3827
3828    fn from_client(value: fidl::endpoints::ClientEnd<ChannelListenerRegistryMarker>) -> Self {
3829        Self::new(value.into_channel())
3830    }
3831}
3832
3833#[derive(Debug, Clone)]
3834pub struct ChannelListenerRegistryProxy {
3835    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3836}
3837
3838impl fidl::endpoints::Proxy for ChannelListenerRegistryProxy {
3839    type Protocol = ChannelListenerRegistryMarker;
3840
3841    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3842        Self::new(inner)
3843    }
3844
3845    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3846        self.client.into_channel().map_err(|client| Self { client })
3847    }
3848
3849    fn as_channel(&self) -> &::fidl::AsyncChannel {
3850        self.client.as_channel()
3851    }
3852}
3853
3854impl ChannelListenerRegistryProxy {
3855    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelListenerRegistry.
3856    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3857        let protocol_name =
3858            <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3859        Self { client: fidl::client::Client::new(channel, protocol_name) }
3860    }
3861
3862    /// Get a Stream of events from the remote end of the protocol.
3863    ///
3864    /// # Panics
3865    ///
3866    /// Panics if the event stream was already taken.
3867    pub fn take_event_stream(&self) -> ChannelListenerRegistryEventStream {
3868        ChannelListenerRegistryEventStream { event_receiver: self.client.take_event_receiver() }
3869    }
3870
3871    /// Register a listener for incoming channels. The registry will assign a
3872    /// PSM value that is unique for the local device, as well as open a
3873    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
3874    /// event that all PSMs have been assigned, this call will fail with
3875    /// `ZX_ERR_NO_RESOURCES`.
3876    ///
3877    /// Note that the method of service discovery or advertising is defined by
3878    /// the service or protocol, so it is the responsibility of the caller to
3879    /// communicate the assigned PSM to any clients.
3880    pub fn r#listen_l2cap(
3881        &self,
3882        mut payload: ChannelListenerRegistryListenL2capRequest,
3883    ) -> fidl::client::QueryResponseFut<
3884        ChannelListenerRegistryListenL2capResult,
3885        fidl::encoding::DefaultFuchsiaResourceDialect,
3886    > {
3887        ChannelListenerRegistryProxyInterface::r#listen_l2cap(self, payload)
3888    }
3889}
3890
3891impl ChannelListenerRegistryProxyInterface for ChannelListenerRegistryProxy {
3892    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
3893        ChannelListenerRegistryListenL2capResult,
3894        fidl::encoding::DefaultFuchsiaResourceDialect,
3895    >;
3896    fn r#listen_l2cap(
3897        &self,
3898        mut payload: ChannelListenerRegistryListenL2capRequest,
3899    ) -> Self::ListenL2capResponseFut {
3900        fn _decode(
3901            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3902        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
3903            let _response = fidl::client::decode_transaction_body::<
3904                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
3905                fidl::encoding::DefaultFuchsiaResourceDialect,
3906                0x39c6e9001d102338,
3907            >(_buf?)?;
3908            Ok(_response.map(|x| x))
3909        }
3910        self.client.send_query_and_decode::<
3911            ChannelListenerRegistryListenL2capRequest,
3912            ChannelListenerRegistryListenL2capResult,
3913        >(
3914            &mut payload,
3915            0x39c6e9001d102338,
3916            fidl::encoding::DynamicFlags::empty(),
3917            _decode,
3918        )
3919    }
3920}
3921
3922pub struct ChannelListenerRegistryEventStream {
3923    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3924}
3925
3926impl std::marker::Unpin for ChannelListenerRegistryEventStream {}
3927
3928impl futures::stream::FusedStream for ChannelListenerRegistryEventStream {
3929    fn is_terminated(&self) -> bool {
3930        self.event_receiver.is_terminated()
3931    }
3932}
3933
3934impl futures::Stream for ChannelListenerRegistryEventStream {
3935    type Item = Result<ChannelListenerRegistryEvent, fidl::Error>;
3936
3937    fn poll_next(
3938        mut self: std::pin::Pin<&mut Self>,
3939        cx: &mut std::task::Context<'_>,
3940    ) -> std::task::Poll<Option<Self::Item>> {
3941        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3942            &mut self.event_receiver,
3943            cx
3944        )?) {
3945            Some(buf) => std::task::Poll::Ready(Some(ChannelListenerRegistryEvent::decode(buf))),
3946            None => std::task::Poll::Ready(None),
3947        }
3948    }
3949}
3950
3951#[derive(Debug)]
3952pub enum ChannelListenerRegistryEvent {}
3953
3954impl ChannelListenerRegistryEvent {
3955    /// Decodes a message buffer as a [`ChannelListenerRegistryEvent`].
3956    fn decode(
3957        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3958    ) -> Result<ChannelListenerRegistryEvent, fidl::Error> {
3959        let (bytes, _handles) = buf.split_mut();
3960        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3961        debug_assert_eq!(tx_header.tx_id, 0);
3962        match tx_header.ordinal {
3963            _ => Err(fidl::Error::UnknownOrdinal {
3964                ordinal: tx_header.ordinal,
3965                protocol_name:
3966                    <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3967            }),
3968        }
3969    }
3970}
3971
3972/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelListenerRegistry.
3973pub struct ChannelListenerRegistryRequestStream {
3974    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3975    is_terminated: bool,
3976}
3977
3978impl std::marker::Unpin for ChannelListenerRegistryRequestStream {}
3979
3980impl futures::stream::FusedStream for ChannelListenerRegistryRequestStream {
3981    fn is_terminated(&self) -> bool {
3982        self.is_terminated
3983    }
3984}
3985
3986impl fidl::endpoints::RequestStream for ChannelListenerRegistryRequestStream {
3987    type Protocol = ChannelListenerRegistryMarker;
3988    type ControlHandle = ChannelListenerRegistryControlHandle;
3989
3990    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3991        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3992    }
3993
3994    fn control_handle(&self) -> Self::ControlHandle {
3995        ChannelListenerRegistryControlHandle { inner: self.inner.clone() }
3996    }
3997
3998    fn into_inner(
3999        self,
4000    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4001    {
4002        (self.inner, self.is_terminated)
4003    }
4004
4005    fn from_inner(
4006        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4007        is_terminated: bool,
4008    ) -> Self {
4009        Self { inner, is_terminated }
4010    }
4011}
4012
4013impl futures::Stream for ChannelListenerRegistryRequestStream {
4014    type Item = Result<ChannelListenerRegistryRequest, fidl::Error>;
4015
4016    fn poll_next(
4017        mut self: std::pin::Pin<&mut Self>,
4018        cx: &mut std::task::Context<'_>,
4019    ) -> std::task::Poll<Option<Self::Item>> {
4020        let this = &mut *self;
4021        if this.inner.check_shutdown(cx) {
4022            this.is_terminated = true;
4023            return std::task::Poll::Ready(None);
4024        }
4025        if this.is_terminated {
4026            panic!("polled ChannelListenerRegistryRequestStream after completion");
4027        }
4028        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4029            |bytes, handles| {
4030                match this.inner.channel().read_etc(cx, bytes, handles) {
4031                    std::task::Poll::Ready(Ok(())) => {}
4032                    std::task::Poll::Pending => return std::task::Poll::Pending,
4033                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4034                        this.is_terminated = true;
4035                        return std::task::Poll::Ready(None);
4036                    }
4037                    std::task::Poll::Ready(Err(e)) => {
4038                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4039                            e.into(),
4040                        ))));
4041                    }
4042                }
4043
4044                // A message has been received from the channel
4045                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4046
4047                std::task::Poll::Ready(Some(match header.ordinal {
4048                0x39c6e9001d102338 => {
4049                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4050                    let mut req = fidl::new_empty!(ChannelListenerRegistryListenL2capRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4051                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
4052                    let control_handle = ChannelListenerRegistryControlHandle {
4053                        inner: this.inner.clone(),
4054                    };
4055                    Ok(ChannelListenerRegistryRequest::ListenL2cap {payload: req,
4056                        responder: ChannelListenerRegistryListenL2capResponder {
4057                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4058                            tx_id: header.tx_id,
4059                        },
4060                    })
4061                }
4062                _ => Err(fidl::Error::UnknownOrdinal {
4063                    ordinal: header.ordinal,
4064                    protocol_name: <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4065                }),
4066            }))
4067            },
4068        )
4069    }
4070}
4071
4072/// Represents the ability to register and accept incoming connections on
4073/// connection oriented channels.
4074#[derive(Debug)]
4075pub enum ChannelListenerRegistryRequest {
4076    /// Register a listener for incoming channels. The registry will assign a
4077    /// PSM value that is unique for the local device, as well as open a
4078    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
4079    /// event that all PSMs have been assigned, this call will fail with
4080    /// `ZX_ERR_NO_RESOURCES`.
4081    ///
4082    /// Note that the method of service discovery or advertising is defined by
4083    /// the service or protocol, so it is the responsibility of the caller to
4084    /// communicate the assigned PSM to any clients.
4085    ListenL2cap {
4086        payload: ChannelListenerRegistryListenL2capRequest,
4087        responder: ChannelListenerRegistryListenL2capResponder,
4088    },
4089}
4090
4091impl ChannelListenerRegistryRequest {
4092    #[allow(irrefutable_let_patterns)]
4093    pub fn into_listen_l2cap(
4094        self,
4095    ) -> Option<(
4096        ChannelListenerRegistryListenL2capRequest,
4097        ChannelListenerRegistryListenL2capResponder,
4098    )> {
4099        if let ChannelListenerRegistryRequest::ListenL2cap { payload, responder } = self {
4100            Some((payload, responder))
4101        } else {
4102            None
4103        }
4104    }
4105
4106    /// Name of the method defined in FIDL
4107    pub fn method_name(&self) -> &'static str {
4108        match *self {
4109            ChannelListenerRegistryRequest::ListenL2cap { .. } => "listen_l2cap",
4110        }
4111    }
4112}
4113
4114#[derive(Debug, Clone)]
4115pub struct ChannelListenerRegistryControlHandle {
4116    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4117}
4118
4119impl fidl::endpoints::ControlHandle for ChannelListenerRegistryControlHandle {
4120    fn shutdown(&self) {
4121        self.inner.shutdown()
4122    }
4123
4124    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4125        self.inner.shutdown_with_epitaph(status)
4126    }
4127
4128    fn is_closed(&self) -> bool {
4129        self.inner.channel().is_closed()
4130    }
4131    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4132        self.inner.channel().on_closed()
4133    }
4134
4135    #[cfg(target_os = "fuchsia")]
4136    fn signal_peer(
4137        &self,
4138        clear_mask: zx::Signals,
4139        set_mask: zx::Signals,
4140    ) -> Result<(), zx_status::Status> {
4141        use fidl::Peered;
4142        self.inner.channel().signal_peer(clear_mask, set_mask)
4143    }
4144}
4145
4146impl ChannelListenerRegistryControlHandle {}
4147
4148#[must_use = "FIDL methods require a response to be sent"]
4149#[derive(Debug)]
4150pub struct ChannelListenerRegistryListenL2capResponder {
4151    control_handle: std::mem::ManuallyDrop<ChannelListenerRegistryControlHandle>,
4152    tx_id: u32,
4153}
4154
4155/// Set the the channel to be shutdown (see [`ChannelListenerRegistryControlHandle::shutdown`])
4156/// if the responder is dropped without sending a response, so that the client
4157/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4158impl std::ops::Drop for ChannelListenerRegistryListenL2capResponder {
4159    fn drop(&mut self) {
4160        self.control_handle.shutdown();
4161        // Safety: drops once, never accessed again
4162        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4163    }
4164}
4165
4166impl fidl::endpoints::Responder for ChannelListenerRegistryListenL2capResponder {
4167    type ControlHandle = ChannelListenerRegistryControlHandle;
4168
4169    fn control_handle(&self) -> &ChannelListenerRegistryControlHandle {
4170        &self.control_handle
4171    }
4172
4173    fn drop_without_shutdown(mut self) {
4174        // Safety: drops once, never accessed again due to mem::forget
4175        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4176        // Prevent Drop from running (which would shut down the channel)
4177        std::mem::forget(self);
4178    }
4179}
4180
4181impl ChannelListenerRegistryListenL2capResponder {
4182    /// Sends a response to the FIDL transaction.
4183    ///
4184    /// Sets the channel to shutdown if an error occurs.
4185    pub fn send(
4186        self,
4187        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4188    ) -> Result<(), fidl::Error> {
4189        let _result = self.send_raw(result);
4190        if _result.is_err() {
4191            self.control_handle.shutdown();
4192        }
4193        self.drop_without_shutdown();
4194        _result
4195    }
4196
4197    /// Similar to "send" but does not shutdown the channel if an error occurs.
4198    pub fn send_no_shutdown_on_err(
4199        self,
4200        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4201    ) -> Result<(), fidl::Error> {
4202        let _result = self.send_raw(result);
4203        self.drop_without_shutdown();
4204        _result
4205    }
4206
4207    fn send_raw(
4208        &self,
4209        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4210    ) -> Result<(), fidl::Error> {
4211        self.control_handle.inner.send::<fidl::encoding::ResultType<
4212            ChannelListenerRegistryListenL2capResponse,
4213            i32,
4214        >>(
4215            result,
4216            self.tx_id,
4217            0x39c6e9001d102338,
4218            fidl::encoding::DynamicFlags::empty(),
4219        )
4220    }
4221}
4222
4223#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4224pub struct CodecDelayMarker;
4225
4226impl fidl::endpoints::ProtocolMarker for CodecDelayMarker {
4227    type Proxy = CodecDelayProxy;
4228    type RequestStream = CodecDelayRequestStream;
4229    #[cfg(target_os = "fuchsia")]
4230    type SynchronousProxy = CodecDelaySynchronousProxy;
4231
4232    const DEBUG_NAME: &'static str = "(anonymous) CodecDelay";
4233}
4234pub type CodecDelayGetCodecLocalDelayRangeResult =
4235    Result<CodecDelayGetCodecLocalDelayRangeResponse, i32>;
4236
4237pub trait CodecDelayProxyInterface: Send + Sync {
4238    type GetCodecLocalDelayRangeResponseFut: std::future::Future<Output = Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error>>
4239        + Send;
4240    fn r#get_codec_local_delay_range(
4241        &self,
4242        payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4243    ) -> Self::GetCodecLocalDelayRangeResponseFut;
4244}
4245#[derive(Debug)]
4246#[cfg(target_os = "fuchsia")]
4247pub struct CodecDelaySynchronousProxy {
4248    client: fidl::client::sync::Client,
4249}
4250
4251#[cfg(target_os = "fuchsia")]
4252impl fidl::endpoints::SynchronousProxy for CodecDelaySynchronousProxy {
4253    type Proxy = CodecDelayProxy;
4254    type Protocol = CodecDelayMarker;
4255
4256    fn from_channel(inner: fidl::Channel) -> Self {
4257        Self::new(inner)
4258    }
4259
4260    fn into_channel(self) -> fidl::Channel {
4261        self.client.into_channel()
4262    }
4263
4264    fn as_channel(&self) -> &fidl::Channel {
4265        self.client.as_channel()
4266    }
4267}
4268
4269#[cfg(target_os = "fuchsia")]
4270impl CodecDelaySynchronousProxy {
4271    pub fn new(channel: fidl::Channel) -> Self {
4272        let protocol_name = <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4273        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4274    }
4275
4276    pub fn into_channel(self) -> fidl::Channel {
4277        self.client.into_channel()
4278    }
4279
4280    /// Waits until an event arrives and returns it. It is safe for other
4281    /// threads to make concurrent requests while waiting for an event.
4282    pub fn wait_for_event(
4283        &self,
4284        deadline: zx::MonotonicInstant,
4285    ) -> Result<CodecDelayEvent, fidl::Error> {
4286        CodecDelayEvent::decode(self.client.wait_for_event(deadline)?)
4287    }
4288
4289    /// Retrieve the range of controller delay for the codec specified with the provided stream
4290    /// attributes.
4291    ///
4292    /// On success, returns the minimum and maximum allowed delay.
4293    ///
4294    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
4295    /// Returns ZX_ERR_INTERNAL for all other failures.
4296    pub fn r#get_codec_local_delay_range(
4297        &self,
4298        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4299        ___deadline: zx::MonotonicInstant,
4300    ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
4301        let _response = self.client.send_query::<
4302            CodecDelayGetCodecLocalDelayRangeRequest,
4303            fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4304        >(
4305            payload,
4306            0x1cf34fdeed80b4d,
4307            fidl::encoding::DynamicFlags::empty(),
4308            ___deadline,
4309        )?;
4310        Ok(_response.map(|x| x))
4311    }
4312}
4313
4314#[cfg(target_os = "fuchsia")]
4315impl From<CodecDelaySynchronousProxy> for zx::NullableHandle {
4316    fn from(value: CodecDelaySynchronousProxy) -> Self {
4317        value.into_channel().into()
4318    }
4319}
4320
4321#[cfg(target_os = "fuchsia")]
4322impl From<fidl::Channel> for CodecDelaySynchronousProxy {
4323    fn from(value: fidl::Channel) -> Self {
4324        Self::new(value)
4325    }
4326}
4327
4328#[cfg(target_os = "fuchsia")]
4329impl fidl::endpoints::FromClient for CodecDelaySynchronousProxy {
4330    type Protocol = CodecDelayMarker;
4331
4332    fn from_client(value: fidl::endpoints::ClientEnd<CodecDelayMarker>) -> Self {
4333        Self::new(value.into_channel())
4334    }
4335}
4336
4337#[derive(Debug, Clone)]
4338pub struct CodecDelayProxy {
4339    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4340}
4341
4342impl fidl::endpoints::Proxy for CodecDelayProxy {
4343    type Protocol = CodecDelayMarker;
4344
4345    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4346        Self::new(inner)
4347    }
4348
4349    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4350        self.client.into_channel().map_err(|client| Self { client })
4351    }
4352
4353    fn as_channel(&self) -> &::fidl::AsyncChannel {
4354        self.client.as_channel()
4355    }
4356}
4357
4358impl CodecDelayProxy {
4359    /// Create a new Proxy for fuchsia.bluetooth.le/CodecDelay.
4360    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4361        let protocol_name = <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4362        Self { client: fidl::client::Client::new(channel, protocol_name) }
4363    }
4364
4365    /// Get a Stream of events from the remote end of the protocol.
4366    ///
4367    /// # Panics
4368    ///
4369    /// Panics if the event stream was already taken.
4370    pub fn take_event_stream(&self) -> CodecDelayEventStream {
4371        CodecDelayEventStream { event_receiver: self.client.take_event_receiver() }
4372    }
4373
4374    /// Retrieve the range of controller delay for the codec specified with the provided stream
4375    /// attributes.
4376    ///
4377    /// On success, returns the minimum and maximum allowed delay.
4378    ///
4379    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
4380    /// Returns ZX_ERR_INTERNAL for all other failures.
4381    pub fn r#get_codec_local_delay_range(
4382        &self,
4383        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4384    ) -> fidl::client::QueryResponseFut<
4385        CodecDelayGetCodecLocalDelayRangeResult,
4386        fidl::encoding::DefaultFuchsiaResourceDialect,
4387    > {
4388        CodecDelayProxyInterface::r#get_codec_local_delay_range(self, payload)
4389    }
4390}
4391
4392impl CodecDelayProxyInterface for CodecDelayProxy {
4393    type GetCodecLocalDelayRangeResponseFut = fidl::client::QueryResponseFut<
4394        CodecDelayGetCodecLocalDelayRangeResult,
4395        fidl::encoding::DefaultFuchsiaResourceDialect,
4396    >;
4397    fn r#get_codec_local_delay_range(
4398        &self,
4399        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4400    ) -> Self::GetCodecLocalDelayRangeResponseFut {
4401        fn _decode(
4402            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4403        ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
4404            let _response = fidl::client::decode_transaction_body::<
4405                fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4406                fidl::encoding::DefaultFuchsiaResourceDialect,
4407                0x1cf34fdeed80b4d,
4408            >(_buf?)?;
4409            Ok(_response.map(|x| x))
4410        }
4411        self.client.send_query_and_decode::<
4412            CodecDelayGetCodecLocalDelayRangeRequest,
4413            CodecDelayGetCodecLocalDelayRangeResult,
4414        >(
4415            payload,
4416            0x1cf34fdeed80b4d,
4417            fidl::encoding::DynamicFlags::empty(),
4418            _decode,
4419        )
4420    }
4421}
4422
4423pub struct CodecDelayEventStream {
4424    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4425}
4426
4427impl std::marker::Unpin for CodecDelayEventStream {}
4428
4429impl futures::stream::FusedStream for CodecDelayEventStream {
4430    fn is_terminated(&self) -> bool {
4431        self.event_receiver.is_terminated()
4432    }
4433}
4434
4435impl futures::Stream for CodecDelayEventStream {
4436    type Item = Result<CodecDelayEvent, fidl::Error>;
4437
4438    fn poll_next(
4439        mut self: std::pin::Pin<&mut Self>,
4440        cx: &mut std::task::Context<'_>,
4441    ) -> std::task::Poll<Option<Self::Item>> {
4442        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4443            &mut self.event_receiver,
4444            cx
4445        )?) {
4446            Some(buf) => std::task::Poll::Ready(Some(CodecDelayEvent::decode(buf))),
4447            None => std::task::Poll::Ready(None),
4448        }
4449    }
4450}
4451
4452#[derive(Debug)]
4453pub enum CodecDelayEvent {}
4454
4455impl CodecDelayEvent {
4456    /// Decodes a message buffer as a [`CodecDelayEvent`].
4457    fn decode(
4458        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4459    ) -> Result<CodecDelayEvent, fidl::Error> {
4460        let (bytes, _handles) = buf.split_mut();
4461        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4462        debug_assert_eq!(tx_header.tx_id, 0);
4463        match tx_header.ordinal {
4464            _ => Err(fidl::Error::UnknownOrdinal {
4465                ordinal: tx_header.ordinal,
4466                protocol_name: <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4467            }),
4468        }
4469    }
4470}
4471
4472/// A Stream of incoming requests for fuchsia.bluetooth.le/CodecDelay.
4473pub struct CodecDelayRequestStream {
4474    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4475    is_terminated: bool,
4476}
4477
4478impl std::marker::Unpin for CodecDelayRequestStream {}
4479
4480impl futures::stream::FusedStream for CodecDelayRequestStream {
4481    fn is_terminated(&self) -> bool {
4482        self.is_terminated
4483    }
4484}
4485
4486impl fidl::endpoints::RequestStream for CodecDelayRequestStream {
4487    type Protocol = CodecDelayMarker;
4488    type ControlHandle = CodecDelayControlHandle;
4489
4490    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4491        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4492    }
4493
4494    fn control_handle(&self) -> Self::ControlHandle {
4495        CodecDelayControlHandle { inner: self.inner.clone() }
4496    }
4497
4498    fn into_inner(
4499        self,
4500    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4501    {
4502        (self.inner, self.is_terminated)
4503    }
4504
4505    fn from_inner(
4506        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4507        is_terminated: bool,
4508    ) -> Self {
4509        Self { inner, is_terminated }
4510    }
4511}
4512
4513impl futures::Stream for CodecDelayRequestStream {
4514    type Item = Result<CodecDelayRequest, fidl::Error>;
4515
4516    fn poll_next(
4517        mut self: std::pin::Pin<&mut Self>,
4518        cx: &mut std::task::Context<'_>,
4519    ) -> std::task::Poll<Option<Self::Item>> {
4520        let this = &mut *self;
4521        if this.inner.check_shutdown(cx) {
4522            this.is_terminated = true;
4523            return std::task::Poll::Ready(None);
4524        }
4525        if this.is_terminated {
4526            panic!("polled CodecDelayRequestStream after completion");
4527        }
4528        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4529            |bytes, handles| {
4530                match this.inner.channel().read_etc(cx, bytes, handles) {
4531                    std::task::Poll::Ready(Ok(())) => {}
4532                    std::task::Poll::Pending => return std::task::Poll::Pending,
4533                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4534                        this.is_terminated = true;
4535                        return std::task::Poll::Ready(None);
4536                    }
4537                    std::task::Poll::Ready(Err(e)) => {
4538                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4539                            e.into(),
4540                        ))));
4541                    }
4542                }
4543
4544                // A message has been received from the channel
4545                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4546
4547                std::task::Poll::Ready(Some(match header.ordinal {
4548                    0x1cf34fdeed80b4d => {
4549                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4550                        let mut req = fidl::new_empty!(
4551                            CodecDelayGetCodecLocalDelayRangeRequest,
4552                            fidl::encoding::DefaultFuchsiaResourceDialect
4553                        );
4554                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecDelayGetCodecLocalDelayRangeRequest>(&header, _body_bytes, handles, &mut req)?;
4555                        let control_handle = CodecDelayControlHandle { inner: this.inner.clone() };
4556                        Ok(CodecDelayRequest::GetCodecLocalDelayRange {
4557                            payload: req,
4558                            responder: CodecDelayGetCodecLocalDelayRangeResponder {
4559                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4560                                tx_id: header.tx_id,
4561                            },
4562                        })
4563                    }
4564                    _ => Err(fidl::Error::UnknownOrdinal {
4565                        ordinal: header.ordinal,
4566                        protocol_name:
4567                            <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4568                    }),
4569                }))
4570            },
4571        )
4572    }
4573}
4574
4575/// This protocol allows us to retrieve controller local delay values. It is not intended to be
4576/// used stand-alone, but to be composed into protocols that need access to this information.
4577#[derive(Debug)]
4578pub enum CodecDelayRequest {
4579    /// Retrieve the range of controller delay for the codec specified with the provided stream
4580    /// attributes.
4581    ///
4582    /// On success, returns the minimum and maximum allowed delay.
4583    ///
4584    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
4585    /// Returns ZX_ERR_INTERNAL for all other failures.
4586    GetCodecLocalDelayRange {
4587        payload: CodecDelayGetCodecLocalDelayRangeRequest,
4588        responder: CodecDelayGetCodecLocalDelayRangeResponder,
4589    },
4590}
4591
4592impl CodecDelayRequest {
4593    #[allow(irrefutable_let_patterns)]
4594    pub fn into_get_codec_local_delay_range(
4595        self,
4596    ) -> Option<(
4597        CodecDelayGetCodecLocalDelayRangeRequest,
4598        CodecDelayGetCodecLocalDelayRangeResponder,
4599    )> {
4600        if let CodecDelayRequest::GetCodecLocalDelayRange { payload, responder } = self {
4601            Some((payload, responder))
4602        } else {
4603            None
4604        }
4605    }
4606
4607    /// Name of the method defined in FIDL
4608    pub fn method_name(&self) -> &'static str {
4609        match *self {
4610            CodecDelayRequest::GetCodecLocalDelayRange { .. } => "get_codec_local_delay_range",
4611        }
4612    }
4613}
4614
4615#[derive(Debug, Clone)]
4616pub struct CodecDelayControlHandle {
4617    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4618}
4619
4620impl fidl::endpoints::ControlHandle for CodecDelayControlHandle {
4621    fn shutdown(&self) {
4622        self.inner.shutdown()
4623    }
4624
4625    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4626        self.inner.shutdown_with_epitaph(status)
4627    }
4628
4629    fn is_closed(&self) -> bool {
4630        self.inner.channel().is_closed()
4631    }
4632    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4633        self.inner.channel().on_closed()
4634    }
4635
4636    #[cfg(target_os = "fuchsia")]
4637    fn signal_peer(
4638        &self,
4639        clear_mask: zx::Signals,
4640        set_mask: zx::Signals,
4641    ) -> Result<(), zx_status::Status> {
4642        use fidl::Peered;
4643        self.inner.channel().signal_peer(clear_mask, set_mask)
4644    }
4645}
4646
4647impl CodecDelayControlHandle {}
4648
4649#[must_use = "FIDL methods require a response to be sent"]
4650#[derive(Debug)]
4651pub struct CodecDelayGetCodecLocalDelayRangeResponder {
4652    control_handle: std::mem::ManuallyDrop<CodecDelayControlHandle>,
4653    tx_id: u32,
4654}
4655
4656/// Set the the channel to be shutdown (see [`CodecDelayControlHandle::shutdown`])
4657/// if the responder is dropped without sending a response, so that the client
4658/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4659impl std::ops::Drop for CodecDelayGetCodecLocalDelayRangeResponder {
4660    fn drop(&mut self) {
4661        self.control_handle.shutdown();
4662        // Safety: drops once, never accessed again
4663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4664    }
4665}
4666
4667impl fidl::endpoints::Responder for CodecDelayGetCodecLocalDelayRangeResponder {
4668    type ControlHandle = CodecDelayControlHandle;
4669
4670    fn control_handle(&self) -> &CodecDelayControlHandle {
4671        &self.control_handle
4672    }
4673
4674    fn drop_without_shutdown(mut self) {
4675        // Safety: drops once, never accessed again due to mem::forget
4676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4677        // Prevent Drop from running (which would shut down the channel)
4678        std::mem::forget(self);
4679    }
4680}
4681
4682impl CodecDelayGetCodecLocalDelayRangeResponder {
4683    /// Sends a response to the FIDL transaction.
4684    ///
4685    /// Sets the channel to shutdown if an error occurs.
4686    pub fn send(
4687        self,
4688        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4689    ) -> Result<(), fidl::Error> {
4690        let _result = self.send_raw(result);
4691        if _result.is_err() {
4692            self.control_handle.shutdown();
4693        }
4694        self.drop_without_shutdown();
4695        _result
4696    }
4697
4698    /// Similar to "send" but does not shutdown the channel if an error occurs.
4699    pub fn send_no_shutdown_on_err(
4700        self,
4701        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4702    ) -> Result<(), fidl::Error> {
4703        let _result = self.send_raw(result);
4704        self.drop_without_shutdown();
4705        _result
4706    }
4707
4708    fn send_raw(
4709        &self,
4710        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4711    ) -> Result<(), fidl::Error> {
4712        self.control_handle.inner.send::<fidl::encoding::ResultType<
4713            CodecDelayGetCodecLocalDelayRangeResponse,
4714            i32,
4715        >>(
4716            result,
4717            self.tx_id,
4718            0x1cf34fdeed80b4d,
4719            fidl::encoding::DynamicFlags::empty(),
4720        )
4721    }
4722}
4723
4724#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4725pub struct ConnectedIsochronousGroupMarker;
4726
4727impl fidl::endpoints::ProtocolMarker for ConnectedIsochronousGroupMarker {
4728    type Proxy = ConnectedIsochronousGroupProxy;
4729    type RequestStream = ConnectedIsochronousGroupRequestStream;
4730    #[cfg(target_os = "fuchsia")]
4731    type SynchronousProxy = ConnectedIsochronousGroupSynchronousProxy;
4732
4733    const DEBUG_NAME: &'static str = "(anonymous) ConnectedIsochronousGroup";
4734}
4735pub type ConnectedIsochronousGroupEstablishStreamsResult = Result<(), EstablishStreamsError>;
4736
4737pub trait ConnectedIsochronousGroupProxyInterface: Send + Sync {
4738    type EstablishStreamsResponseFut: std::future::Future<
4739            Output = Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error>,
4740        > + Send;
4741    fn r#establish_streams(
4742        &self,
4743        payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4744    ) -> Self::EstablishStreamsResponseFut;
4745    fn r#remove(&self) -> Result<(), fidl::Error>;
4746}
4747#[derive(Debug)]
4748#[cfg(target_os = "fuchsia")]
4749pub struct ConnectedIsochronousGroupSynchronousProxy {
4750    client: fidl::client::sync::Client,
4751}
4752
4753#[cfg(target_os = "fuchsia")]
4754impl fidl::endpoints::SynchronousProxy for ConnectedIsochronousGroupSynchronousProxy {
4755    type Proxy = ConnectedIsochronousGroupProxy;
4756    type Protocol = ConnectedIsochronousGroupMarker;
4757
4758    fn from_channel(inner: fidl::Channel) -> Self {
4759        Self::new(inner)
4760    }
4761
4762    fn into_channel(self) -> fidl::Channel {
4763        self.client.into_channel()
4764    }
4765
4766    fn as_channel(&self) -> &fidl::Channel {
4767        self.client.as_channel()
4768    }
4769}
4770
4771#[cfg(target_os = "fuchsia")]
4772impl ConnectedIsochronousGroupSynchronousProxy {
4773    pub fn new(channel: fidl::Channel) -> Self {
4774        let protocol_name =
4775            <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4776        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4777    }
4778
4779    pub fn into_channel(self) -> fidl::Channel {
4780        self.client.into_channel()
4781    }
4782
4783    /// Waits until an event arrives and returns it. It is safe for other
4784    /// threads to make concurrent requests while waiting for an event.
4785    pub fn wait_for_event(
4786        &self,
4787        deadline: zx::MonotonicInstant,
4788    ) -> Result<ConnectedIsochronousGroupEvent, fidl::Error> {
4789        ConnectedIsochronousGroupEvent::decode(self.client.wait_for_event(deadline)?)
4790    }
4791
4792    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
4793    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
4794    /// be sent on the IsochronousStream.
4795    ///
4796    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
4797    /// returned.
4798    ///
4799    /// Otherwise, this call returns once each CIS specified has connected.
4800    pub fn r#establish_streams(
4801        &self,
4802        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4803        ___deadline: zx::MonotonicInstant,
4804    ) -> Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error> {
4805        let _response = self.client.send_query::<
4806            ConnectedIsochronousGroupEstablishStreamsRequest,
4807            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EstablishStreamsError>,
4808        >(
4809            payload,
4810            0xc7296c5edb4dacc,
4811            fidl::encoding::DynamicFlags::FLEXIBLE,
4812            ___deadline,
4813        )?
4814        .into_result::<ConnectedIsochronousGroupMarker>("establish_streams")?;
4815        Ok(_response.map(|x| x))
4816    }
4817
4818    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
4819    /// all of the associated streams have closed and the group has been removed.
4820    pub fn r#remove(&self) -> Result<(), fidl::Error> {
4821        self.client.send::<fidl::encoding::EmptyPayload>(
4822            (),
4823            0xbed433babd20503,
4824            fidl::encoding::DynamicFlags::FLEXIBLE,
4825        )
4826    }
4827}
4828
4829#[cfg(target_os = "fuchsia")]
4830impl From<ConnectedIsochronousGroupSynchronousProxy> for zx::NullableHandle {
4831    fn from(value: ConnectedIsochronousGroupSynchronousProxy) -> Self {
4832        value.into_channel().into()
4833    }
4834}
4835
4836#[cfg(target_os = "fuchsia")]
4837impl From<fidl::Channel> for ConnectedIsochronousGroupSynchronousProxy {
4838    fn from(value: fidl::Channel) -> Self {
4839        Self::new(value)
4840    }
4841}
4842
4843#[cfg(target_os = "fuchsia")]
4844impl fidl::endpoints::FromClient for ConnectedIsochronousGroupSynchronousProxy {
4845    type Protocol = ConnectedIsochronousGroupMarker;
4846
4847    fn from_client(value: fidl::endpoints::ClientEnd<ConnectedIsochronousGroupMarker>) -> Self {
4848        Self::new(value.into_channel())
4849    }
4850}
4851
4852#[derive(Debug, Clone)]
4853pub struct ConnectedIsochronousGroupProxy {
4854    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4855}
4856
4857impl fidl::endpoints::Proxy for ConnectedIsochronousGroupProxy {
4858    type Protocol = ConnectedIsochronousGroupMarker;
4859
4860    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4861        Self::new(inner)
4862    }
4863
4864    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4865        self.client.into_channel().map_err(|client| Self { client })
4866    }
4867
4868    fn as_channel(&self) -> &::fidl::AsyncChannel {
4869        self.client.as_channel()
4870    }
4871}
4872
4873impl ConnectedIsochronousGroupProxy {
4874    /// Create a new Proxy for fuchsia.bluetooth.le/ConnectedIsochronousGroup.
4875    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4876        let protocol_name =
4877            <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4878        Self { client: fidl::client::Client::new(channel, protocol_name) }
4879    }
4880
4881    /// Get a Stream of events from the remote end of the protocol.
4882    ///
4883    /// # Panics
4884    ///
4885    /// Panics if the event stream was already taken.
4886    pub fn take_event_stream(&self) -> ConnectedIsochronousGroupEventStream {
4887        ConnectedIsochronousGroupEventStream { event_receiver: self.client.take_event_receiver() }
4888    }
4889
4890    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
4891    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
4892    /// be sent on the IsochronousStream.
4893    ///
4894    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
4895    /// returned.
4896    ///
4897    /// Otherwise, this call returns once each CIS specified has connected.
4898    pub fn r#establish_streams(
4899        &self,
4900        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4901    ) -> fidl::client::QueryResponseFut<
4902        ConnectedIsochronousGroupEstablishStreamsResult,
4903        fidl::encoding::DefaultFuchsiaResourceDialect,
4904    > {
4905        ConnectedIsochronousGroupProxyInterface::r#establish_streams(self, payload)
4906    }
4907
4908    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
4909    /// all of the associated streams have closed and the group has been removed.
4910    pub fn r#remove(&self) -> Result<(), fidl::Error> {
4911        ConnectedIsochronousGroupProxyInterface::r#remove(self)
4912    }
4913}
4914
4915impl ConnectedIsochronousGroupProxyInterface for ConnectedIsochronousGroupProxy {
4916    type EstablishStreamsResponseFut = fidl::client::QueryResponseFut<
4917        ConnectedIsochronousGroupEstablishStreamsResult,
4918        fidl::encoding::DefaultFuchsiaResourceDialect,
4919    >;
4920    fn r#establish_streams(
4921        &self,
4922        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4923    ) -> Self::EstablishStreamsResponseFut {
4924        fn _decode(
4925            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4926        ) -> Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error> {
4927            let _response = fidl::client::decode_transaction_body::<
4928                fidl::encoding::FlexibleResultType<
4929                    fidl::encoding::EmptyStruct,
4930                    EstablishStreamsError,
4931                >,
4932                fidl::encoding::DefaultFuchsiaResourceDialect,
4933                0xc7296c5edb4dacc,
4934            >(_buf?)?
4935            .into_result::<ConnectedIsochronousGroupMarker>("establish_streams")?;
4936            Ok(_response.map(|x| x))
4937        }
4938        self.client.send_query_and_decode::<
4939            ConnectedIsochronousGroupEstablishStreamsRequest,
4940            ConnectedIsochronousGroupEstablishStreamsResult,
4941        >(
4942            payload,
4943            0xc7296c5edb4dacc,
4944            fidl::encoding::DynamicFlags::FLEXIBLE,
4945            _decode,
4946        )
4947    }
4948
4949    fn r#remove(&self) -> Result<(), fidl::Error> {
4950        self.client.send::<fidl::encoding::EmptyPayload>(
4951            (),
4952            0xbed433babd20503,
4953            fidl::encoding::DynamicFlags::FLEXIBLE,
4954        )
4955    }
4956}
4957
4958pub struct ConnectedIsochronousGroupEventStream {
4959    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4960}
4961
4962impl std::marker::Unpin for ConnectedIsochronousGroupEventStream {}
4963
4964impl futures::stream::FusedStream for ConnectedIsochronousGroupEventStream {
4965    fn is_terminated(&self) -> bool {
4966        self.event_receiver.is_terminated()
4967    }
4968}
4969
4970impl futures::Stream for ConnectedIsochronousGroupEventStream {
4971    type Item = Result<ConnectedIsochronousGroupEvent, fidl::Error>;
4972
4973    fn poll_next(
4974        mut self: std::pin::Pin<&mut Self>,
4975        cx: &mut std::task::Context<'_>,
4976    ) -> std::task::Poll<Option<Self::Item>> {
4977        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4978            &mut self.event_receiver,
4979            cx
4980        )?) {
4981            Some(buf) => std::task::Poll::Ready(Some(ConnectedIsochronousGroupEvent::decode(buf))),
4982            None => std::task::Poll::Ready(None),
4983        }
4984    }
4985}
4986
4987#[derive(Debug)]
4988pub enum ConnectedIsochronousGroupEvent {
4989    #[non_exhaustive]
4990    _UnknownEvent {
4991        /// Ordinal of the event that was sent.
4992        ordinal: u64,
4993    },
4994}
4995
4996impl ConnectedIsochronousGroupEvent {
4997    /// Decodes a message buffer as a [`ConnectedIsochronousGroupEvent`].
4998    fn decode(
4999        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5000    ) -> Result<ConnectedIsochronousGroupEvent, fidl::Error> {
5001        let (bytes, _handles) = buf.split_mut();
5002        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5003        debug_assert_eq!(tx_header.tx_id, 0);
5004        match tx_header.ordinal {
5005            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5006                Ok(ConnectedIsochronousGroupEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5007            }
5008            _ => Err(fidl::Error::UnknownOrdinal {
5009                ordinal: tx_header.ordinal,
5010                protocol_name:
5011                    <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5012            }),
5013        }
5014    }
5015}
5016
5017/// A Stream of incoming requests for fuchsia.bluetooth.le/ConnectedIsochronousGroup.
5018pub struct ConnectedIsochronousGroupRequestStream {
5019    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5020    is_terminated: bool,
5021}
5022
5023impl std::marker::Unpin for ConnectedIsochronousGroupRequestStream {}
5024
5025impl futures::stream::FusedStream for ConnectedIsochronousGroupRequestStream {
5026    fn is_terminated(&self) -> bool {
5027        self.is_terminated
5028    }
5029}
5030
5031impl fidl::endpoints::RequestStream for ConnectedIsochronousGroupRequestStream {
5032    type Protocol = ConnectedIsochronousGroupMarker;
5033    type ControlHandle = ConnectedIsochronousGroupControlHandle;
5034
5035    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5036        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5037    }
5038
5039    fn control_handle(&self) -> Self::ControlHandle {
5040        ConnectedIsochronousGroupControlHandle { inner: self.inner.clone() }
5041    }
5042
5043    fn into_inner(
5044        self,
5045    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5046    {
5047        (self.inner, self.is_terminated)
5048    }
5049
5050    fn from_inner(
5051        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5052        is_terminated: bool,
5053    ) -> Self {
5054        Self { inner, is_terminated }
5055    }
5056}
5057
5058impl futures::Stream for ConnectedIsochronousGroupRequestStream {
5059    type Item = Result<ConnectedIsochronousGroupRequest, fidl::Error>;
5060
5061    fn poll_next(
5062        mut self: std::pin::Pin<&mut Self>,
5063        cx: &mut std::task::Context<'_>,
5064    ) -> std::task::Poll<Option<Self::Item>> {
5065        let this = &mut *self;
5066        if this.inner.check_shutdown(cx) {
5067            this.is_terminated = true;
5068            return std::task::Poll::Ready(None);
5069        }
5070        if this.is_terminated {
5071            panic!("polled ConnectedIsochronousGroupRequestStream after completion");
5072        }
5073        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5074            |bytes, handles| {
5075                match this.inner.channel().read_etc(cx, bytes, handles) {
5076                    std::task::Poll::Ready(Ok(())) => {}
5077                    std::task::Poll::Pending => return std::task::Poll::Pending,
5078                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5079                        this.is_terminated = true;
5080                        return std::task::Poll::Ready(None);
5081                    }
5082                    std::task::Poll::Ready(Err(e)) => {
5083                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5084                            e.into(),
5085                        ))));
5086                    }
5087                }
5088
5089                // A message has been received from the channel
5090                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5091
5092                std::task::Poll::Ready(Some(match header.ordinal {
5093                0xc7296c5edb4dacc => {
5094                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5095                    let mut req = fidl::new_empty!(ConnectedIsochronousGroupEstablishStreamsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5096                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectedIsochronousGroupEstablishStreamsRequest>(&header, _body_bytes, handles, &mut req)?;
5097                    let control_handle = ConnectedIsochronousGroupControlHandle {
5098                        inner: this.inner.clone(),
5099                    };
5100                    Ok(ConnectedIsochronousGroupRequest::EstablishStreams {payload: req,
5101                        responder: ConnectedIsochronousGroupEstablishStreamsResponder {
5102                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5103                            tx_id: header.tx_id,
5104                        },
5105                    })
5106                }
5107                0xbed433babd20503 => {
5108                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5109                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5110                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5111                    let control_handle = ConnectedIsochronousGroupControlHandle {
5112                        inner: this.inner.clone(),
5113                    };
5114                    Ok(ConnectedIsochronousGroupRequest::Remove {
5115                        control_handle,
5116                    })
5117                }
5118                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5119                    Ok(ConnectedIsochronousGroupRequest::_UnknownMethod {
5120                        ordinal: header.ordinal,
5121                        control_handle: ConnectedIsochronousGroupControlHandle { inner: this.inner.clone() },
5122                        method_type: fidl::MethodType::OneWay,
5123                    })
5124                }
5125                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5126                    this.inner.send_framework_err(
5127                        fidl::encoding::FrameworkErr::UnknownMethod,
5128                        header.tx_id,
5129                        header.ordinal,
5130                        header.dynamic_flags(),
5131                        (bytes, handles),
5132                    )?;
5133                    Ok(ConnectedIsochronousGroupRequest::_UnknownMethod {
5134                        ordinal: header.ordinal,
5135                        control_handle: ConnectedIsochronousGroupControlHandle { inner: this.inner.clone() },
5136                        method_type: fidl::MethodType::TwoWay,
5137                    })
5138                }
5139                _ => Err(fidl::Error::UnknownOrdinal {
5140                    ordinal: header.ordinal,
5141                    protocol_name: <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5142                }),
5143            }))
5144            },
5145        )
5146    }
5147}
5148
5149#[derive(Debug)]
5150pub enum ConnectedIsochronousGroupRequest {
5151    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
5152    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
5153    /// be sent on the IsochronousStream.
5154    ///
5155    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
5156    /// returned.
5157    ///
5158    /// Otherwise, this call returns once each CIS specified has connected.
5159    EstablishStreams {
5160        payload: ConnectedIsochronousGroupEstablishStreamsRequest,
5161        responder: ConnectedIsochronousGroupEstablishStreamsResponder,
5162    },
5163    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
5164    /// all of the associated streams have closed and the group has been removed.
5165    Remove { control_handle: ConnectedIsochronousGroupControlHandle },
5166    /// An interaction was received which does not match any known method.
5167    #[non_exhaustive]
5168    _UnknownMethod {
5169        /// Ordinal of the method that was called.
5170        ordinal: u64,
5171        control_handle: ConnectedIsochronousGroupControlHandle,
5172        method_type: fidl::MethodType,
5173    },
5174}
5175
5176impl ConnectedIsochronousGroupRequest {
5177    #[allow(irrefutable_let_patterns)]
5178    pub fn into_establish_streams(
5179        self,
5180    ) -> Option<(
5181        ConnectedIsochronousGroupEstablishStreamsRequest,
5182        ConnectedIsochronousGroupEstablishStreamsResponder,
5183    )> {
5184        if let ConnectedIsochronousGroupRequest::EstablishStreams { payload, responder } = self {
5185            Some((payload, responder))
5186        } else {
5187            None
5188        }
5189    }
5190
5191    #[allow(irrefutable_let_patterns)]
5192    pub fn into_remove(self) -> Option<(ConnectedIsochronousGroupControlHandle)> {
5193        if let ConnectedIsochronousGroupRequest::Remove { control_handle } = self {
5194            Some((control_handle))
5195        } else {
5196            None
5197        }
5198    }
5199
5200    /// Name of the method defined in FIDL
5201    pub fn method_name(&self) -> &'static str {
5202        match *self {
5203            ConnectedIsochronousGroupRequest::EstablishStreams { .. } => "establish_streams",
5204            ConnectedIsochronousGroupRequest::Remove { .. } => "remove",
5205            ConnectedIsochronousGroupRequest::_UnknownMethod {
5206                method_type: fidl::MethodType::OneWay,
5207                ..
5208            } => "unknown one-way method",
5209            ConnectedIsochronousGroupRequest::_UnknownMethod {
5210                method_type: fidl::MethodType::TwoWay,
5211                ..
5212            } => "unknown two-way method",
5213        }
5214    }
5215}
5216
5217#[derive(Debug, Clone)]
5218pub struct ConnectedIsochronousGroupControlHandle {
5219    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5220}
5221
5222impl fidl::endpoints::ControlHandle for ConnectedIsochronousGroupControlHandle {
5223    fn shutdown(&self) {
5224        self.inner.shutdown()
5225    }
5226
5227    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5228        self.inner.shutdown_with_epitaph(status)
5229    }
5230
5231    fn is_closed(&self) -> bool {
5232        self.inner.channel().is_closed()
5233    }
5234    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5235        self.inner.channel().on_closed()
5236    }
5237
5238    #[cfg(target_os = "fuchsia")]
5239    fn signal_peer(
5240        &self,
5241        clear_mask: zx::Signals,
5242        set_mask: zx::Signals,
5243    ) -> Result<(), zx_status::Status> {
5244        use fidl::Peered;
5245        self.inner.channel().signal_peer(clear_mask, set_mask)
5246    }
5247}
5248
5249impl ConnectedIsochronousGroupControlHandle {}
5250
5251#[must_use = "FIDL methods require a response to be sent"]
5252#[derive(Debug)]
5253pub struct ConnectedIsochronousGroupEstablishStreamsResponder {
5254    control_handle: std::mem::ManuallyDrop<ConnectedIsochronousGroupControlHandle>,
5255    tx_id: u32,
5256}
5257
5258/// Set the the channel to be shutdown (see [`ConnectedIsochronousGroupControlHandle::shutdown`])
5259/// if the responder is dropped without sending a response, so that the client
5260/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5261impl std::ops::Drop for ConnectedIsochronousGroupEstablishStreamsResponder {
5262    fn drop(&mut self) {
5263        self.control_handle.shutdown();
5264        // Safety: drops once, never accessed again
5265        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5266    }
5267}
5268
5269impl fidl::endpoints::Responder for ConnectedIsochronousGroupEstablishStreamsResponder {
5270    type ControlHandle = ConnectedIsochronousGroupControlHandle;
5271
5272    fn control_handle(&self) -> &ConnectedIsochronousGroupControlHandle {
5273        &self.control_handle
5274    }
5275
5276    fn drop_without_shutdown(mut self) {
5277        // Safety: drops once, never accessed again due to mem::forget
5278        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5279        // Prevent Drop from running (which would shut down the channel)
5280        std::mem::forget(self);
5281    }
5282}
5283
5284impl ConnectedIsochronousGroupEstablishStreamsResponder {
5285    /// Sends a response to the FIDL transaction.
5286    ///
5287    /// Sets the channel to shutdown if an error occurs.
5288    pub fn send(self, mut result: Result<(), EstablishStreamsError>) -> Result<(), fidl::Error> {
5289        let _result = self.send_raw(result);
5290        if _result.is_err() {
5291            self.control_handle.shutdown();
5292        }
5293        self.drop_without_shutdown();
5294        _result
5295    }
5296
5297    /// Similar to "send" but does not shutdown the channel if an error occurs.
5298    pub fn send_no_shutdown_on_err(
5299        self,
5300        mut result: Result<(), EstablishStreamsError>,
5301    ) -> Result<(), fidl::Error> {
5302        let _result = self.send_raw(result);
5303        self.drop_without_shutdown();
5304        _result
5305    }
5306
5307    fn send_raw(&self, mut result: Result<(), EstablishStreamsError>) -> Result<(), fidl::Error> {
5308        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5309            fidl::encoding::EmptyStruct,
5310            EstablishStreamsError,
5311        >>(
5312            fidl::encoding::FlexibleResult::new(result),
5313            self.tx_id,
5314            0xc7296c5edb4dacc,
5315            fidl::encoding::DynamicFlags::FLEXIBLE,
5316        )
5317    }
5318}
5319
5320#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5321pub struct ConnectionMarker;
5322
5323impl fidl::endpoints::ProtocolMarker for ConnectionMarker {
5324    type Proxy = ConnectionProxy;
5325    type RequestStream = ConnectionRequestStream;
5326    #[cfg(target_os = "fuchsia")]
5327    type SynchronousProxy = ConnectionSynchronousProxy;
5328
5329    const DEBUG_NAME: &'static str = "(anonymous) Connection";
5330}
5331pub type ConnectionTransferPeriodicAdvertisingSyncResult =
5332    Result<(), PeriodicAdvertisingSyncTransferError>;
5333pub type ConnectionAcceptPeriodicAdvertisingSyncTransferResult =
5334    Result<(), PeriodicAdvertisingSyncTransferError>;
5335
5336pub trait ConnectionProxyInterface: Send + Sync {
5337    type GetCodecLocalDelayRangeResponseFut: std::future::Future<Output = Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error>>
5338        + Send;
5339    fn r#get_codec_local_delay_range(
5340        &self,
5341        payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5342    ) -> Self::GetCodecLocalDelayRangeResponseFut;
5343    fn r#request_gatt_client(
5344        &self,
5345        client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5346    ) -> Result<(), fidl::Error>;
5347    fn r#accept_cis(&self, payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error>;
5348    fn r#connect_l2cap(&self, payload: ConnectionConnectL2capRequest) -> Result<(), fidl::Error>;
5349    type TransferPeriodicAdvertisingSyncResponseFut: std::future::Future<
5350            Output = Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error>,
5351        > + Send;
5352    fn r#transfer_periodic_advertising_sync(
5353        &self,
5354        payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
5355    ) -> Self::TransferPeriodicAdvertisingSyncResponseFut;
5356    type AcceptPeriodicAdvertisingSyncTransferResponseFut: std::future::Future<
5357            Output = Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error>,
5358        > + Send;
5359    fn r#accept_periodic_advertising_sync_transfer(
5360        &self,
5361        payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5362    ) -> Self::AcceptPeriodicAdvertisingSyncTransferResponseFut;
5363}
5364#[derive(Debug)]
5365#[cfg(target_os = "fuchsia")]
5366pub struct ConnectionSynchronousProxy {
5367    client: fidl::client::sync::Client,
5368}
5369
5370#[cfg(target_os = "fuchsia")]
5371impl fidl::endpoints::SynchronousProxy for ConnectionSynchronousProxy {
5372    type Proxy = ConnectionProxy;
5373    type Protocol = ConnectionMarker;
5374
5375    fn from_channel(inner: fidl::Channel) -> Self {
5376        Self::new(inner)
5377    }
5378
5379    fn into_channel(self) -> fidl::Channel {
5380        self.client.into_channel()
5381    }
5382
5383    fn as_channel(&self) -> &fidl::Channel {
5384        self.client.as_channel()
5385    }
5386}
5387
5388#[cfg(target_os = "fuchsia")]
5389impl ConnectionSynchronousProxy {
5390    pub fn new(channel: fidl::Channel) -> Self {
5391        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5392        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5393    }
5394
5395    pub fn into_channel(self) -> fidl::Channel {
5396        self.client.into_channel()
5397    }
5398
5399    /// Waits until an event arrives and returns it. It is safe for other
5400    /// threads to make concurrent requests while waiting for an event.
5401    pub fn wait_for_event(
5402        &self,
5403        deadline: zx::MonotonicInstant,
5404    ) -> Result<ConnectionEvent, fidl::Error> {
5405        ConnectionEvent::decode(self.client.wait_for_event(deadline)?)
5406    }
5407
5408    /// Retrieve the range of controller delay for the codec specified with the provided stream
5409    /// attributes.
5410    ///
5411    /// On success, returns the minimum and maximum allowed delay.
5412    ///
5413    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5414    /// Returns ZX_ERR_INTERNAL for all other failures.
5415    pub fn r#get_codec_local_delay_range(
5416        &self,
5417        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5418        ___deadline: zx::MonotonicInstant,
5419    ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
5420        let _response = self.client.send_query::<
5421            CodecDelayGetCodecLocalDelayRangeRequest,
5422            fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5423        >(
5424            payload,
5425            0x1cf34fdeed80b4d,
5426            fidl::encoding::DynamicFlags::empty(),
5427            ___deadline,
5428        )?;
5429        Ok(_response.map(|x| x))
5430    }
5431
5432    /// The following epitaphs may be sent by the server on error:
5433    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
5434    ///                           protocol. The existing Client should be used.
5435    pub fn r#request_gatt_client(
5436        &self,
5437        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5438    ) -> Result<(), fidl::Error> {
5439        self.client.send::<ConnectionRequestGattClientRequest>(
5440            (client,),
5441            0x2a670e0fec6ccc6b,
5442            fidl::encoding::DynamicFlags::empty(),
5443        )
5444    }
5445
5446    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
5447    /// CIS requests that have not explicitly been allowed will be rejected.
5448    ///
5449    /// The provided IsochronousStream will be used for future notification of established
5450    /// connections.
5451    ///
5452    /// The host may wait for multiple incoming connections simultaneously, although each
5453    /// must have a combination of CIG/CIS values that is unique to this connection.
5454    ///
5455    /// If we are not operating in the peripheral role in this connection, connection_stream
5456    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
5457    ///
5458    /// If we are already waiting for another connection with the same combination of CIG/CIS
5459    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
5460    pub fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
5461        self.client.send::<ConnectionAcceptCisRequest>(
5462            &mut payload,
5463            0x7e6338c237088144,
5464            fidl::encoding::DynamicFlags::empty(),
5465        )
5466    }
5467
5468    /// Connect to an L2CAP LE connection-oriented channel.
5469    pub fn r#connect_l2cap(
5470        &self,
5471        mut payload: ConnectionConnectL2capRequest,
5472    ) -> Result<(), fidl::Error> {
5473        self.client.send::<ConnectionConnectL2capRequest>(
5474            &mut payload,
5475            0x12351316feaebce9,
5476            fidl::encoding::DynamicFlags::empty(),
5477        )
5478    }
5479
5480    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
5481    /// the connected peer.
5482    pub fn r#transfer_periodic_advertising_sync(
5483        &self,
5484        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
5485        ___deadline: zx::MonotonicInstant,
5486    ) -> Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error> {
5487        let _response = self.client.send_query::<
5488            ConnectionTransferPeriodicAdvertisingSyncRequest,
5489            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeriodicAdvertisingSyncTransferError>,
5490        >(
5491            payload,
5492            0x1117a10b5ba1e219,
5493            fidl::encoding::DynamicFlags::empty(),
5494            ___deadline,
5495        )?;
5496        Ok(_response.map(|x| x))
5497    }
5498
5499    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
5500    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
5501    pub fn r#accept_periodic_advertising_sync_transfer(
5502        &self,
5503        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5504        ___deadline: zx::MonotonicInstant,
5505    ) -> Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error> {
5506        let _response = self.client.send_query::<
5507            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5508            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeriodicAdvertisingSyncTransferError>,
5509        >(
5510            &mut payload,
5511            0x441a31a7effa7e2b,
5512            fidl::encoding::DynamicFlags::empty(),
5513            ___deadline,
5514        )?;
5515        Ok(_response.map(|x| x))
5516    }
5517}
5518
5519#[cfg(target_os = "fuchsia")]
5520impl From<ConnectionSynchronousProxy> for zx::NullableHandle {
5521    fn from(value: ConnectionSynchronousProxy) -> Self {
5522        value.into_channel().into()
5523    }
5524}
5525
5526#[cfg(target_os = "fuchsia")]
5527impl From<fidl::Channel> for ConnectionSynchronousProxy {
5528    fn from(value: fidl::Channel) -> Self {
5529        Self::new(value)
5530    }
5531}
5532
5533#[cfg(target_os = "fuchsia")]
5534impl fidl::endpoints::FromClient for ConnectionSynchronousProxy {
5535    type Protocol = ConnectionMarker;
5536
5537    fn from_client(value: fidl::endpoints::ClientEnd<ConnectionMarker>) -> Self {
5538        Self::new(value.into_channel())
5539    }
5540}
5541
5542#[derive(Debug, Clone)]
5543pub struct ConnectionProxy {
5544    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5545}
5546
5547impl fidl::endpoints::Proxy for ConnectionProxy {
5548    type Protocol = ConnectionMarker;
5549
5550    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5551        Self::new(inner)
5552    }
5553
5554    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5555        self.client.into_channel().map_err(|client| Self { client })
5556    }
5557
5558    fn as_channel(&self) -> &::fidl::AsyncChannel {
5559        self.client.as_channel()
5560    }
5561}
5562
5563impl ConnectionProxy {
5564    /// Create a new Proxy for fuchsia.bluetooth.le/Connection.
5565    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5566        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5567        Self { client: fidl::client::Client::new(channel, protocol_name) }
5568    }
5569
5570    /// Get a Stream of events from the remote end of the protocol.
5571    ///
5572    /// # Panics
5573    ///
5574    /// Panics if the event stream was already taken.
5575    pub fn take_event_stream(&self) -> ConnectionEventStream {
5576        ConnectionEventStream { event_receiver: self.client.take_event_receiver() }
5577    }
5578
5579    /// Retrieve the range of controller delay for the codec specified with the provided stream
5580    /// attributes.
5581    ///
5582    /// On success, returns the minimum and maximum allowed delay.
5583    ///
5584    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5585    /// Returns ZX_ERR_INTERNAL for all other failures.
5586    pub fn r#get_codec_local_delay_range(
5587        &self,
5588        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5589    ) -> fidl::client::QueryResponseFut<
5590        CodecDelayGetCodecLocalDelayRangeResult,
5591        fidl::encoding::DefaultFuchsiaResourceDialect,
5592    > {
5593        ConnectionProxyInterface::r#get_codec_local_delay_range(self, payload)
5594    }
5595
5596    /// The following epitaphs may be sent by the server on error:
5597    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
5598    ///                           protocol. The existing Client should be used.
5599    pub fn r#request_gatt_client(
5600        &self,
5601        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5602    ) -> Result<(), fidl::Error> {
5603        ConnectionProxyInterface::r#request_gatt_client(self, client)
5604    }
5605
5606    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
5607    /// CIS requests that have not explicitly been allowed will be rejected.
5608    ///
5609    /// The provided IsochronousStream will be used for future notification of established
5610    /// connections.
5611    ///
5612    /// The host may wait for multiple incoming connections simultaneously, although each
5613    /// must have a combination of CIG/CIS values that is unique to this connection.
5614    ///
5615    /// If we are not operating in the peripheral role in this connection, connection_stream
5616    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
5617    ///
5618    /// If we are already waiting for another connection with the same combination of CIG/CIS
5619    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
5620    pub fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
5621        ConnectionProxyInterface::r#accept_cis(self, payload)
5622    }
5623
5624    /// Connect to an L2CAP LE connection-oriented channel.
5625    pub fn r#connect_l2cap(
5626        &self,
5627        mut payload: ConnectionConnectL2capRequest,
5628    ) -> Result<(), fidl::Error> {
5629        ConnectionProxyInterface::r#connect_l2cap(self, payload)
5630    }
5631
5632    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
5633    /// the connected peer.
5634    pub fn r#transfer_periodic_advertising_sync(
5635        &self,
5636        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
5637    ) -> fidl::client::QueryResponseFut<
5638        ConnectionTransferPeriodicAdvertisingSyncResult,
5639        fidl::encoding::DefaultFuchsiaResourceDialect,
5640    > {
5641        ConnectionProxyInterface::r#transfer_periodic_advertising_sync(self, payload)
5642    }
5643
5644    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
5645    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
5646    pub fn r#accept_periodic_advertising_sync_transfer(
5647        &self,
5648        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5649    ) -> fidl::client::QueryResponseFut<
5650        ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
5651        fidl::encoding::DefaultFuchsiaResourceDialect,
5652    > {
5653        ConnectionProxyInterface::r#accept_periodic_advertising_sync_transfer(self, payload)
5654    }
5655}
5656
5657impl ConnectionProxyInterface for ConnectionProxy {
5658    type GetCodecLocalDelayRangeResponseFut = fidl::client::QueryResponseFut<
5659        CodecDelayGetCodecLocalDelayRangeResult,
5660        fidl::encoding::DefaultFuchsiaResourceDialect,
5661    >;
5662    fn r#get_codec_local_delay_range(
5663        &self,
5664        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5665    ) -> Self::GetCodecLocalDelayRangeResponseFut {
5666        fn _decode(
5667            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5668        ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
5669            let _response = fidl::client::decode_transaction_body::<
5670                fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5671                fidl::encoding::DefaultFuchsiaResourceDialect,
5672                0x1cf34fdeed80b4d,
5673            >(_buf?)?;
5674            Ok(_response.map(|x| x))
5675        }
5676        self.client.send_query_and_decode::<
5677            CodecDelayGetCodecLocalDelayRangeRequest,
5678            CodecDelayGetCodecLocalDelayRangeResult,
5679        >(
5680            payload,
5681            0x1cf34fdeed80b4d,
5682            fidl::encoding::DynamicFlags::empty(),
5683            _decode,
5684        )
5685    }
5686
5687    fn r#request_gatt_client(
5688        &self,
5689        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5690    ) -> Result<(), fidl::Error> {
5691        self.client.send::<ConnectionRequestGattClientRequest>(
5692            (client,),
5693            0x2a670e0fec6ccc6b,
5694            fidl::encoding::DynamicFlags::empty(),
5695        )
5696    }
5697
5698    fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
5699        self.client.send::<ConnectionAcceptCisRequest>(
5700            &mut payload,
5701            0x7e6338c237088144,
5702            fidl::encoding::DynamicFlags::empty(),
5703        )
5704    }
5705
5706    fn r#connect_l2cap(
5707        &self,
5708        mut payload: ConnectionConnectL2capRequest,
5709    ) -> Result<(), fidl::Error> {
5710        self.client.send::<ConnectionConnectL2capRequest>(
5711            &mut payload,
5712            0x12351316feaebce9,
5713            fidl::encoding::DynamicFlags::empty(),
5714        )
5715    }
5716
5717    type TransferPeriodicAdvertisingSyncResponseFut = fidl::client::QueryResponseFut<
5718        ConnectionTransferPeriodicAdvertisingSyncResult,
5719        fidl::encoding::DefaultFuchsiaResourceDialect,
5720    >;
5721    fn r#transfer_periodic_advertising_sync(
5722        &self,
5723        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
5724    ) -> Self::TransferPeriodicAdvertisingSyncResponseFut {
5725        fn _decode(
5726            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5727        ) -> Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error> {
5728            let _response = fidl::client::decode_transaction_body::<
5729                fidl::encoding::ResultType<
5730                    fidl::encoding::EmptyStruct,
5731                    PeriodicAdvertisingSyncTransferError,
5732                >,
5733                fidl::encoding::DefaultFuchsiaResourceDialect,
5734                0x1117a10b5ba1e219,
5735            >(_buf?)?;
5736            Ok(_response.map(|x| x))
5737        }
5738        self.client.send_query_and_decode::<
5739            ConnectionTransferPeriodicAdvertisingSyncRequest,
5740            ConnectionTransferPeriodicAdvertisingSyncResult,
5741        >(
5742            payload,
5743            0x1117a10b5ba1e219,
5744            fidl::encoding::DynamicFlags::empty(),
5745            _decode,
5746        )
5747    }
5748
5749    type AcceptPeriodicAdvertisingSyncTransferResponseFut = fidl::client::QueryResponseFut<
5750        ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
5751        fidl::encoding::DefaultFuchsiaResourceDialect,
5752    >;
5753    fn r#accept_periodic_advertising_sync_transfer(
5754        &self,
5755        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5756    ) -> Self::AcceptPeriodicAdvertisingSyncTransferResponseFut {
5757        fn _decode(
5758            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5759        ) -> Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error> {
5760            let _response = fidl::client::decode_transaction_body::<
5761                fidl::encoding::ResultType<
5762                    fidl::encoding::EmptyStruct,
5763                    PeriodicAdvertisingSyncTransferError,
5764                >,
5765                fidl::encoding::DefaultFuchsiaResourceDialect,
5766                0x441a31a7effa7e2b,
5767            >(_buf?)?;
5768            Ok(_response.map(|x| x))
5769        }
5770        self.client.send_query_and_decode::<
5771            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5772            ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
5773        >(
5774            &mut payload,
5775            0x441a31a7effa7e2b,
5776            fidl::encoding::DynamicFlags::empty(),
5777            _decode,
5778        )
5779    }
5780}
5781
5782pub struct ConnectionEventStream {
5783    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5784}
5785
5786impl std::marker::Unpin for ConnectionEventStream {}
5787
5788impl futures::stream::FusedStream for ConnectionEventStream {
5789    fn is_terminated(&self) -> bool {
5790        self.event_receiver.is_terminated()
5791    }
5792}
5793
5794impl futures::Stream for ConnectionEventStream {
5795    type Item = Result<ConnectionEvent, fidl::Error>;
5796
5797    fn poll_next(
5798        mut self: std::pin::Pin<&mut Self>,
5799        cx: &mut std::task::Context<'_>,
5800    ) -> std::task::Poll<Option<Self::Item>> {
5801        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5802            &mut self.event_receiver,
5803            cx
5804        )?) {
5805            Some(buf) => std::task::Poll::Ready(Some(ConnectionEvent::decode(buf))),
5806            None => std::task::Poll::Ready(None),
5807        }
5808    }
5809}
5810
5811#[derive(Debug)]
5812pub enum ConnectionEvent {}
5813
5814impl ConnectionEvent {
5815    /// Decodes a message buffer as a [`ConnectionEvent`].
5816    fn decode(
5817        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5818    ) -> Result<ConnectionEvent, fidl::Error> {
5819        let (bytes, _handles) = buf.split_mut();
5820        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5821        debug_assert_eq!(tx_header.tx_id, 0);
5822        match tx_header.ordinal {
5823            _ => Err(fidl::Error::UnknownOrdinal {
5824                ordinal: tx_header.ordinal,
5825                protocol_name: <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5826            }),
5827        }
5828    }
5829}
5830
5831/// A Stream of incoming requests for fuchsia.bluetooth.le/Connection.
5832pub struct ConnectionRequestStream {
5833    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5834    is_terminated: bool,
5835}
5836
5837impl std::marker::Unpin for ConnectionRequestStream {}
5838
5839impl futures::stream::FusedStream for ConnectionRequestStream {
5840    fn is_terminated(&self) -> bool {
5841        self.is_terminated
5842    }
5843}
5844
5845impl fidl::endpoints::RequestStream for ConnectionRequestStream {
5846    type Protocol = ConnectionMarker;
5847    type ControlHandle = ConnectionControlHandle;
5848
5849    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5850        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5851    }
5852
5853    fn control_handle(&self) -> Self::ControlHandle {
5854        ConnectionControlHandle { inner: self.inner.clone() }
5855    }
5856
5857    fn into_inner(
5858        self,
5859    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5860    {
5861        (self.inner, self.is_terminated)
5862    }
5863
5864    fn from_inner(
5865        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5866        is_terminated: bool,
5867    ) -> Self {
5868        Self { inner, is_terminated }
5869    }
5870}
5871
5872impl futures::Stream for ConnectionRequestStream {
5873    type Item = Result<ConnectionRequest, fidl::Error>;
5874
5875    fn poll_next(
5876        mut self: std::pin::Pin<&mut Self>,
5877        cx: &mut std::task::Context<'_>,
5878    ) -> std::task::Poll<Option<Self::Item>> {
5879        let this = &mut *self;
5880        if this.inner.check_shutdown(cx) {
5881            this.is_terminated = true;
5882            return std::task::Poll::Ready(None);
5883        }
5884        if this.is_terminated {
5885            panic!("polled ConnectionRequestStream after completion");
5886        }
5887        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5888            |bytes, handles| {
5889                match this.inner.channel().read_etc(cx, bytes, handles) {
5890                    std::task::Poll::Ready(Ok(())) => {}
5891                    std::task::Poll::Pending => return std::task::Poll::Pending,
5892                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5893                        this.is_terminated = true;
5894                        return std::task::Poll::Ready(None);
5895                    }
5896                    std::task::Poll::Ready(Err(e)) => {
5897                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5898                            e.into(),
5899                        ))));
5900                    }
5901                }
5902
5903                // A message has been received from the channel
5904                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5905
5906                std::task::Poll::Ready(Some(match header.ordinal {
5907                    0x1cf34fdeed80b4d => {
5908                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5909                        let mut req = fidl::new_empty!(
5910                            CodecDelayGetCodecLocalDelayRangeRequest,
5911                            fidl::encoding::DefaultFuchsiaResourceDialect
5912                        );
5913                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecDelayGetCodecLocalDelayRangeRequest>(&header, _body_bytes, handles, &mut req)?;
5914                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5915                        Ok(ConnectionRequest::GetCodecLocalDelayRange {
5916                            payload: req,
5917                            responder: ConnectionGetCodecLocalDelayRangeResponder {
5918                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5919                                tx_id: header.tx_id,
5920                            },
5921                        })
5922                    }
5923                    0x2a670e0fec6ccc6b => {
5924                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5925                        let mut req = fidl::new_empty!(
5926                            ConnectionRequestGattClientRequest,
5927                            fidl::encoding::DefaultFuchsiaResourceDialect
5928                        );
5929                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionRequestGattClientRequest>(&header, _body_bytes, handles, &mut req)?;
5930                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5931                        Ok(ConnectionRequest::RequestGattClient {
5932                            client: req.client,
5933
5934                            control_handle,
5935                        })
5936                    }
5937                    0x7e6338c237088144 => {
5938                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5939                        let mut req = fidl::new_empty!(
5940                            ConnectionAcceptCisRequest,
5941                            fidl::encoding::DefaultFuchsiaResourceDialect
5942                        );
5943                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionAcceptCisRequest>(&header, _body_bytes, handles, &mut req)?;
5944                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5945                        Ok(ConnectionRequest::AcceptCis { payload: req, control_handle })
5946                    }
5947                    0x12351316feaebce9 => {
5948                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5949                        let mut req = fidl::new_empty!(
5950                            ConnectionConnectL2capRequest,
5951                            fidl::encoding::DefaultFuchsiaResourceDialect
5952                        );
5953                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionConnectL2capRequest>(&header, _body_bytes, handles, &mut req)?;
5954                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5955                        Ok(ConnectionRequest::ConnectL2cap { payload: req, control_handle })
5956                    }
5957                    0x1117a10b5ba1e219 => {
5958                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5959                        let mut req = fidl::new_empty!(
5960                            ConnectionTransferPeriodicAdvertisingSyncRequest,
5961                            fidl::encoding::DefaultFuchsiaResourceDialect
5962                        );
5963                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionTransferPeriodicAdvertisingSyncRequest>(&header, _body_bytes, handles, &mut req)?;
5964                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5965                        Ok(ConnectionRequest::TransferPeriodicAdvertisingSync {
5966                            payload: req,
5967                            responder: ConnectionTransferPeriodicAdvertisingSyncResponder {
5968                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5969                                tx_id: header.tx_id,
5970                            },
5971                        })
5972                    }
5973                    0x441a31a7effa7e2b => {
5974                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5975                        let mut req = fidl::new_empty!(
5976                            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
5977                            fidl::encoding::DefaultFuchsiaResourceDialect
5978                        );
5979                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionAcceptPeriodicAdvertisingSyncTransferRequest>(&header, _body_bytes, handles, &mut req)?;
5980                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5981                        Ok(ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer {
5982                            payload: req,
5983                            responder: ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
5984                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5985                                tx_id: header.tx_id,
5986                            },
5987                        })
5988                    }
5989                    _ => Err(fidl::Error::UnknownOrdinal {
5990                        ordinal: header.ordinal,
5991                        protocol_name:
5992                            <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5993                    }),
5994                }))
5995            },
5996        )
5997    }
5998}
5999
6000/// Protocol that represents the connection to a peer. This can be used to interact with GATT
6001/// services and establish L2CAP channels.
6002///
6003/// This lifetime of this capability is tied to that of the LE connection it represents. Closing the
6004/// channel results in a disconnection if no other clients hold a Connection to the same peer.
6005#[derive(Debug)]
6006pub enum ConnectionRequest {
6007    /// Retrieve the range of controller delay for the codec specified with the provided stream
6008    /// attributes.
6009    ///
6010    /// On success, returns the minimum and maximum allowed delay.
6011    ///
6012    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
6013    /// Returns ZX_ERR_INTERNAL for all other failures.
6014    GetCodecLocalDelayRange {
6015        payload: CodecDelayGetCodecLocalDelayRangeRequest,
6016        responder: ConnectionGetCodecLocalDelayRangeResponder,
6017    },
6018    /// The following epitaphs may be sent by the server on error:
6019    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
6020    ///                           protocol. The existing Client should be used.
6021    RequestGattClient {
6022        client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6023        control_handle: ConnectionControlHandle,
6024    },
6025    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
6026    /// CIS requests that have not explicitly been allowed will be rejected.
6027    ///
6028    /// The provided IsochronousStream will be used for future notification of established
6029    /// connections.
6030    ///
6031    /// The host may wait for multiple incoming connections simultaneously, although each
6032    /// must have a combination of CIG/CIS values that is unique to this connection.
6033    ///
6034    /// If we are not operating in the peripheral role in this connection, connection_stream
6035    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
6036    ///
6037    /// If we are already waiting for another connection with the same combination of CIG/CIS
6038    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
6039    AcceptCis { payload: ConnectionAcceptCisRequest, control_handle: ConnectionControlHandle },
6040    /// Connect to an L2CAP LE connection-oriented channel.
6041    ConnectL2cap { payload: ConnectionConnectL2capRequest, control_handle: ConnectionControlHandle },
6042    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
6043    /// the connected peer.
6044    TransferPeriodicAdvertisingSync {
6045        payload: ConnectionTransferPeriodicAdvertisingSyncRequest,
6046        responder: ConnectionTransferPeriodicAdvertisingSyncResponder,
6047    },
6048    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
6049    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
6050    AcceptPeriodicAdvertisingSyncTransfer {
6051        payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6052        responder: ConnectionAcceptPeriodicAdvertisingSyncTransferResponder,
6053    },
6054}
6055
6056impl ConnectionRequest {
6057    #[allow(irrefutable_let_patterns)]
6058    pub fn into_get_codec_local_delay_range(
6059        self,
6060    ) -> Option<(
6061        CodecDelayGetCodecLocalDelayRangeRequest,
6062        ConnectionGetCodecLocalDelayRangeResponder,
6063    )> {
6064        if let ConnectionRequest::GetCodecLocalDelayRange { payload, responder } = self {
6065            Some((payload, responder))
6066        } else {
6067            None
6068        }
6069    }
6070
6071    #[allow(irrefutable_let_patterns)]
6072    pub fn into_request_gatt_client(
6073        self,
6074    ) -> Option<(
6075        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6076        ConnectionControlHandle,
6077    )> {
6078        if let ConnectionRequest::RequestGattClient { client, control_handle } = self {
6079            Some((client, control_handle))
6080        } else {
6081            None
6082        }
6083    }
6084
6085    #[allow(irrefutable_let_patterns)]
6086    pub fn into_accept_cis(self) -> Option<(ConnectionAcceptCisRequest, ConnectionControlHandle)> {
6087        if let ConnectionRequest::AcceptCis { payload, control_handle } = self {
6088            Some((payload, control_handle))
6089        } else {
6090            None
6091        }
6092    }
6093
6094    #[allow(irrefutable_let_patterns)]
6095    pub fn into_connect_l2cap(
6096        self,
6097    ) -> Option<(ConnectionConnectL2capRequest, ConnectionControlHandle)> {
6098        if let ConnectionRequest::ConnectL2cap { payload, control_handle } = self {
6099            Some((payload, control_handle))
6100        } else {
6101            None
6102        }
6103    }
6104
6105    #[allow(irrefutable_let_patterns)]
6106    pub fn into_transfer_periodic_advertising_sync(
6107        self,
6108    ) -> Option<(
6109        ConnectionTransferPeriodicAdvertisingSyncRequest,
6110        ConnectionTransferPeriodicAdvertisingSyncResponder,
6111    )> {
6112        if let ConnectionRequest::TransferPeriodicAdvertisingSync { payload, responder } = self {
6113            Some((payload, responder))
6114        } else {
6115            None
6116        }
6117    }
6118
6119    #[allow(irrefutable_let_patterns)]
6120    pub fn into_accept_periodic_advertising_sync_transfer(
6121        self,
6122    ) -> Option<(
6123        ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6124        ConnectionAcceptPeriodicAdvertisingSyncTransferResponder,
6125    )> {
6126        if let ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer { payload, responder } =
6127            self
6128        {
6129            Some((payload, responder))
6130        } else {
6131            None
6132        }
6133    }
6134
6135    /// Name of the method defined in FIDL
6136    pub fn method_name(&self) -> &'static str {
6137        match *self {
6138            ConnectionRequest::GetCodecLocalDelayRange { .. } => "get_codec_local_delay_range",
6139            ConnectionRequest::RequestGattClient { .. } => "request_gatt_client",
6140            ConnectionRequest::AcceptCis { .. } => "accept_cis",
6141            ConnectionRequest::ConnectL2cap { .. } => "connect_l2cap",
6142            ConnectionRequest::TransferPeriodicAdvertisingSync { .. } => {
6143                "transfer_periodic_advertising_sync"
6144            }
6145            ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer { .. } => {
6146                "accept_periodic_advertising_sync_transfer"
6147            }
6148        }
6149    }
6150}
6151
6152#[derive(Debug, Clone)]
6153pub struct ConnectionControlHandle {
6154    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6155}
6156
6157impl fidl::endpoints::ControlHandle for ConnectionControlHandle {
6158    fn shutdown(&self) {
6159        self.inner.shutdown()
6160    }
6161
6162    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6163        self.inner.shutdown_with_epitaph(status)
6164    }
6165
6166    fn is_closed(&self) -> bool {
6167        self.inner.channel().is_closed()
6168    }
6169    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6170        self.inner.channel().on_closed()
6171    }
6172
6173    #[cfg(target_os = "fuchsia")]
6174    fn signal_peer(
6175        &self,
6176        clear_mask: zx::Signals,
6177        set_mask: zx::Signals,
6178    ) -> Result<(), zx_status::Status> {
6179        use fidl::Peered;
6180        self.inner.channel().signal_peer(clear_mask, set_mask)
6181    }
6182}
6183
6184impl ConnectionControlHandle {}
6185
6186#[must_use = "FIDL methods require a response to be sent"]
6187#[derive(Debug)]
6188pub struct ConnectionGetCodecLocalDelayRangeResponder {
6189    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
6190    tx_id: u32,
6191}
6192
6193/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
6194/// if the responder is dropped without sending a response, so that the client
6195/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6196impl std::ops::Drop for ConnectionGetCodecLocalDelayRangeResponder {
6197    fn drop(&mut self) {
6198        self.control_handle.shutdown();
6199        // Safety: drops once, never accessed again
6200        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6201    }
6202}
6203
6204impl fidl::endpoints::Responder for ConnectionGetCodecLocalDelayRangeResponder {
6205    type ControlHandle = ConnectionControlHandle;
6206
6207    fn control_handle(&self) -> &ConnectionControlHandle {
6208        &self.control_handle
6209    }
6210
6211    fn drop_without_shutdown(mut self) {
6212        // Safety: drops once, never accessed again due to mem::forget
6213        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6214        // Prevent Drop from running (which would shut down the channel)
6215        std::mem::forget(self);
6216    }
6217}
6218
6219impl ConnectionGetCodecLocalDelayRangeResponder {
6220    /// Sends a response to the FIDL transaction.
6221    ///
6222    /// Sets the channel to shutdown if an error occurs.
6223    pub fn send(
6224        self,
6225        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
6226    ) -> Result<(), fidl::Error> {
6227        let _result = self.send_raw(result);
6228        if _result.is_err() {
6229            self.control_handle.shutdown();
6230        }
6231        self.drop_without_shutdown();
6232        _result
6233    }
6234
6235    /// Similar to "send" but does not shutdown the channel if an error occurs.
6236    pub fn send_no_shutdown_on_err(
6237        self,
6238        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
6239    ) -> Result<(), fidl::Error> {
6240        let _result = self.send_raw(result);
6241        self.drop_without_shutdown();
6242        _result
6243    }
6244
6245    fn send_raw(
6246        &self,
6247        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
6248    ) -> Result<(), fidl::Error> {
6249        self.control_handle.inner.send::<fidl::encoding::ResultType<
6250            CodecDelayGetCodecLocalDelayRangeResponse,
6251            i32,
6252        >>(
6253            result,
6254            self.tx_id,
6255            0x1cf34fdeed80b4d,
6256            fidl::encoding::DynamicFlags::empty(),
6257        )
6258    }
6259}
6260
6261#[must_use = "FIDL methods require a response to be sent"]
6262#[derive(Debug)]
6263pub struct ConnectionTransferPeriodicAdvertisingSyncResponder {
6264    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
6265    tx_id: u32,
6266}
6267
6268/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
6269/// if the responder is dropped without sending a response, so that the client
6270/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6271impl std::ops::Drop for ConnectionTransferPeriodicAdvertisingSyncResponder {
6272    fn drop(&mut self) {
6273        self.control_handle.shutdown();
6274        // Safety: drops once, never accessed again
6275        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6276    }
6277}
6278
6279impl fidl::endpoints::Responder for ConnectionTransferPeriodicAdvertisingSyncResponder {
6280    type ControlHandle = ConnectionControlHandle;
6281
6282    fn control_handle(&self) -> &ConnectionControlHandle {
6283        &self.control_handle
6284    }
6285
6286    fn drop_without_shutdown(mut self) {
6287        // Safety: drops once, never accessed again due to mem::forget
6288        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6289        // Prevent Drop from running (which would shut down the channel)
6290        std::mem::forget(self);
6291    }
6292}
6293
6294impl ConnectionTransferPeriodicAdvertisingSyncResponder {
6295    /// Sends a response to the FIDL transaction.
6296    ///
6297    /// Sets the channel to shutdown if an error occurs.
6298    pub fn send(
6299        self,
6300        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6301    ) -> Result<(), fidl::Error> {
6302        let _result = self.send_raw(result);
6303        if _result.is_err() {
6304            self.control_handle.shutdown();
6305        }
6306        self.drop_without_shutdown();
6307        _result
6308    }
6309
6310    /// Similar to "send" but does not shutdown the channel if an error occurs.
6311    pub fn send_no_shutdown_on_err(
6312        self,
6313        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6314    ) -> Result<(), fidl::Error> {
6315        let _result = self.send_raw(result);
6316        self.drop_without_shutdown();
6317        _result
6318    }
6319
6320    fn send_raw(
6321        &self,
6322        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6323    ) -> Result<(), fidl::Error> {
6324        self.control_handle.inner.send::<fidl::encoding::ResultType<
6325            fidl::encoding::EmptyStruct,
6326            PeriodicAdvertisingSyncTransferError,
6327        >>(
6328            result,
6329            self.tx_id,
6330            0x1117a10b5ba1e219,
6331            fidl::encoding::DynamicFlags::empty(),
6332        )
6333    }
6334}
6335
6336#[must_use = "FIDL methods require a response to be sent"]
6337#[derive(Debug)]
6338pub struct ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
6339    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
6340    tx_id: u32,
6341}
6342
6343/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
6344/// if the responder is dropped without sending a response, so that the client
6345/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6346impl std::ops::Drop for ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
6347    fn drop(&mut self) {
6348        self.control_handle.shutdown();
6349        // Safety: drops once, never accessed again
6350        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6351    }
6352}
6353
6354impl fidl::endpoints::Responder for ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
6355    type ControlHandle = ConnectionControlHandle;
6356
6357    fn control_handle(&self) -> &ConnectionControlHandle {
6358        &self.control_handle
6359    }
6360
6361    fn drop_without_shutdown(mut self) {
6362        // Safety: drops once, never accessed again due to mem::forget
6363        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6364        // Prevent Drop from running (which would shut down the channel)
6365        std::mem::forget(self);
6366    }
6367}
6368
6369impl ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
6370    /// Sends a response to the FIDL transaction.
6371    ///
6372    /// Sets the channel to shutdown if an error occurs.
6373    pub fn send(
6374        self,
6375        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6376    ) -> Result<(), fidl::Error> {
6377        let _result = self.send_raw(result);
6378        if _result.is_err() {
6379            self.control_handle.shutdown();
6380        }
6381        self.drop_without_shutdown();
6382        _result
6383    }
6384
6385    /// Similar to "send" but does not shutdown the channel if an error occurs.
6386    pub fn send_no_shutdown_on_err(
6387        self,
6388        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6389    ) -> Result<(), fidl::Error> {
6390        let _result = self.send_raw(result);
6391        self.drop_without_shutdown();
6392        _result
6393    }
6394
6395    fn send_raw(
6396        &self,
6397        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
6398    ) -> Result<(), fidl::Error> {
6399        self.control_handle.inner.send::<fidl::encoding::ResultType<
6400            fidl::encoding::EmptyStruct,
6401            PeriodicAdvertisingSyncTransferError,
6402        >>(
6403            result,
6404            self.tx_id,
6405            0x441a31a7effa7e2b,
6406            fidl::encoding::DynamicFlags::empty(),
6407        )
6408    }
6409}
6410
6411#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6412pub struct IsochronousStreamMarker;
6413
6414impl fidl::endpoints::ProtocolMarker for IsochronousStreamMarker {
6415    type Proxy = IsochronousStreamProxy;
6416    type RequestStream = IsochronousStreamRequestStream;
6417    #[cfg(target_os = "fuchsia")]
6418    type SynchronousProxy = IsochronousStreamSynchronousProxy;
6419
6420    const DEBUG_NAME: &'static str = "(anonymous) IsochronousStream";
6421}
6422pub type IsochronousStreamSetupDataPathResult = Result<(), i32>;
6423pub type IsochronousStreamWriteResult = Result<(), i32>;
6424
6425pub trait IsochronousStreamProxyInterface: Send + Sync {
6426    type SetupDataPathResponseFut: std::future::Future<Output = Result<IsochronousStreamSetupDataPathResult, fidl::Error>>
6427        + Send;
6428    fn r#setup_data_path(
6429        &self,
6430        payload: &IsochronousStreamSetupDataPathRequest,
6431    ) -> Self::SetupDataPathResponseFut;
6432    type ReadResponseFut: std::future::Future<Output = Result<IsochronousStreamReadResponse, fidl::Error>>
6433        + Send;
6434    fn r#read(&self) -> Self::ReadResponseFut;
6435    type WriteResponseFut: std::future::Future<Output = Result<IsochronousStreamWriteResult, fidl::Error>>
6436        + Send;
6437    fn r#write(&self, payload: &IsochronousStreamWriteRequest) -> Self::WriteResponseFut;
6438}
6439#[derive(Debug)]
6440#[cfg(target_os = "fuchsia")]
6441pub struct IsochronousStreamSynchronousProxy {
6442    client: fidl::client::sync::Client,
6443}
6444
6445#[cfg(target_os = "fuchsia")]
6446impl fidl::endpoints::SynchronousProxy for IsochronousStreamSynchronousProxy {
6447    type Proxy = IsochronousStreamProxy;
6448    type Protocol = IsochronousStreamMarker;
6449
6450    fn from_channel(inner: fidl::Channel) -> Self {
6451        Self::new(inner)
6452    }
6453
6454    fn into_channel(self) -> fidl::Channel {
6455        self.client.into_channel()
6456    }
6457
6458    fn as_channel(&self) -> &fidl::Channel {
6459        self.client.as_channel()
6460    }
6461}
6462
6463#[cfg(target_os = "fuchsia")]
6464impl IsochronousStreamSynchronousProxy {
6465    pub fn new(channel: fidl::Channel) -> Self {
6466        let protocol_name =
6467            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6468        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6469    }
6470
6471    pub fn into_channel(self) -> fidl::Channel {
6472        self.client.into_channel()
6473    }
6474
6475    /// Waits until an event arrives and returns it. It is safe for other
6476    /// threads to make concurrent requests while waiting for an event.
6477    pub fn wait_for_event(
6478        &self,
6479        deadline: zx::MonotonicInstant,
6480    ) -> Result<IsochronousStreamEvent, fidl::Error> {
6481        IsochronousStreamEvent::decode(self.client.wait_for_event(deadline)?)
6482    }
6483
6484    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
6485    /// transport is currently supported.
6486    ///
6487    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
6488    /// direction.
6489    ///
6490    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
6491    /// accepted.
6492    ///
6493    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
6494    /// controller's supported range.
6495    pub fn r#setup_data_path(
6496        &self,
6497        mut payload: &IsochronousStreamSetupDataPathRequest,
6498        ___deadline: zx::MonotonicInstant,
6499    ) -> Result<IsochronousStreamSetupDataPathResult, fidl::Error> {
6500        let _response = self.client.send_query::<
6501            IsochronousStreamSetupDataPathRequest,
6502            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6503        >(
6504            payload,
6505            0x7ec1e2b9cc6d2fbe,
6506            fidl::encoding::DynamicFlags::FLEXIBLE,
6507            ___deadline,
6508        )?
6509        .into_result::<IsochronousStreamMarker>("setup_data_path")?;
6510        Ok(_response.map(|x| x))
6511    }
6512
6513    /// Receive data from an output (controller => host) ISO stream that has been established and
6514    /// set up. Designed to be used with a hanging get pattern.
6515    ///
6516    /// Can be invoked before the ISO data stream has been established and set up, but will not
6517    /// return until after it has been set up and data has been received.
6518    pub fn r#read(
6519        &self,
6520        ___deadline: zx::MonotonicInstant,
6521    ) -> Result<IsochronousStreamReadResponse, fidl::Error> {
6522        let _response = self.client.send_query::<
6523            fidl::encoding::EmptyPayload,
6524            fidl::encoding::FlexibleType<IsochronousStreamReadResponse>,
6525        >(
6526            (),
6527            0x6d7d8b4950ed3a32,
6528            fidl::encoding::DynamicFlags::FLEXIBLE,
6529            ___deadline,
6530        )?
6531        .into_result::<IsochronousStreamMarker>("read")?;
6532        Ok(_response)
6533    }
6534
6535    /// Send data to an established ISO stream (host => controller).
6536    ///
6537    /// Returns ZX_ERR_INTERNAL for any errors encountered.
6538    pub fn r#write(
6539        &self,
6540        mut payload: &IsochronousStreamWriteRequest,
6541        ___deadline: zx::MonotonicInstant,
6542    ) -> Result<IsochronousStreamWriteResult, fidl::Error> {
6543        let _response = self.client.send_query::<
6544            IsochronousStreamWriteRequest,
6545            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6546        >(
6547            payload,
6548            0x5282e90b667d0d43,
6549            fidl::encoding::DynamicFlags::FLEXIBLE,
6550            ___deadline,
6551        )?
6552        .into_result::<IsochronousStreamMarker>("write")?;
6553        Ok(_response.map(|x| x))
6554    }
6555}
6556
6557#[cfg(target_os = "fuchsia")]
6558impl From<IsochronousStreamSynchronousProxy> for zx::NullableHandle {
6559    fn from(value: IsochronousStreamSynchronousProxy) -> Self {
6560        value.into_channel().into()
6561    }
6562}
6563
6564#[cfg(target_os = "fuchsia")]
6565impl From<fidl::Channel> for IsochronousStreamSynchronousProxy {
6566    fn from(value: fidl::Channel) -> Self {
6567        Self::new(value)
6568    }
6569}
6570
6571#[cfg(target_os = "fuchsia")]
6572impl fidl::endpoints::FromClient for IsochronousStreamSynchronousProxy {
6573    type Protocol = IsochronousStreamMarker;
6574
6575    fn from_client(value: fidl::endpoints::ClientEnd<IsochronousStreamMarker>) -> Self {
6576        Self::new(value.into_channel())
6577    }
6578}
6579
6580#[derive(Debug, Clone)]
6581pub struct IsochronousStreamProxy {
6582    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6583}
6584
6585impl fidl::endpoints::Proxy for IsochronousStreamProxy {
6586    type Protocol = IsochronousStreamMarker;
6587
6588    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6589        Self::new(inner)
6590    }
6591
6592    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6593        self.client.into_channel().map_err(|client| Self { client })
6594    }
6595
6596    fn as_channel(&self) -> &::fidl::AsyncChannel {
6597        self.client.as_channel()
6598    }
6599}
6600
6601impl IsochronousStreamProxy {
6602    /// Create a new Proxy for fuchsia.bluetooth.le/IsochronousStream.
6603    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6604        let protocol_name =
6605            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6606        Self { client: fidl::client::Client::new(channel, protocol_name) }
6607    }
6608
6609    /// Get a Stream of events from the remote end of the protocol.
6610    ///
6611    /// # Panics
6612    ///
6613    /// Panics if the event stream was already taken.
6614    pub fn take_event_stream(&self) -> IsochronousStreamEventStream {
6615        IsochronousStreamEventStream { event_receiver: self.client.take_event_receiver() }
6616    }
6617
6618    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
6619    /// transport is currently supported.
6620    ///
6621    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
6622    /// direction.
6623    ///
6624    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
6625    /// accepted.
6626    ///
6627    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
6628    /// controller's supported range.
6629    pub fn r#setup_data_path(
6630        &self,
6631        mut payload: &IsochronousStreamSetupDataPathRequest,
6632    ) -> fidl::client::QueryResponseFut<
6633        IsochronousStreamSetupDataPathResult,
6634        fidl::encoding::DefaultFuchsiaResourceDialect,
6635    > {
6636        IsochronousStreamProxyInterface::r#setup_data_path(self, payload)
6637    }
6638
6639    /// Receive data from an output (controller => host) ISO stream that has been established and
6640    /// set up. Designed to be used with a hanging get pattern.
6641    ///
6642    /// Can be invoked before the ISO data stream has been established and set up, but will not
6643    /// return until after it has been set up and data has been received.
6644    pub fn r#read(
6645        &self,
6646    ) -> fidl::client::QueryResponseFut<
6647        IsochronousStreamReadResponse,
6648        fidl::encoding::DefaultFuchsiaResourceDialect,
6649    > {
6650        IsochronousStreamProxyInterface::r#read(self)
6651    }
6652
6653    /// Send data to an established ISO stream (host => controller).
6654    ///
6655    /// Returns ZX_ERR_INTERNAL for any errors encountered.
6656    pub fn r#write(
6657        &self,
6658        mut payload: &IsochronousStreamWriteRequest,
6659    ) -> fidl::client::QueryResponseFut<
6660        IsochronousStreamWriteResult,
6661        fidl::encoding::DefaultFuchsiaResourceDialect,
6662    > {
6663        IsochronousStreamProxyInterface::r#write(self, payload)
6664    }
6665}
6666
6667impl IsochronousStreamProxyInterface for IsochronousStreamProxy {
6668    type SetupDataPathResponseFut = fidl::client::QueryResponseFut<
6669        IsochronousStreamSetupDataPathResult,
6670        fidl::encoding::DefaultFuchsiaResourceDialect,
6671    >;
6672    fn r#setup_data_path(
6673        &self,
6674        mut payload: &IsochronousStreamSetupDataPathRequest,
6675    ) -> Self::SetupDataPathResponseFut {
6676        fn _decode(
6677            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6678        ) -> Result<IsochronousStreamSetupDataPathResult, fidl::Error> {
6679            let _response = fidl::client::decode_transaction_body::<
6680                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6681                fidl::encoding::DefaultFuchsiaResourceDialect,
6682                0x7ec1e2b9cc6d2fbe,
6683            >(_buf?)?
6684            .into_result::<IsochronousStreamMarker>("setup_data_path")?;
6685            Ok(_response.map(|x| x))
6686        }
6687        self.client.send_query_and_decode::<
6688            IsochronousStreamSetupDataPathRequest,
6689            IsochronousStreamSetupDataPathResult,
6690        >(
6691            payload,
6692            0x7ec1e2b9cc6d2fbe,
6693            fidl::encoding::DynamicFlags::FLEXIBLE,
6694            _decode,
6695        )
6696    }
6697
6698    type ReadResponseFut = fidl::client::QueryResponseFut<
6699        IsochronousStreamReadResponse,
6700        fidl::encoding::DefaultFuchsiaResourceDialect,
6701    >;
6702    fn r#read(&self) -> Self::ReadResponseFut {
6703        fn _decode(
6704            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6705        ) -> Result<IsochronousStreamReadResponse, fidl::Error> {
6706            let _response = fidl::client::decode_transaction_body::<
6707                fidl::encoding::FlexibleType<IsochronousStreamReadResponse>,
6708                fidl::encoding::DefaultFuchsiaResourceDialect,
6709                0x6d7d8b4950ed3a32,
6710            >(_buf?)?
6711            .into_result::<IsochronousStreamMarker>("read")?;
6712            Ok(_response)
6713        }
6714        self.client
6715            .send_query_and_decode::<fidl::encoding::EmptyPayload, IsochronousStreamReadResponse>(
6716                (),
6717                0x6d7d8b4950ed3a32,
6718                fidl::encoding::DynamicFlags::FLEXIBLE,
6719                _decode,
6720            )
6721    }
6722
6723    type WriteResponseFut = fidl::client::QueryResponseFut<
6724        IsochronousStreamWriteResult,
6725        fidl::encoding::DefaultFuchsiaResourceDialect,
6726    >;
6727    fn r#write(&self, mut payload: &IsochronousStreamWriteRequest) -> Self::WriteResponseFut {
6728        fn _decode(
6729            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6730        ) -> Result<IsochronousStreamWriteResult, fidl::Error> {
6731            let _response = fidl::client::decode_transaction_body::<
6732                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6733                fidl::encoding::DefaultFuchsiaResourceDialect,
6734                0x5282e90b667d0d43,
6735            >(_buf?)?
6736            .into_result::<IsochronousStreamMarker>("write")?;
6737            Ok(_response.map(|x| x))
6738        }
6739        self.client
6740            .send_query_and_decode::<IsochronousStreamWriteRequest, IsochronousStreamWriteResult>(
6741                payload,
6742                0x5282e90b667d0d43,
6743                fidl::encoding::DynamicFlags::FLEXIBLE,
6744                _decode,
6745            )
6746    }
6747}
6748
6749pub struct IsochronousStreamEventStream {
6750    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6751}
6752
6753impl std::marker::Unpin for IsochronousStreamEventStream {}
6754
6755impl futures::stream::FusedStream for IsochronousStreamEventStream {
6756    fn is_terminated(&self) -> bool {
6757        self.event_receiver.is_terminated()
6758    }
6759}
6760
6761impl futures::Stream for IsochronousStreamEventStream {
6762    type Item = Result<IsochronousStreamEvent, fidl::Error>;
6763
6764    fn poll_next(
6765        mut self: std::pin::Pin<&mut Self>,
6766        cx: &mut std::task::Context<'_>,
6767    ) -> std::task::Poll<Option<Self::Item>> {
6768        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6769            &mut self.event_receiver,
6770            cx
6771        )?) {
6772            Some(buf) => std::task::Poll::Ready(Some(IsochronousStreamEvent::decode(buf))),
6773            None => std::task::Poll::Ready(None),
6774        }
6775    }
6776}
6777
6778#[derive(Debug)]
6779pub enum IsochronousStreamEvent {
6780    OnEstablished {
6781        payload: IsochronousStreamOnEstablishedRequest,
6782    },
6783    #[non_exhaustive]
6784    _UnknownEvent {
6785        /// Ordinal of the event that was sent.
6786        ordinal: u64,
6787    },
6788}
6789
6790impl IsochronousStreamEvent {
6791    #[allow(irrefutable_let_patterns)]
6792    pub fn into_on_established(self) -> Option<IsochronousStreamOnEstablishedRequest> {
6793        if let IsochronousStreamEvent::OnEstablished { payload } = self {
6794            Some((payload))
6795        } else {
6796            None
6797        }
6798    }
6799
6800    /// Decodes a message buffer as a [`IsochronousStreamEvent`].
6801    fn decode(
6802        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6803    ) -> Result<IsochronousStreamEvent, fidl::Error> {
6804        let (bytes, _handles) = buf.split_mut();
6805        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6806        debug_assert_eq!(tx_header.tx_id, 0);
6807        match tx_header.ordinal {
6808            0x341c50e9d10f3421 => {
6809                let mut out = fidl::new_empty!(
6810                    IsochronousStreamOnEstablishedRequest,
6811                    fidl::encoding::DefaultFuchsiaResourceDialect
6812                );
6813                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamOnEstablishedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6814                Ok((IsochronousStreamEvent::OnEstablished { payload: out }))
6815            }
6816            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6817                Ok(IsochronousStreamEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6818            }
6819            _ => Err(fidl::Error::UnknownOrdinal {
6820                ordinal: tx_header.ordinal,
6821                protocol_name:
6822                    <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6823            }),
6824        }
6825    }
6826}
6827
6828/// A Stream of incoming requests for fuchsia.bluetooth.le/IsochronousStream.
6829pub struct IsochronousStreamRequestStream {
6830    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6831    is_terminated: bool,
6832}
6833
6834impl std::marker::Unpin for IsochronousStreamRequestStream {}
6835
6836impl futures::stream::FusedStream for IsochronousStreamRequestStream {
6837    fn is_terminated(&self) -> bool {
6838        self.is_terminated
6839    }
6840}
6841
6842impl fidl::endpoints::RequestStream for IsochronousStreamRequestStream {
6843    type Protocol = IsochronousStreamMarker;
6844    type ControlHandle = IsochronousStreamControlHandle;
6845
6846    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6847        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6848    }
6849
6850    fn control_handle(&self) -> Self::ControlHandle {
6851        IsochronousStreamControlHandle { inner: self.inner.clone() }
6852    }
6853
6854    fn into_inner(
6855        self,
6856    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6857    {
6858        (self.inner, self.is_terminated)
6859    }
6860
6861    fn from_inner(
6862        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6863        is_terminated: bool,
6864    ) -> Self {
6865        Self { inner, is_terminated }
6866    }
6867}
6868
6869impl futures::Stream for IsochronousStreamRequestStream {
6870    type Item = Result<IsochronousStreamRequest, fidl::Error>;
6871
6872    fn poll_next(
6873        mut self: std::pin::Pin<&mut Self>,
6874        cx: &mut std::task::Context<'_>,
6875    ) -> std::task::Poll<Option<Self::Item>> {
6876        let this = &mut *self;
6877        if this.inner.check_shutdown(cx) {
6878            this.is_terminated = true;
6879            return std::task::Poll::Ready(None);
6880        }
6881        if this.is_terminated {
6882            panic!("polled IsochronousStreamRequestStream after completion");
6883        }
6884        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6885            |bytes, handles| {
6886                match this.inner.channel().read_etc(cx, bytes, handles) {
6887                    std::task::Poll::Ready(Ok(())) => {}
6888                    std::task::Poll::Pending => return std::task::Poll::Pending,
6889                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6890                        this.is_terminated = true;
6891                        return std::task::Poll::Ready(None);
6892                    }
6893                    std::task::Poll::Ready(Err(e)) => {
6894                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6895                            e.into(),
6896                        ))));
6897                    }
6898                }
6899
6900                // A message has been received from the channel
6901                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6902
6903                std::task::Poll::Ready(Some(match header.ordinal {
6904                    0x7ec1e2b9cc6d2fbe => {
6905                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6906                        let mut req = fidl::new_empty!(
6907                            IsochronousStreamSetupDataPathRequest,
6908                            fidl::encoding::DefaultFuchsiaResourceDialect
6909                        );
6910                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamSetupDataPathRequest>(&header, _body_bytes, handles, &mut req)?;
6911                        let control_handle =
6912                            IsochronousStreamControlHandle { inner: this.inner.clone() };
6913                        Ok(IsochronousStreamRequest::SetupDataPath {
6914                            payload: req,
6915                            responder: IsochronousStreamSetupDataPathResponder {
6916                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6917                                tx_id: header.tx_id,
6918                            },
6919                        })
6920                    }
6921                    0x6d7d8b4950ed3a32 => {
6922                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6923                        let mut req = fidl::new_empty!(
6924                            fidl::encoding::EmptyPayload,
6925                            fidl::encoding::DefaultFuchsiaResourceDialect
6926                        );
6927                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6928                        let control_handle =
6929                            IsochronousStreamControlHandle { inner: this.inner.clone() };
6930                        Ok(IsochronousStreamRequest::Read {
6931                            responder: IsochronousStreamReadResponder {
6932                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6933                                tx_id: header.tx_id,
6934                            },
6935                        })
6936                    }
6937                    0x5282e90b667d0d43 => {
6938                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6939                        let mut req = fidl::new_empty!(
6940                            IsochronousStreamWriteRequest,
6941                            fidl::encoding::DefaultFuchsiaResourceDialect
6942                        );
6943                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamWriteRequest>(&header, _body_bytes, handles, &mut req)?;
6944                        let control_handle =
6945                            IsochronousStreamControlHandle { inner: this.inner.clone() };
6946                        Ok(IsochronousStreamRequest::Write {
6947                            payload: req,
6948                            responder: IsochronousStreamWriteResponder {
6949                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6950                                tx_id: header.tx_id,
6951                            },
6952                        })
6953                    }
6954                    _ if header.tx_id == 0
6955                        && header
6956                            .dynamic_flags()
6957                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6958                    {
6959                        Ok(IsochronousStreamRequest::_UnknownMethod {
6960                            ordinal: header.ordinal,
6961                            control_handle: IsochronousStreamControlHandle {
6962                                inner: this.inner.clone(),
6963                            },
6964                            method_type: fidl::MethodType::OneWay,
6965                        })
6966                    }
6967                    _ if header
6968                        .dynamic_flags()
6969                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6970                    {
6971                        this.inner.send_framework_err(
6972                            fidl::encoding::FrameworkErr::UnknownMethod,
6973                            header.tx_id,
6974                            header.ordinal,
6975                            header.dynamic_flags(),
6976                            (bytes, handles),
6977                        )?;
6978                        Ok(IsochronousStreamRequest::_UnknownMethod {
6979                            ordinal: header.ordinal,
6980                            control_handle: IsochronousStreamControlHandle {
6981                                inner: this.inner.clone(),
6982                            },
6983                            method_type: fidl::MethodType::TwoWay,
6984                        })
6985                    }
6986                    _ => Err(fidl::Error::UnknownOrdinal {
6987                        ordinal: header.ordinal,
6988                        protocol_name:
6989                            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6990                    }),
6991                }))
6992            },
6993        )
6994    }
6995}
6996
6997#[derive(Debug)]
6998pub enum IsochronousStreamRequest {
6999    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
7000    /// transport is currently supported.
7001    ///
7002    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
7003    /// direction.
7004    ///
7005    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
7006    /// accepted.
7007    ///
7008    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
7009    /// controller's supported range.
7010    SetupDataPath {
7011        payload: IsochronousStreamSetupDataPathRequest,
7012        responder: IsochronousStreamSetupDataPathResponder,
7013    },
7014    /// Receive data from an output (controller => host) ISO stream that has been established and
7015    /// set up. Designed to be used with a hanging get pattern.
7016    ///
7017    /// Can be invoked before the ISO data stream has been established and set up, but will not
7018    /// return until after it has been set up and data has been received.
7019    Read { responder: IsochronousStreamReadResponder },
7020    /// Send data to an established ISO stream (host => controller).
7021    ///
7022    /// Returns ZX_ERR_INTERNAL for any errors encountered.
7023    Write { payload: IsochronousStreamWriteRequest, responder: IsochronousStreamWriteResponder },
7024    /// An interaction was received which does not match any known method.
7025    #[non_exhaustive]
7026    _UnknownMethod {
7027        /// Ordinal of the method that was called.
7028        ordinal: u64,
7029        control_handle: IsochronousStreamControlHandle,
7030        method_type: fidl::MethodType,
7031    },
7032}
7033
7034impl IsochronousStreamRequest {
7035    #[allow(irrefutable_let_patterns)]
7036    pub fn into_setup_data_path(
7037        self,
7038    ) -> Option<(IsochronousStreamSetupDataPathRequest, IsochronousStreamSetupDataPathResponder)>
7039    {
7040        if let IsochronousStreamRequest::SetupDataPath { payload, responder } = self {
7041            Some((payload, responder))
7042        } else {
7043            None
7044        }
7045    }
7046
7047    #[allow(irrefutable_let_patterns)]
7048    pub fn into_read(self) -> Option<(IsochronousStreamReadResponder)> {
7049        if let IsochronousStreamRequest::Read { responder } = self {
7050            Some((responder))
7051        } else {
7052            None
7053        }
7054    }
7055
7056    #[allow(irrefutable_let_patterns)]
7057    pub fn into_write(
7058        self,
7059    ) -> Option<(IsochronousStreamWriteRequest, IsochronousStreamWriteResponder)> {
7060        if let IsochronousStreamRequest::Write { payload, responder } = self {
7061            Some((payload, responder))
7062        } else {
7063            None
7064        }
7065    }
7066
7067    /// Name of the method defined in FIDL
7068    pub fn method_name(&self) -> &'static str {
7069        match *self {
7070            IsochronousStreamRequest::SetupDataPath { .. } => "setup_data_path",
7071            IsochronousStreamRequest::Read { .. } => "read",
7072            IsochronousStreamRequest::Write { .. } => "write",
7073            IsochronousStreamRequest::_UnknownMethod {
7074                method_type: fidl::MethodType::OneWay,
7075                ..
7076            } => "unknown one-way method",
7077            IsochronousStreamRequest::_UnknownMethod {
7078                method_type: fidl::MethodType::TwoWay,
7079                ..
7080            } => "unknown two-way method",
7081        }
7082    }
7083}
7084
7085#[derive(Debug, Clone)]
7086pub struct IsochronousStreamControlHandle {
7087    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7088}
7089
7090impl fidl::endpoints::ControlHandle for IsochronousStreamControlHandle {
7091    fn shutdown(&self) {
7092        self.inner.shutdown()
7093    }
7094
7095    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7096        self.inner.shutdown_with_epitaph(status)
7097    }
7098
7099    fn is_closed(&self) -> bool {
7100        self.inner.channel().is_closed()
7101    }
7102    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7103        self.inner.channel().on_closed()
7104    }
7105
7106    #[cfg(target_os = "fuchsia")]
7107    fn signal_peer(
7108        &self,
7109        clear_mask: zx::Signals,
7110        set_mask: zx::Signals,
7111    ) -> Result<(), zx_status::Status> {
7112        use fidl::Peered;
7113        self.inner.channel().signal_peer(clear_mask, set_mask)
7114    }
7115}
7116
7117impl IsochronousStreamControlHandle {
7118    pub fn send_on_established(
7119        &self,
7120        mut payload: &IsochronousStreamOnEstablishedRequest,
7121    ) -> Result<(), fidl::Error> {
7122        self.inner.send::<IsochronousStreamOnEstablishedRequest>(
7123            payload,
7124            0,
7125            0x341c50e9d10f3421,
7126            fidl::encoding::DynamicFlags::FLEXIBLE,
7127        )
7128    }
7129}
7130
7131#[must_use = "FIDL methods require a response to be sent"]
7132#[derive(Debug)]
7133pub struct IsochronousStreamSetupDataPathResponder {
7134    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
7135    tx_id: u32,
7136}
7137
7138/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
7139/// if the responder is dropped without sending a response, so that the client
7140/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7141impl std::ops::Drop for IsochronousStreamSetupDataPathResponder {
7142    fn drop(&mut self) {
7143        self.control_handle.shutdown();
7144        // Safety: drops once, never accessed again
7145        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7146    }
7147}
7148
7149impl fidl::endpoints::Responder for IsochronousStreamSetupDataPathResponder {
7150    type ControlHandle = IsochronousStreamControlHandle;
7151
7152    fn control_handle(&self) -> &IsochronousStreamControlHandle {
7153        &self.control_handle
7154    }
7155
7156    fn drop_without_shutdown(mut self) {
7157        // Safety: drops once, never accessed again due to mem::forget
7158        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7159        // Prevent Drop from running (which would shut down the channel)
7160        std::mem::forget(self);
7161    }
7162}
7163
7164impl IsochronousStreamSetupDataPathResponder {
7165    /// Sends a response to the FIDL transaction.
7166    ///
7167    /// Sets the channel to shutdown if an error occurs.
7168    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7169        let _result = self.send_raw(result);
7170        if _result.is_err() {
7171            self.control_handle.shutdown();
7172        }
7173        self.drop_without_shutdown();
7174        _result
7175    }
7176
7177    /// Similar to "send" but does not shutdown the channel if an error occurs.
7178    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7179        let _result = self.send_raw(result);
7180        self.drop_without_shutdown();
7181        _result
7182    }
7183
7184    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7185        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7186            fidl::encoding::EmptyStruct,
7187            i32,
7188        >>(
7189            fidl::encoding::FlexibleResult::new(result),
7190            self.tx_id,
7191            0x7ec1e2b9cc6d2fbe,
7192            fidl::encoding::DynamicFlags::FLEXIBLE,
7193        )
7194    }
7195}
7196
7197#[must_use = "FIDL methods require a response to be sent"]
7198#[derive(Debug)]
7199pub struct IsochronousStreamReadResponder {
7200    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
7201    tx_id: u32,
7202}
7203
7204/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
7205/// if the responder is dropped without sending a response, so that the client
7206/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7207impl std::ops::Drop for IsochronousStreamReadResponder {
7208    fn drop(&mut self) {
7209        self.control_handle.shutdown();
7210        // Safety: drops once, never accessed again
7211        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7212    }
7213}
7214
7215impl fidl::endpoints::Responder for IsochronousStreamReadResponder {
7216    type ControlHandle = IsochronousStreamControlHandle;
7217
7218    fn control_handle(&self) -> &IsochronousStreamControlHandle {
7219        &self.control_handle
7220    }
7221
7222    fn drop_without_shutdown(mut self) {
7223        // Safety: drops once, never accessed again due to mem::forget
7224        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7225        // Prevent Drop from running (which would shut down the channel)
7226        std::mem::forget(self);
7227    }
7228}
7229
7230impl IsochronousStreamReadResponder {
7231    /// Sends a response to the FIDL transaction.
7232    ///
7233    /// Sets the channel to shutdown if an error occurs.
7234    pub fn send(self, mut payload: &IsochronousStreamReadResponse) -> Result<(), fidl::Error> {
7235        let _result = self.send_raw(payload);
7236        if _result.is_err() {
7237            self.control_handle.shutdown();
7238        }
7239        self.drop_without_shutdown();
7240        _result
7241    }
7242
7243    /// Similar to "send" but does not shutdown the channel if an error occurs.
7244    pub fn send_no_shutdown_on_err(
7245        self,
7246        mut payload: &IsochronousStreamReadResponse,
7247    ) -> Result<(), fidl::Error> {
7248        let _result = self.send_raw(payload);
7249        self.drop_without_shutdown();
7250        _result
7251    }
7252
7253    fn send_raw(&self, mut payload: &IsochronousStreamReadResponse) -> Result<(), fidl::Error> {
7254        self.control_handle
7255            .inner
7256            .send::<fidl::encoding::FlexibleType<IsochronousStreamReadResponse>>(
7257                fidl::encoding::Flexible::new(payload),
7258                self.tx_id,
7259                0x6d7d8b4950ed3a32,
7260                fidl::encoding::DynamicFlags::FLEXIBLE,
7261            )
7262    }
7263}
7264
7265#[must_use = "FIDL methods require a response to be sent"]
7266#[derive(Debug)]
7267pub struct IsochronousStreamWriteResponder {
7268    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
7269    tx_id: u32,
7270}
7271
7272/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
7273/// if the responder is dropped without sending a response, so that the client
7274/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7275impl std::ops::Drop for IsochronousStreamWriteResponder {
7276    fn drop(&mut self) {
7277        self.control_handle.shutdown();
7278        // Safety: drops once, never accessed again
7279        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7280    }
7281}
7282
7283impl fidl::endpoints::Responder for IsochronousStreamWriteResponder {
7284    type ControlHandle = IsochronousStreamControlHandle;
7285
7286    fn control_handle(&self) -> &IsochronousStreamControlHandle {
7287        &self.control_handle
7288    }
7289
7290    fn drop_without_shutdown(mut self) {
7291        // Safety: drops once, never accessed again due to mem::forget
7292        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7293        // Prevent Drop from running (which would shut down the channel)
7294        std::mem::forget(self);
7295    }
7296}
7297
7298impl IsochronousStreamWriteResponder {
7299    /// Sends a response to the FIDL transaction.
7300    ///
7301    /// Sets the channel to shutdown if an error occurs.
7302    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7303        let _result = self.send_raw(result);
7304        if _result.is_err() {
7305            self.control_handle.shutdown();
7306        }
7307        self.drop_without_shutdown();
7308        _result
7309    }
7310
7311    /// Similar to "send" but does not shutdown the channel if an error occurs.
7312    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7313        let _result = self.send_raw(result);
7314        self.drop_without_shutdown();
7315        _result
7316    }
7317
7318    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7319        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7320            fidl::encoding::EmptyStruct,
7321            i32,
7322        >>(
7323            fidl::encoding::FlexibleResult::new(result),
7324            self.tx_id,
7325            0x5282e90b667d0d43,
7326            fidl::encoding::DynamicFlags::FLEXIBLE,
7327        )
7328    }
7329}
7330
7331#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7332pub struct PeriodicAdvertisingSyncMarker;
7333
7334impl fidl::endpoints::ProtocolMarker for PeriodicAdvertisingSyncMarker {
7335    type Proxy = PeriodicAdvertisingSyncProxy;
7336    type RequestStream = PeriodicAdvertisingSyncRequestStream;
7337    #[cfg(target_os = "fuchsia")]
7338    type SynchronousProxy = PeriodicAdvertisingSyncSynchronousProxy;
7339
7340    const DEBUG_NAME: &'static str = "(anonymous) PeriodicAdvertisingSync";
7341}
7342pub type PeriodicAdvertisingSyncSyncToSubeventsResult = Result<(), i32>;
7343
7344pub trait PeriodicAdvertisingSyncProxyInterface: Send + Sync {
7345    type WatchAdvertisingReportResponseFut: std::future::Future<
7346            Output = Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error>,
7347        > + Send;
7348    fn r#watch_advertising_report(&self) -> Self::WatchAdvertisingReportResponseFut;
7349    type SyncToSubeventsResponseFut: std::future::Future<
7350            Output = Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error>,
7351        > + Send;
7352    fn r#sync_to_subevents(
7353        &self,
7354        payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
7355    ) -> Self::SyncToSubeventsResponseFut;
7356    fn r#cancel(&self) -> Result<(), fidl::Error>;
7357}
7358#[derive(Debug)]
7359#[cfg(target_os = "fuchsia")]
7360pub struct PeriodicAdvertisingSyncSynchronousProxy {
7361    client: fidl::client::sync::Client,
7362}
7363
7364#[cfg(target_os = "fuchsia")]
7365impl fidl::endpoints::SynchronousProxy for PeriodicAdvertisingSyncSynchronousProxy {
7366    type Proxy = PeriodicAdvertisingSyncProxy;
7367    type Protocol = PeriodicAdvertisingSyncMarker;
7368
7369    fn from_channel(inner: fidl::Channel) -> Self {
7370        Self::new(inner)
7371    }
7372
7373    fn into_channel(self) -> fidl::Channel {
7374        self.client.into_channel()
7375    }
7376
7377    fn as_channel(&self) -> &fidl::Channel {
7378        self.client.as_channel()
7379    }
7380}
7381
7382#[cfg(target_os = "fuchsia")]
7383impl PeriodicAdvertisingSyncSynchronousProxy {
7384    pub fn new(channel: fidl::Channel) -> Self {
7385        let protocol_name =
7386            <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7387        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7388    }
7389
7390    pub fn into_channel(self) -> fidl::Channel {
7391        self.client.into_channel()
7392    }
7393
7394    /// Waits until an event arrives and returns it. It is safe for other
7395    /// threads to make concurrent requests while waiting for an event.
7396    pub fn wait_for_event(
7397        &self,
7398        deadline: zx::MonotonicInstant,
7399    ) -> Result<PeriodicAdvertisingSyncEvent, fidl::Error> {
7400        PeriodicAdvertisingSyncEvent::decode(self.client.wait_for_event(deadline)?)
7401    }
7402
7403    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
7404    /// Only one call may be pending at a time.
7405    pub fn r#watch_advertising_report(
7406        &self,
7407        ___deadline: zx::MonotonicInstant,
7408    ) -> Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error> {
7409        let _response = self.client.send_query::<
7410            fidl::encoding::EmptyPayload,
7411            fidl::encoding::FlexibleType<PeriodicAdvertisingSyncWatchAdvertisingReportResponse>,
7412        >(
7413            (),
7414            0x2ea610fea0e7d337,
7415            fidl::encoding::DynamicFlags::FLEXIBLE,
7416            ___deadline,
7417        )?
7418        .into_result::<PeriodicAdvertisingSyncMarker>("watch_advertising_report")?;
7419        Ok(_response)
7420    }
7421
7422    /// Synchronize to subevents of this periodic advertisement.
7423    /// * error FAILED: The synchronization failed.
7424    pub fn r#sync_to_subevents(
7425        &self,
7426        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
7427        ___deadline: zx::MonotonicInstant,
7428    ) -> Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error> {
7429        let _response = self.client.send_query::<
7430            PeriodicAdvertisingSyncSyncToSubeventsRequest,
7431            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7432        >(
7433            payload,
7434            0x653c5dab1f1d80ed,
7435            fidl::encoding::DynamicFlags::FLEXIBLE,
7436            ___deadline,
7437        )?
7438        .into_result::<PeriodicAdvertisingSyncMarker>("sync_to_subevents")?;
7439        Ok(_response.map(|x| x))
7440    }
7441
7442    /// The server will end the synchronization and then close the protocol.
7443    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
7444    /// Advertisement.
7445    /// Synchronization can also be cancelled by closing the protocol on the client end.
7446    pub fn r#cancel(&self) -> Result<(), fidl::Error> {
7447        self.client.send::<fidl::encoding::EmptyPayload>(
7448            (),
7449            0xd617c037eaf5d92,
7450            fidl::encoding::DynamicFlags::FLEXIBLE,
7451        )
7452    }
7453}
7454
7455#[cfg(target_os = "fuchsia")]
7456impl From<PeriodicAdvertisingSyncSynchronousProxy> for zx::NullableHandle {
7457    fn from(value: PeriodicAdvertisingSyncSynchronousProxy) -> Self {
7458        value.into_channel().into()
7459    }
7460}
7461
7462#[cfg(target_os = "fuchsia")]
7463impl From<fidl::Channel> for PeriodicAdvertisingSyncSynchronousProxy {
7464    fn from(value: fidl::Channel) -> Self {
7465        Self::new(value)
7466    }
7467}
7468
7469#[cfg(target_os = "fuchsia")]
7470impl fidl::endpoints::FromClient for PeriodicAdvertisingSyncSynchronousProxy {
7471    type Protocol = PeriodicAdvertisingSyncMarker;
7472
7473    fn from_client(value: fidl::endpoints::ClientEnd<PeriodicAdvertisingSyncMarker>) -> Self {
7474        Self::new(value.into_channel())
7475    }
7476}
7477
7478#[derive(Debug, Clone)]
7479pub struct PeriodicAdvertisingSyncProxy {
7480    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7481}
7482
7483impl fidl::endpoints::Proxy for PeriodicAdvertisingSyncProxy {
7484    type Protocol = PeriodicAdvertisingSyncMarker;
7485
7486    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7487        Self::new(inner)
7488    }
7489
7490    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7491        self.client.into_channel().map_err(|client| Self { client })
7492    }
7493
7494    fn as_channel(&self) -> &::fidl::AsyncChannel {
7495        self.client.as_channel()
7496    }
7497}
7498
7499impl PeriodicAdvertisingSyncProxy {
7500    /// Create a new Proxy for fuchsia.bluetooth.le/PeriodicAdvertisingSync.
7501    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7502        let protocol_name =
7503            <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7504        Self { client: fidl::client::Client::new(channel, protocol_name) }
7505    }
7506
7507    /// Get a Stream of events from the remote end of the protocol.
7508    ///
7509    /// # Panics
7510    ///
7511    /// Panics if the event stream was already taken.
7512    pub fn take_event_stream(&self) -> PeriodicAdvertisingSyncEventStream {
7513        PeriodicAdvertisingSyncEventStream { event_receiver: self.client.take_event_receiver() }
7514    }
7515
7516    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
7517    /// Only one call may be pending at a time.
7518    pub fn r#watch_advertising_report(
7519        &self,
7520    ) -> fidl::client::QueryResponseFut<
7521        PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
7522        fidl::encoding::DefaultFuchsiaResourceDialect,
7523    > {
7524        PeriodicAdvertisingSyncProxyInterface::r#watch_advertising_report(self)
7525    }
7526
7527    /// Synchronize to subevents of this periodic advertisement.
7528    /// * error FAILED: The synchronization failed.
7529    pub fn r#sync_to_subevents(
7530        &self,
7531        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
7532    ) -> fidl::client::QueryResponseFut<
7533        PeriodicAdvertisingSyncSyncToSubeventsResult,
7534        fidl::encoding::DefaultFuchsiaResourceDialect,
7535    > {
7536        PeriodicAdvertisingSyncProxyInterface::r#sync_to_subevents(self, payload)
7537    }
7538
7539    /// The server will end the synchronization and then close the protocol.
7540    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
7541    /// Advertisement.
7542    /// Synchronization can also be cancelled by closing the protocol on the client end.
7543    pub fn r#cancel(&self) -> Result<(), fidl::Error> {
7544        PeriodicAdvertisingSyncProxyInterface::r#cancel(self)
7545    }
7546}
7547
7548impl PeriodicAdvertisingSyncProxyInterface for PeriodicAdvertisingSyncProxy {
7549    type WatchAdvertisingReportResponseFut = fidl::client::QueryResponseFut<
7550        PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
7551        fidl::encoding::DefaultFuchsiaResourceDialect,
7552    >;
7553    fn r#watch_advertising_report(&self) -> Self::WatchAdvertisingReportResponseFut {
7554        fn _decode(
7555            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7556        ) -> Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error> {
7557            let _response = fidl::client::decode_transaction_body::<
7558                fidl::encoding::FlexibleType<PeriodicAdvertisingSyncWatchAdvertisingReportResponse>,
7559                fidl::encoding::DefaultFuchsiaResourceDialect,
7560                0x2ea610fea0e7d337,
7561            >(_buf?)?
7562            .into_result::<PeriodicAdvertisingSyncMarker>("watch_advertising_report")?;
7563            Ok(_response)
7564        }
7565        self.client.send_query_and_decode::<
7566            fidl::encoding::EmptyPayload,
7567            PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
7568        >(
7569            (),
7570            0x2ea610fea0e7d337,
7571            fidl::encoding::DynamicFlags::FLEXIBLE,
7572            _decode,
7573        )
7574    }
7575
7576    type SyncToSubeventsResponseFut = fidl::client::QueryResponseFut<
7577        PeriodicAdvertisingSyncSyncToSubeventsResult,
7578        fidl::encoding::DefaultFuchsiaResourceDialect,
7579    >;
7580    fn r#sync_to_subevents(
7581        &self,
7582        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
7583    ) -> Self::SyncToSubeventsResponseFut {
7584        fn _decode(
7585            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7586        ) -> Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error> {
7587            let _response = fidl::client::decode_transaction_body::<
7588                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7589                fidl::encoding::DefaultFuchsiaResourceDialect,
7590                0x653c5dab1f1d80ed,
7591            >(_buf?)?
7592            .into_result::<PeriodicAdvertisingSyncMarker>("sync_to_subevents")?;
7593            Ok(_response.map(|x| x))
7594        }
7595        self.client.send_query_and_decode::<
7596            PeriodicAdvertisingSyncSyncToSubeventsRequest,
7597            PeriodicAdvertisingSyncSyncToSubeventsResult,
7598        >(
7599            payload,
7600            0x653c5dab1f1d80ed,
7601            fidl::encoding::DynamicFlags::FLEXIBLE,
7602            _decode,
7603        )
7604    }
7605
7606    fn r#cancel(&self) -> Result<(), fidl::Error> {
7607        self.client.send::<fidl::encoding::EmptyPayload>(
7608            (),
7609            0xd617c037eaf5d92,
7610            fidl::encoding::DynamicFlags::FLEXIBLE,
7611        )
7612    }
7613}
7614
7615pub struct PeriodicAdvertisingSyncEventStream {
7616    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7617}
7618
7619impl std::marker::Unpin for PeriodicAdvertisingSyncEventStream {}
7620
7621impl futures::stream::FusedStream for PeriodicAdvertisingSyncEventStream {
7622    fn is_terminated(&self) -> bool {
7623        self.event_receiver.is_terminated()
7624    }
7625}
7626
7627impl futures::Stream for PeriodicAdvertisingSyncEventStream {
7628    type Item = Result<PeriodicAdvertisingSyncEvent, fidl::Error>;
7629
7630    fn poll_next(
7631        mut self: std::pin::Pin<&mut Self>,
7632        cx: &mut std::task::Context<'_>,
7633    ) -> std::task::Poll<Option<Self::Item>> {
7634        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7635            &mut self.event_receiver,
7636            cx
7637        )?) {
7638            Some(buf) => std::task::Poll::Ready(Some(PeriodicAdvertisingSyncEvent::decode(buf))),
7639            None => std::task::Poll::Ready(None),
7640        }
7641    }
7642}
7643
7644#[derive(Debug)]
7645pub enum PeriodicAdvertisingSyncEvent {
7646    OnEstablished {
7647        payload: PeriodicAdvertisingSyncOnEstablishedRequest,
7648    },
7649    OnError {
7650        error: PeriodicAdvertisingSyncError,
7651    },
7652    #[non_exhaustive]
7653    _UnknownEvent {
7654        /// Ordinal of the event that was sent.
7655        ordinal: u64,
7656    },
7657}
7658
7659impl PeriodicAdvertisingSyncEvent {
7660    #[allow(irrefutable_let_patterns)]
7661    pub fn into_on_established(self) -> Option<PeriodicAdvertisingSyncOnEstablishedRequest> {
7662        if let PeriodicAdvertisingSyncEvent::OnEstablished { payload } = self {
7663            Some((payload))
7664        } else {
7665            None
7666        }
7667    }
7668    #[allow(irrefutable_let_patterns)]
7669    pub fn into_on_error(self) -> Option<PeriodicAdvertisingSyncError> {
7670        if let PeriodicAdvertisingSyncEvent::OnError { error } = self {
7671            Some((error))
7672        } else {
7673            None
7674        }
7675    }
7676
7677    /// Decodes a message buffer as a [`PeriodicAdvertisingSyncEvent`].
7678    fn decode(
7679        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7680    ) -> Result<PeriodicAdvertisingSyncEvent, fidl::Error> {
7681        let (bytes, _handles) = buf.split_mut();
7682        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7683        debug_assert_eq!(tx_header.tx_id, 0);
7684        match tx_header.ordinal {
7685            0x4a5c307761c40fdc => {
7686                let mut out = fidl::new_empty!(
7687                    PeriodicAdvertisingSyncOnEstablishedRequest,
7688                    fidl::encoding::DefaultFuchsiaResourceDialect
7689                );
7690                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncOnEstablishedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7691                Ok((PeriodicAdvertisingSyncEvent::OnEstablished { payload: out }))
7692            }
7693            0x1c051673126ce4a => {
7694                let mut out = fidl::new_empty!(
7695                    PeriodicAdvertisingSyncOnErrorRequest,
7696                    fidl::encoding::DefaultFuchsiaResourceDialect
7697                );
7698                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncOnErrorRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7699                Ok((PeriodicAdvertisingSyncEvent::OnError { error: out.error }))
7700            }
7701            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7702                Ok(PeriodicAdvertisingSyncEvent::_UnknownEvent { ordinal: tx_header.ordinal })
7703            }
7704            _ => Err(fidl::Error::UnknownOrdinal {
7705                ordinal: tx_header.ordinal,
7706                protocol_name:
7707                    <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7708            }),
7709        }
7710    }
7711}
7712
7713/// A Stream of incoming requests for fuchsia.bluetooth.le/PeriodicAdvertisingSync.
7714pub struct PeriodicAdvertisingSyncRequestStream {
7715    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7716    is_terminated: bool,
7717}
7718
7719impl std::marker::Unpin for PeriodicAdvertisingSyncRequestStream {}
7720
7721impl futures::stream::FusedStream for PeriodicAdvertisingSyncRequestStream {
7722    fn is_terminated(&self) -> bool {
7723        self.is_terminated
7724    }
7725}
7726
7727impl fidl::endpoints::RequestStream for PeriodicAdvertisingSyncRequestStream {
7728    type Protocol = PeriodicAdvertisingSyncMarker;
7729    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
7730
7731    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7732        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7733    }
7734
7735    fn control_handle(&self) -> Self::ControlHandle {
7736        PeriodicAdvertisingSyncControlHandle { inner: self.inner.clone() }
7737    }
7738
7739    fn into_inner(
7740        self,
7741    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7742    {
7743        (self.inner, self.is_terminated)
7744    }
7745
7746    fn from_inner(
7747        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7748        is_terminated: bool,
7749    ) -> Self {
7750        Self { inner, is_terminated }
7751    }
7752}
7753
7754impl futures::Stream for PeriodicAdvertisingSyncRequestStream {
7755    type Item = Result<PeriodicAdvertisingSyncRequest, fidl::Error>;
7756
7757    fn poll_next(
7758        mut self: std::pin::Pin<&mut Self>,
7759        cx: &mut std::task::Context<'_>,
7760    ) -> std::task::Poll<Option<Self::Item>> {
7761        let this = &mut *self;
7762        if this.inner.check_shutdown(cx) {
7763            this.is_terminated = true;
7764            return std::task::Poll::Ready(None);
7765        }
7766        if this.is_terminated {
7767            panic!("polled PeriodicAdvertisingSyncRequestStream after completion");
7768        }
7769        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7770            |bytes, handles| {
7771                match this.inner.channel().read_etc(cx, bytes, handles) {
7772                    std::task::Poll::Ready(Ok(())) => {}
7773                    std::task::Poll::Pending => return std::task::Poll::Pending,
7774                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7775                        this.is_terminated = true;
7776                        return std::task::Poll::Ready(None);
7777                    }
7778                    std::task::Poll::Ready(Err(e)) => {
7779                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7780                            e.into(),
7781                        ))));
7782                    }
7783                }
7784
7785                // A message has been received from the channel
7786                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7787
7788                std::task::Poll::Ready(Some(match header.ordinal {
7789                0x2ea610fea0e7d337 => {
7790                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7791                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7792                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7793                    let control_handle = PeriodicAdvertisingSyncControlHandle {
7794                        inner: this.inner.clone(),
7795                    };
7796                    Ok(PeriodicAdvertisingSyncRequest::WatchAdvertisingReport {
7797                        responder: PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
7798                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7799                            tx_id: header.tx_id,
7800                        },
7801                    })
7802                }
7803                0x653c5dab1f1d80ed => {
7804                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7805                    let mut req = fidl::new_empty!(PeriodicAdvertisingSyncSyncToSubeventsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7806                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncSyncToSubeventsRequest>(&header, _body_bytes, handles, &mut req)?;
7807                    let control_handle = PeriodicAdvertisingSyncControlHandle {
7808                        inner: this.inner.clone(),
7809                    };
7810                    Ok(PeriodicAdvertisingSyncRequest::SyncToSubevents {payload: req,
7811                        responder: PeriodicAdvertisingSyncSyncToSubeventsResponder {
7812                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7813                            tx_id: header.tx_id,
7814                        },
7815                    })
7816                }
7817                0xd617c037eaf5d92 => {
7818                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7819                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7820                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7821                    let control_handle = PeriodicAdvertisingSyncControlHandle {
7822                        inner: this.inner.clone(),
7823                    };
7824                    Ok(PeriodicAdvertisingSyncRequest::Cancel {
7825                        control_handle,
7826                    })
7827                }
7828                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7829                    Ok(PeriodicAdvertisingSyncRequest::_UnknownMethod {
7830                        ordinal: header.ordinal,
7831                        control_handle: PeriodicAdvertisingSyncControlHandle { inner: this.inner.clone() },
7832                        method_type: fidl::MethodType::OneWay,
7833                    })
7834                }
7835                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7836                    this.inner.send_framework_err(
7837                        fidl::encoding::FrameworkErr::UnknownMethod,
7838                        header.tx_id,
7839                        header.ordinal,
7840                        header.dynamic_flags(),
7841                        (bytes, handles),
7842                    )?;
7843                    Ok(PeriodicAdvertisingSyncRequest::_UnknownMethod {
7844                        ordinal: header.ordinal,
7845                        control_handle: PeriodicAdvertisingSyncControlHandle { inner: this.inner.clone() },
7846                        method_type: fidl::MethodType::TwoWay,
7847                    })
7848                }
7849                _ => Err(fidl::Error::UnknownOrdinal {
7850                    ordinal: header.ordinal,
7851                    protocol_name: <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7852                }),
7853            }))
7854            },
7855        )
7856    }
7857}
7858
7859/// Closed by the server when the sync fails to be established or is lost.
7860#[derive(Debug)]
7861pub enum PeriodicAdvertisingSyncRequest {
7862    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
7863    /// Only one call may be pending at a time.
7864    WatchAdvertisingReport { responder: PeriodicAdvertisingSyncWatchAdvertisingReportResponder },
7865    /// Synchronize to subevents of this periodic advertisement.
7866    /// * error FAILED: The synchronization failed.
7867    SyncToSubevents {
7868        payload: PeriodicAdvertisingSyncSyncToSubeventsRequest,
7869        responder: PeriodicAdvertisingSyncSyncToSubeventsResponder,
7870    },
7871    /// The server will end the synchronization and then close the protocol.
7872    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
7873    /// Advertisement.
7874    /// Synchronization can also be cancelled by closing the protocol on the client end.
7875    Cancel { control_handle: PeriodicAdvertisingSyncControlHandle },
7876    /// An interaction was received which does not match any known method.
7877    #[non_exhaustive]
7878    _UnknownMethod {
7879        /// Ordinal of the method that was called.
7880        ordinal: u64,
7881        control_handle: PeriodicAdvertisingSyncControlHandle,
7882        method_type: fidl::MethodType,
7883    },
7884}
7885
7886impl PeriodicAdvertisingSyncRequest {
7887    #[allow(irrefutable_let_patterns)]
7888    pub fn into_watch_advertising_report(
7889        self,
7890    ) -> Option<(PeriodicAdvertisingSyncWatchAdvertisingReportResponder)> {
7891        if let PeriodicAdvertisingSyncRequest::WatchAdvertisingReport { responder } = self {
7892            Some((responder))
7893        } else {
7894            None
7895        }
7896    }
7897
7898    #[allow(irrefutable_let_patterns)]
7899    pub fn into_sync_to_subevents(
7900        self,
7901    ) -> Option<(
7902        PeriodicAdvertisingSyncSyncToSubeventsRequest,
7903        PeriodicAdvertisingSyncSyncToSubeventsResponder,
7904    )> {
7905        if let PeriodicAdvertisingSyncRequest::SyncToSubevents { payload, responder } = self {
7906            Some((payload, responder))
7907        } else {
7908            None
7909        }
7910    }
7911
7912    #[allow(irrefutable_let_patterns)]
7913    pub fn into_cancel(self) -> Option<(PeriodicAdvertisingSyncControlHandle)> {
7914        if let PeriodicAdvertisingSyncRequest::Cancel { control_handle } = self {
7915            Some((control_handle))
7916        } else {
7917            None
7918        }
7919    }
7920
7921    /// Name of the method defined in FIDL
7922    pub fn method_name(&self) -> &'static str {
7923        match *self {
7924            PeriodicAdvertisingSyncRequest::WatchAdvertisingReport { .. } => {
7925                "watch_advertising_report"
7926            }
7927            PeriodicAdvertisingSyncRequest::SyncToSubevents { .. } => "sync_to_subevents",
7928            PeriodicAdvertisingSyncRequest::Cancel { .. } => "cancel",
7929            PeriodicAdvertisingSyncRequest::_UnknownMethod {
7930                method_type: fidl::MethodType::OneWay,
7931                ..
7932            } => "unknown one-way method",
7933            PeriodicAdvertisingSyncRequest::_UnknownMethod {
7934                method_type: fidl::MethodType::TwoWay,
7935                ..
7936            } => "unknown two-way method",
7937        }
7938    }
7939}
7940
7941#[derive(Debug, Clone)]
7942pub struct PeriodicAdvertisingSyncControlHandle {
7943    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7944}
7945
7946impl fidl::endpoints::ControlHandle for PeriodicAdvertisingSyncControlHandle {
7947    fn shutdown(&self) {
7948        self.inner.shutdown()
7949    }
7950
7951    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7952        self.inner.shutdown_with_epitaph(status)
7953    }
7954
7955    fn is_closed(&self) -> bool {
7956        self.inner.channel().is_closed()
7957    }
7958    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7959        self.inner.channel().on_closed()
7960    }
7961
7962    #[cfg(target_os = "fuchsia")]
7963    fn signal_peer(
7964        &self,
7965        clear_mask: zx::Signals,
7966        set_mask: zx::Signals,
7967    ) -> Result<(), zx_status::Status> {
7968        use fidl::Peered;
7969        self.inner.channel().signal_peer(clear_mask, set_mask)
7970    }
7971}
7972
7973impl PeriodicAdvertisingSyncControlHandle {
7974    pub fn send_on_established(
7975        &self,
7976        mut payload: &PeriodicAdvertisingSyncOnEstablishedRequest,
7977    ) -> Result<(), fidl::Error> {
7978        self.inner.send::<PeriodicAdvertisingSyncOnEstablishedRequest>(
7979            payload,
7980            0,
7981            0x4a5c307761c40fdc,
7982            fidl::encoding::DynamicFlags::FLEXIBLE,
7983        )
7984    }
7985
7986    pub fn send_on_error(
7987        &self,
7988        mut error: PeriodicAdvertisingSyncError,
7989    ) -> Result<(), fidl::Error> {
7990        self.inner.send::<PeriodicAdvertisingSyncOnErrorRequest>(
7991            (error,),
7992            0,
7993            0x1c051673126ce4a,
7994            fidl::encoding::DynamicFlags::FLEXIBLE,
7995        )
7996    }
7997}
7998
7999#[must_use = "FIDL methods require a response to be sent"]
8000#[derive(Debug)]
8001pub struct PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8002    control_handle: std::mem::ManuallyDrop<PeriodicAdvertisingSyncControlHandle>,
8003    tx_id: u32,
8004}
8005
8006/// Set the the channel to be shutdown (see [`PeriodicAdvertisingSyncControlHandle::shutdown`])
8007/// if the responder is dropped without sending a response, so that the client
8008/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8009impl std::ops::Drop for PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8010    fn drop(&mut self) {
8011        self.control_handle.shutdown();
8012        // Safety: drops once, never accessed again
8013        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8014    }
8015}
8016
8017impl fidl::endpoints::Responder for PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8018    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
8019
8020    fn control_handle(&self) -> &PeriodicAdvertisingSyncControlHandle {
8021        &self.control_handle
8022    }
8023
8024    fn drop_without_shutdown(mut self) {
8025        // Safety: drops once, never accessed again due to mem::forget
8026        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8027        // Prevent Drop from running (which would shut down the channel)
8028        std::mem::forget(self);
8029    }
8030}
8031
8032impl PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8033    /// Sends a response to the FIDL transaction.
8034    ///
8035    /// Sets the channel to shutdown if an error occurs.
8036    pub fn send(
8037        self,
8038        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8039    ) -> Result<(), fidl::Error> {
8040        let _result = self.send_raw(payload);
8041        if _result.is_err() {
8042            self.control_handle.shutdown();
8043        }
8044        self.drop_without_shutdown();
8045        _result
8046    }
8047
8048    /// Similar to "send" but does not shutdown the channel if an error occurs.
8049    pub fn send_no_shutdown_on_err(
8050        self,
8051        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8052    ) -> Result<(), fidl::Error> {
8053        let _result = self.send_raw(payload);
8054        self.drop_without_shutdown();
8055        _result
8056    }
8057
8058    fn send_raw(
8059        &self,
8060        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8061    ) -> Result<(), fidl::Error> {
8062        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
8063            PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8064        >>(
8065            fidl::encoding::Flexible::new(payload),
8066            self.tx_id,
8067            0x2ea610fea0e7d337,
8068            fidl::encoding::DynamicFlags::FLEXIBLE,
8069        )
8070    }
8071}
8072
8073#[must_use = "FIDL methods require a response to be sent"]
8074#[derive(Debug)]
8075pub struct PeriodicAdvertisingSyncSyncToSubeventsResponder {
8076    control_handle: std::mem::ManuallyDrop<PeriodicAdvertisingSyncControlHandle>,
8077    tx_id: u32,
8078}
8079
8080/// Set the the channel to be shutdown (see [`PeriodicAdvertisingSyncControlHandle::shutdown`])
8081/// if the responder is dropped without sending a response, so that the client
8082/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8083impl std::ops::Drop for PeriodicAdvertisingSyncSyncToSubeventsResponder {
8084    fn drop(&mut self) {
8085        self.control_handle.shutdown();
8086        // Safety: drops once, never accessed again
8087        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8088    }
8089}
8090
8091impl fidl::endpoints::Responder for PeriodicAdvertisingSyncSyncToSubeventsResponder {
8092    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
8093
8094    fn control_handle(&self) -> &PeriodicAdvertisingSyncControlHandle {
8095        &self.control_handle
8096    }
8097
8098    fn drop_without_shutdown(mut self) {
8099        // Safety: drops once, never accessed again due to mem::forget
8100        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8101        // Prevent Drop from running (which would shut down the channel)
8102        std::mem::forget(self);
8103    }
8104}
8105
8106impl PeriodicAdvertisingSyncSyncToSubeventsResponder {
8107    /// Sends a response to the FIDL transaction.
8108    ///
8109    /// Sets the channel to shutdown if an error occurs.
8110    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8111        let _result = self.send_raw(result);
8112        if _result.is_err() {
8113            self.control_handle.shutdown();
8114        }
8115        self.drop_without_shutdown();
8116        _result
8117    }
8118
8119    /// Similar to "send" but does not shutdown the channel if an error occurs.
8120    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8121        let _result = self.send_raw(result);
8122        self.drop_without_shutdown();
8123        _result
8124    }
8125
8126    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8127        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8128            fidl::encoding::EmptyStruct,
8129            i32,
8130        >>(
8131            fidl::encoding::FlexibleResult::new(result),
8132            self.tx_id,
8133            0x653c5dab1f1d80ed,
8134            fidl::encoding::DynamicFlags::FLEXIBLE,
8135        )
8136    }
8137}
8138
8139#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8140pub struct PeripheralMarker;
8141
8142impl fidl::endpoints::ProtocolMarker for PeripheralMarker {
8143    type Proxy = PeripheralProxy;
8144    type RequestStream = PeripheralRequestStream;
8145    #[cfg(target_os = "fuchsia")]
8146    type SynchronousProxy = PeripheralSynchronousProxy;
8147
8148    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.Peripheral";
8149}
8150impl fidl::endpoints::DiscoverableProtocolMarker for PeripheralMarker {}
8151pub type PeripheralAdvertiseResult = Result<(), PeripheralError>;
8152pub type PeripheralStartAdvertisingResult = Result<(), PeripheralError>;
8153
8154pub trait PeripheralProxyInterface: Send + Sync {
8155    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
8156        + Send;
8157    fn r#listen_l2cap(
8158        &self,
8159        payload: ChannelListenerRegistryListenL2capRequest,
8160    ) -> Self::ListenL2capResponseFut;
8161    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralAdvertiseResult, fidl::Error>>
8162        + Send;
8163    fn r#advertise(
8164        &self,
8165        parameters: &AdvertisingParameters,
8166        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8167    ) -> Self::AdvertiseResponseFut;
8168    type StartAdvertisingResponseFut: std::future::Future<Output = Result<PeripheralStartAdvertisingResult, fidl::Error>>
8169        + Send;
8170    fn r#start_advertising(
8171        &self,
8172        parameters: &AdvertisingParameters,
8173        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8174    ) -> Self::StartAdvertisingResponseFut;
8175}
8176#[derive(Debug)]
8177#[cfg(target_os = "fuchsia")]
8178pub struct PeripheralSynchronousProxy {
8179    client: fidl::client::sync::Client,
8180}
8181
8182#[cfg(target_os = "fuchsia")]
8183impl fidl::endpoints::SynchronousProxy for PeripheralSynchronousProxy {
8184    type Proxy = PeripheralProxy;
8185    type Protocol = PeripheralMarker;
8186
8187    fn from_channel(inner: fidl::Channel) -> Self {
8188        Self::new(inner)
8189    }
8190
8191    fn into_channel(self) -> fidl::Channel {
8192        self.client.into_channel()
8193    }
8194
8195    fn as_channel(&self) -> &fidl::Channel {
8196        self.client.as_channel()
8197    }
8198}
8199
8200#[cfg(target_os = "fuchsia")]
8201impl PeripheralSynchronousProxy {
8202    pub fn new(channel: fidl::Channel) -> Self {
8203        let protocol_name = <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8204        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8205    }
8206
8207    pub fn into_channel(self) -> fidl::Channel {
8208        self.client.into_channel()
8209    }
8210
8211    /// Waits until an event arrives and returns it. It is safe for other
8212    /// threads to make concurrent requests while waiting for an event.
8213    pub fn wait_for_event(
8214        &self,
8215        deadline: zx::MonotonicInstant,
8216    ) -> Result<PeripheralEvent, fidl::Error> {
8217        PeripheralEvent::decode(self.client.wait_for_event(deadline)?)
8218    }
8219
8220    /// Register a listener for incoming channels. The registry will assign a
8221    /// PSM value that is unique for the local device, as well as open a
8222    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
8223    /// event that all PSMs have been assigned, this call will fail with
8224    /// `ZX_ERR_NO_RESOURCES`.
8225    ///
8226    /// Note that the method of service discovery or advertising is defined by
8227    /// the service or protocol, so it is the responsibility of the caller to
8228    /// communicate the assigned PSM to any clients.
8229    pub fn r#listen_l2cap(
8230        &self,
8231        mut payload: ChannelListenerRegistryListenL2capRequest,
8232        ___deadline: zx::MonotonicInstant,
8233    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
8234        let _response = self.client.send_query::<
8235            ChannelListenerRegistryListenL2capRequest,
8236            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
8237        >(
8238            &mut payload,
8239            0x39c6e9001d102338,
8240            fidl::encoding::DynamicFlags::empty(),
8241            ___deadline,
8242        )?;
8243        Ok(_response.map(|x| x))
8244    }
8245
8246    /// Start advertising continuously as a LE peripheral. If advertising cannot
8247    /// be initiated then `advertised_peripheral` will be closed and an error
8248    /// will be returned.
8249    ///
8250    /// This method may be called any number of times. To reconfigure an
8251    /// advertisement, first close the original advertisement and then initiate
8252    /// a new advertisement after an empty response is returned.
8253    ///
8254    /// If the client closes its end of the
8255    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
8256    /// advertising will be stopped. If the handle is closed before the request
8257    /// is fulfilled, advertising may be briefly enabled before it is
8258    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
8259    /// the Peripheral protocol, but this may be changed in the future
8260    /// (https://fxbug.dev/42157682).
8261    ///
8262    /// + request `parameters` Parameters used while configuring the advertising
8263    ///   instance.
8264    /// + request `advertised_peripheral` Protocol that remains valid for the
8265    ///   duration of this advertising session.
8266    /// - response An empty response will be sent when the advertisement is
8267    ///   successfully stopped (due to release of the `advertised_peripheral`
8268    ///   protocol). To prevent overlapping similar advertisements and transient
8269    ///   errors with limited advertising resources, waiting for a response is
8270    ///   recommended before calling `Advertise` again.
8271    /// * error If an error occurs, `advertised_peripheral` will be closed and a
8272    ///   `PeripheralError` will be returned.
8273    pub fn r#advertise(
8274        &self,
8275        mut parameters: &AdvertisingParameters,
8276        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8277        ___deadline: zx::MonotonicInstant,
8278    ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
8279        let _response = self.client.send_query::<
8280            PeripheralAdvertiseRequest,
8281            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8282        >(
8283            (parameters, advertised_peripheral,),
8284            0x2d9ec9260c32c17f,
8285            fidl::encoding::DynamicFlags::empty(),
8286            ___deadline,
8287        )?;
8288        Ok(_response.map(|x| x))
8289    }
8290
8291    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
8292    /// has successfully initiated. If advertising cannot be initiated, then the response will
8293    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
8294    ///
8295    /// This method can get called any number of times and successive calls can be made to
8296    /// reconfigure the advertising parameters. However only the most recent
8297    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
8298    ///
8299    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
8300    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
8301    /// advertisements.
8302    ///
8303    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
8304    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
8305    /// advertising will be briefly enabled before it is terminated.
8306    ///
8307    /// + request `parameters` Parameters used while configuring the advertising instance.
8308    /// + request `handle` Handle that remains valid for the duration of this advertising session.
8309    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
8310    ///         initiated. In this case the `handle` will be closed.
8311    pub fn r#start_advertising(
8312        &self,
8313        mut parameters: &AdvertisingParameters,
8314        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8315        ___deadline: zx::MonotonicInstant,
8316    ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
8317        let _response = self.client.send_query::<
8318            PeripheralStartAdvertisingRequest,
8319            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8320        >(
8321            (parameters, handle,),
8322            0x5875c1c575f00f7d,
8323            fidl::encoding::DynamicFlags::empty(),
8324            ___deadline,
8325        )?;
8326        Ok(_response.map(|x| x))
8327    }
8328}
8329
8330#[cfg(target_os = "fuchsia")]
8331impl From<PeripheralSynchronousProxy> for zx::NullableHandle {
8332    fn from(value: PeripheralSynchronousProxy) -> Self {
8333        value.into_channel().into()
8334    }
8335}
8336
8337#[cfg(target_os = "fuchsia")]
8338impl From<fidl::Channel> for PeripheralSynchronousProxy {
8339    fn from(value: fidl::Channel) -> Self {
8340        Self::new(value)
8341    }
8342}
8343
8344#[cfg(target_os = "fuchsia")]
8345impl fidl::endpoints::FromClient for PeripheralSynchronousProxy {
8346    type Protocol = PeripheralMarker;
8347
8348    fn from_client(value: fidl::endpoints::ClientEnd<PeripheralMarker>) -> Self {
8349        Self::new(value.into_channel())
8350    }
8351}
8352
8353#[derive(Debug, Clone)]
8354pub struct PeripheralProxy {
8355    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8356}
8357
8358impl fidl::endpoints::Proxy for PeripheralProxy {
8359    type Protocol = PeripheralMarker;
8360
8361    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8362        Self::new(inner)
8363    }
8364
8365    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8366        self.client.into_channel().map_err(|client| Self { client })
8367    }
8368
8369    fn as_channel(&self) -> &::fidl::AsyncChannel {
8370        self.client.as_channel()
8371    }
8372}
8373
8374impl PeripheralProxy {
8375    /// Create a new Proxy for fuchsia.bluetooth.le/Peripheral.
8376    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8377        let protocol_name = <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8378        Self { client: fidl::client::Client::new(channel, protocol_name) }
8379    }
8380
8381    /// Get a Stream of events from the remote end of the protocol.
8382    ///
8383    /// # Panics
8384    ///
8385    /// Panics if the event stream was already taken.
8386    pub fn take_event_stream(&self) -> PeripheralEventStream {
8387        PeripheralEventStream { event_receiver: self.client.take_event_receiver() }
8388    }
8389
8390    /// Register a listener for incoming channels. The registry will assign a
8391    /// PSM value that is unique for the local device, as well as open a
8392    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
8393    /// event that all PSMs have been assigned, this call will fail with
8394    /// `ZX_ERR_NO_RESOURCES`.
8395    ///
8396    /// Note that the method of service discovery or advertising is defined by
8397    /// the service or protocol, so it is the responsibility of the caller to
8398    /// communicate the assigned PSM to any clients.
8399    pub fn r#listen_l2cap(
8400        &self,
8401        mut payload: ChannelListenerRegistryListenL2capRequest,
8402    ) -> fidl::client::QueryResponseFut<
8403        ChannelListenerRegistryListenL2capResult,
8404        fidl::encoding::DefaultFuchsiaResourceDialect,
8405    > {
8406        PeripheralProxyInterface::r#listen_l2cap(self, payload)
8407    }
8408
8409    /// Start advertising continuously as a LE peripheral. If advertising cannot
8410    /// be initiated then `advertised_peripheral` will be closed and an error
8411    /// will be returned.
8412    ///
8413    /// This method may be called any number of times. To reconfigure an
8414    /// advertisement, first close the original advertisement and then initiate
8415    /// a new advertisement after an empty response is returned.
8416    ///
8417    /// If the client closes its end of the
8418    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
8419    /// advertising will be stopped. If the handle is closed before the request
8420    /// is fulfilled, advertising may be briefly enabled before it is
8421    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
8422    /// the Peripheral protocol, but this may be changed in the future
8423    /// (https://fxbug.dev/42157682).
8424    ///
8425    /// + request `parameters` Parameters used while configuring the advertising
8426    ///   instance.
8427    /// + request `advertised_peripheral` Protocol that remains valid for the
8428    ///   duration of this advertising session.
8429    /// - response An empty response will be sent when the advertisement is
8430    ///   successfully stopped (due to release of the `advertised_peripheral`
8431    ///   protocol). To prevent overlapping similar advertisements and transient
8432    ///   errors with limited advertising resources, waiting for a response is
8433    ///   recommended before calling `Advertise` again.
8434    /// * error If an error occurs, `advertised_peripheral` will be closed and a
8435    ///   `PeripheralError` will be returned.
8436    pub fn r#advertise(
8437        &self,
8438        mut parameters: &AdvertisingParameters,
8439        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8440    ) -> fidl::client::QueryResponseFut<
8441        PeripheralAdvertiseResult,
8442        fidl::encoding::DefaultFuchsiaResourceDialect,
8443    > {
8444        PeripheralProxyInterface::r#advertise(self, parameters, advertised_peripheral)
8445    }
8446
8447    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
8448    /// has successfully initiated. If advertising cannot be initiated, then the response will
8449    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
8450    ///
8451    /// This method can get called any number of times and successive calls can be made to
8452    /// reconfigure the advertising parameters. However only the most recent
8453    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
8454    ///
8455    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
8456    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
8457    /// advertisements.
8458    ///
8459    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
8460    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
8461    /// advertising will be briefly enabled before it is terminated.
8462    ///
8463    /// + request `parameters` Parameters used while configuring the advertising instance.
8464    /// + request `handle` Handle that remains valid for the duration of this advertising session.
8465    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
8466    ///         initiated. In this case the `handle` will be closed.
8467    pub fn r#start_advertising(
8468        &self,
8469        mut parameters: &AdvertisingParameters,
8470        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8471    ) -> fidl::client::QueryResponseFut<
8472        PeripheralStartAdvertisingResult,
8473        fidl::encoding::DefaultFuchsiaResourceDialect,
8474    > {
8475        PeripheralProxyInterface::r#start_advertising(self, parameters, handle)
8476    }
8477}
8478
8479impl PeripheralProxyInterface for PeripheralProxy {
8480    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
8481        ChannelListenerRegistryListenL2capResult,
8482        fidl::encoding::DefaultFuchsiaResourceDialect,
8483    >;
8484    fn r#listen_l2cap(
8485        &self,
8486        mut payload: ChannelListenerRegistryListenL2capRequest,
8487    ) -> Self::ListenL2capResponseFut {
8488        fn _decode(
8489            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8490        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
8491            let _response = fidl::client::decode_transaction_body::<
8492                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
8493                fidl::encoding::DefaultFuchsiaResourceDialect,
8494                0x39c6e9001d102338,
8495            >(_buf?)?;
8496            Ok(_response.map(|x| x))
8497        }
8498        self.client.send_query_and_decode::<
8499            ChannelListenerRegistryListenL2capRequest,
8500            ChannelListenerRegistryListenL2capResult,
8501        >(
8502            &mut payload,
8503            0x39c6e9001d102338,
8504            fidl::encoding::DynamicFlags::empty(),
8505            _decode,
8506        )
8507    }
8508
8509    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
8510        PeripheralAdvertiseResult,
8511        fidl::encoding::DefaultFuchsiaResourceDialect,
8512    >;
8513    fn r#advertise(
8514        &self,
8515        mut parameters: &AdvertisingParameters,
8516        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8517    ) -> Self::AdvertiseResponseFut {
8518        fn _decode(
8519            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8520        ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
8521            let _response = fidl::client::decode_transaction_body::<
8522                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8523                fidl::encoding::DefaultFuchsiaResourceDialect,
8524                0x2d9ec9260c32c17f,
8525            >(_buf?)?;
8526            Ok(_response.map(|x| x))
8527        }
8528        self.client.send_query_and_decode::<PeripheralAdvertiseRequest, PeripheralAdvertiseResult>(
8529            (parameters, advertised_peripheral),
8530            0x2d9ec9260c32c17f,
8531            fidl::encoding::DynamicFlags::empty(),
8532            _decode,
8533        )
8534    }
8535
8536    type StartAdvertisingResponseFut = fidl::client::QueryResponseFut<
8537        PeripheralStartAdvertisingResult,
8538        fidl::encoding::DefaultFuchsiaResourceDialect,
8539    >;
8540    fn r#start_advertising(
8541        &self,
8542        mut parameters: &AdvertisingParameters,
8543        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8544    ) -> Self::StartAdvertisingResponseFut {
8545        fn _decode(
8546            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8547        ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
8548            let _response = fidl::client::decode_transaction_body::<
8549                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8550                fidl::encoding::DefaultFuchsiaResourceDialect,
8551                0x5875c1c575f00f7d,
8552            >(_buf?)?;
8553            Ok(_response.map(|x| x))
8554        }
8555        self.client.send_query_and_decode::<
8556            PeripheralStartAdvertisingRequest,
8557            PeripheralStartAdvertisingResult,
8558        >(
8559            (parameters, handle,),
8560            0x5875c1c575f00f7d,
8561            fidl::encoding::DynamicFlags::empty(),
8562            _decode,
8563        )
8564    }
8565}
8566
8567pub struct PeripheralEventStream {
8568    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8569}
8570
8571impl std::marker::Unpin for PeripheralEventStream {}
8572
8573impl futures::stream::FusedStream for PeripheralEventStream {
8574    fn is_terminated(&self) -> bool {
8575        self.event_receiver.is_terminated()
8576    }
8577}
8578
8579impl futures::Stream for PeripheralEventStream {
8580    type Item = Result<PeripheralEvent, fidl::Error>;
8581
8582    fn poll_next(
8583        mut self: std::pin::Pin<&mut Self>,
8584        cx: &mut std::task::Context<'_>,
8585    ) -> std::task::Poll<Option<Self::Item>> {
8586        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8587            &mut self.event_receiver,
8588            cx
8589        )?) {
8590            Some(buf) => std::task::Poll::Ready(Some(PeripheralEvent::decode(buf))),
8591            None => std::task::Poll::Ready(None),
8592        }
8593    }
8594}
8595
8596#[derive(Debug)]
8597pub enum PeripheralEvent {
8598    OnPeerConnected { peer: Peer, connection: fidl::endpoints::ClientEnd<ConnectionMarker> },
8599}
8600
8601impl PeripheralEvent {
8602    #[allow(irrefutable_let_patterns)]
8603    pub fn into_on_peer_connected(
8604        self,
8605    ) -> Option<(Peer, fidl::endpoints::ClientEnd<ConnectionMarker>)> {
8606        if let PeripheralEvent::OnPeerConnected { peer, connection } = self {
8607            Some((peer, connection))
8608        } else {
8609            None
8610        }
8611    }
8612
8613    /// Decodes a message buffer as a [`PeripheralEvent`].
8614    fn decode(
8615        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8616    ) -> Result<PeripheralEvent, fidl::Error> {
8617        let (bytes, _handles) = buf.split_mut();
8618        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8619        debug_assert_eq!(tx_header.tx_id, 0);
8620        match tx_header.ordinal {
8621            0x16135d464299e356 => {
8622                let mut out = fidl::new_empty!(
8623                    PeripheralOnPeerConnectedRequest,
8624                    fidl::encoding::DefaultFuchsiaResourceDialect
8625                );
8626                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralOnPeerConnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
8627                Ok((PeripheralEvent::OnPeerConnected {
8628                    peer: out.peer,
8629                    connection: out.connection,
8630                }))
8631            }
8632            _ => Err(fidl::Error::UnknownOrdinal {
8633                ordinal: tx_header.ordinal,
8634                protocol_name: <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8635            }),
8636        }
8637    }
8638}
8639
8640/// A Stream of incoming requests for fuchsia.bluetooth.le/Peripheral.
8641pub struct PeripheralRequestStream {
8642    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8643    is_terminated: bool,
8644}
8645
8646impl std::marker::Unpin for PeripheralRequestStream {}
8647
8648impl futures::stream::FusedStream for PeripheralRequestStream {
8649    fn is_terminated(&self) -> bool {
8650        self.is_terminated
8651    }
8652}
8653
8654impl fidl::endpoints::RequestStream for PeripheralRequestStream {
8655    type Protocol = PeripheralMarker;
8656    type ControlHandle = PeripheralControlHandle;
8657
8658    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8659        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8660    }
8661
8662    fn control_handle(&self) -> Self::ControlHandle {
8663        PeripheralControlHandle { inner: self.inner.clone() }
8664    }
8665
8666    fn into_inner(
8667        self,
8668    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8669    {
8670        (self.inner, self.is_terminated)
8671    }
8672
8673    fn from_inner(
8674        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8675        is_terminated: bool,
8676    ) -> Self {
8677        Self { inner, is_terminated }
8678    }
8679}
8680
8681impl futures::Stream for PeripheralRequestStream {
8682    type Item = Result<PeripheralRequest, fidl::Error>;
8683
8684    fn poll_next(
8685        mut self: std::pin::Pin<&mut Self>,
8686        cx: &mut std::task::Context<'_>,
8687    ) -> std::task::Poll<Option<Self::Item>> {
8688        let this = &mut *self;
8689        if this.inner.check_shutdown(cx) {
8690            this.is_terminated = true;
8691            return std::task::Poll::Ready(None);
8692        }
8693        if this.is_terminated {
8694            panic!("polled PeripheralRequestStream after completion");
8695        }
8696        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8697            |bytes, handles| {
8698                match this.inner.channel().read_etc(cx, bytes, handles) {
8699                    std::task::Poll::Ready(Ok(())) => {}
8700                    std::task::Poll::Pending => return std::task::Poll::Pending,
8701                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8702                        this.is_terminated = true;
8703                        return std::task::Poll::Ready(None);
8704                    }
8705                    std::task::Poll::Ready(Err(e)) => {
8706                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8707                            e.into(),
8708                        ))));
8709                    }
8710                }
8711
8712                // A message has been received from the channel
8713                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8714
8715                std::task::Poll::Ready(Some(match header.ordinal {
8716                    0x39c6e9001d102338 => {
8717                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8718                        let mut req = fidl::new_empty!(
8719                            ChannelListenerRegistryListenL2capRequest,
8720                            fidl::encoding::DefaultFuchsiaResourceDialect
8721                        );
8722                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
8723                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
8724                        Ok(PeripheralRequest::ListenL2cap {
8725                            payload: req,
8726                            responder: PeripheralListenL2capResponder {
8727                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8728                                tx_id: header.tx_id,
8729                            },
8730                        })
8731                    }
8732                    0x2d9ec9260c32c17f => {
8733                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8734                        let mut req = fidl::new_empty!(
8735                            PeripheralAdvertiseRequest,
8736                            fidl::encoding::DefaultFuchsiaResourceDialect
8737                        );
8738                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
8739                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
8740                        Ok(PeripheralRequest::Advertise {
8741                            parameters: req.parameters,
8742                            advertised_peripheral: req.advertised_peripheral,
8743
8744                            responder: PeripheralAdvertiseResponder {
8745                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8746                                tx_id: header.tx_id,
8747                            },
8748                        })
8749                    }
8750                    0x5875c1c575f00f7d => {
8751                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8752                        let mut req = fidl::new_empty!(
8753                            PeripheralStartAdvertisingRequest,
8754                            fidl::encoding::DefaultFuchsiaResourceDialect
8755                        );
8756                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralStartAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
8757                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
8758                        Ok(PeripheralRequest::StartAdvertising {
8759                            parameters: req.parameters,
8760                            handle: req.handle,
8761
8762                            responder: PeripheralStartAdvertisingResponder {
8763                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8764                                tx_id: header.tx_id,
8765                            },
8766                        })
8767                    }
8768                    _ => Err(fidl::Error::UnknownOrdinal {
8769                        ordinal: header.ordinal,
8770                        protocol_name:
8771                            <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8772                    }),
8773                }))
8774            },
8775        )
8776    }
8777}
8778
8779#[derive(Debug)]
8780pub enum PeripheralRequest {
8781    /// Register a listener for incoming channels. The registry will assign a
8782    /// PSM value that is unique for the local device, as well as open a
8783    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
8784    /// event that all PSMs have been assigned, this call will fail with
8785    /// `ZX_ERR_NO_RESOURCES`.
8786    ///
8787    /// Note that the method of service discovery or advertising is defined by
8788    /// the service or protocol, so it is the responsibility of the caller to
8789    /// communicate the assigned PSM to any clients.
8790    ListenL2cap {
8791        payload: ChannelListenerRegistryListenL2capRequest,
8792        responder: PeripheralListenL2capResponder,
8793    },
8794    /// Start advertising continuously as a LE peripheral. If advertising cannot
8795    /// be initiated then `advertised_peripheral` will be closed and an error
8796    /// will be returned.
8797    ///
8798    /// This method may be called any number of times. To reconfigure an
8799    /// advertisement, first close the original advertisement and then initiate
8800    /// a new advertisement after an empty response is returned.
8801    ///
8802    /// If the client closes its end of the
8803    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
8804    /// advertising will be stopped. If the handle is closed before the request
8805    /// is fulfilled, advertising may be briefly enabled before it is
8806    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
8807    /// the Peripheral protocol, but this may be changed in the future
8808    /// (https://fxbug.dev/42157682).
8809    ///
8810    /// + request `parameters` Parameters used while configuring the advertising
8811    ///   instance.
8812    /// + request `advertised_peripheral` Protocol that remains valid for the
8813    ///   duration of this advertising session.
8814    /// - response An empty response will be sent when the advertisement is
8815    ///   successfully stopped (due to release of the `advertised_peripheral`
8816    ///   protocol). To prevent overlapping similar advertisements and transient
8817    ///   errors with limited advertising resources, waiting for a response is
8818    ///   recommended before calling `Advertise` again.
8819    /// * error If an error occurs, `advertised_peripheral` will be closed and a
8820    ///   `PeripheralError` will be returned.
8821    Advertise {
8822        parameters: AdvertisingParameters,
8823        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8824        responder: PeripheralAdvertiseResponder,
8825    },
8826    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
8827    /// has successfully initiated. If advertising cannot be initiated, then the response will
8828    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
8829    ///
8830    /// This method can get called any number of times and successive calls can be made to
8831    /// reconfigure the advertising parameters. However only the most recent
8832    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
8833    ///
8834    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
8835    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
8836    /// advertisements.
8837    ///
8838    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
8839    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
8840    /// advertising will be briefly enabled before it is terminated.
8841    ///
8842    /// + request `parameters` Parameters used while configuring the advertising instance.
8843    /// + request `handle` Handle that remains valid for the duration of this advertising session.
8844    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
8845    ///         initiated. In this case the `handle` will be closed.
8846    StartAdvertising {
8847        parameters: AdvertisingParameters,
8848        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8849        responder: PeripheralStartAdvertisingResponder,
8850    },
8851}
8852
8853impl PeripheralRequest {
8854    #[allow(irrefutable_let_patterns)]
8855    pub fn into_listen_l2cap(
8856        self,
8857    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PeripheralListenL2capResponder)> {
8858        if let PeripheralRequest::ListenL2cap { payload, responder } = self {
8859            Some((payload, responder))
8860        } else {
8861            None
8862        }
8863    }
8864
8865    #[allow(irrefutable_let_patterns)]
8866    pub fn into_advertise(
8867        self,
8868    ) -> Option<(
8869        AdvertisingParameters,
8870        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8871        PeripheralAdvertiseResponder,
8872    )> {
8873        if let PeripheralRequest::Advertise { parameters, advertised_peripheral, responder } = self
8874        {
8875            Some((parameters, advertised_peripheral, responder))
8876        } else {
8877            None
8878        }
8879    }
8880
8881    #[allow(irrefutable_let_patterns)]
8882    pub fn into_start_advertising(
8883        self,
8884    ) -> Option<(
8885        AdvertisingParameters,
8886        fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8887        PeripheralStartAdvertisingResponder,
8888    )> {
8889        if let PeripheralRequest::StartAdvertising { parameters, handle, responder } = self {
8890            Some((parameters, handle, responder))
8891        } else {
8892            None
8893        }
8894    }
8895
8896    /// Name of the method defined in FIDL
8897    pub fn method_name(&self) -> &'static str {
8898        match *self {
8899            PeripheralRequest::ListenL2cap { .. } => "listen_l2cap",
8900            PeripheralRequest::Advertise { .. } => "advertise",
8901            PeripheralRequest::StartAdvertising { .. } => "start_advertising",
8902        }
8903    }
8904}
8905
8906#[derive(Debug, Clone)]
8907pub struct PeripheralControlHandle {
8908    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8909}
8910
8911impl fidl::endpoints::ControlHandle for PeripheralControlHandle {
8912    fn shutdown(&self) {
8913        self.inner.shutdown()
8914    }
8915
8916    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8917        self.inner.shutdown_with_epitaph(status)
8918    }
8919
8920    fn is_closed(&self) -> bool {
8921        self.inner.channel().is_closed()
8922    }
8923    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8924        self.inner.channel().on_closed()
8925    }
8926
8927    #[cfg(target_os = "fuchsia")]
8928    fn signal_peer(
8929        &self,
8930        clear_mask: zx::Signals,
8931        set_mask: zx::Signals,
8932    ) -> Result<(), zx_status::Status> {
8933        use fidl::Peered;
8934        self.inner.channel().signal_peer(clear_mask, set_mask)
8935    }
8936}
8937
8938impl PeripheralControlHandle {
8939    pub fn send_on_peer_connected(
8940        &self,
8941        mut peer: &Peer,
8942        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
8943    ) -> Result<(), fidl::Error> {
8944        self.inner.send::<PeripheralOnPeerConnectedRequest>(
8945            (peer, connection),
8946            0,
8947            0x16135d464299e356,
8948            fidl::encoding::DynamicFlags::empty(),
8949        )
8950    }
8951}
8952
8953#[must_use = "FIDL methods require a response to be sent"]
8954#[derive(Debug)]
8955pub struct PeripheralListenL2capResponder {
8956    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
8957    tx_id: u32,
8958}
8959
8960/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
8961/// if the responder is dropped without sending a response, so that the client
8962/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8963impl std::ops::Drop for PeripheralListenL2capResponder {
8964    fn drop(&mut self) {
8965        self.control_handle.shutdown();
8966        // Safety: drops once, never accessed again
8967        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8968    }
8969}
8970
8971impl fidl::endpoints::Responder for PeripheralListenL2capResponder {
8972    type ControlHandle = PeripheralControlHandle;
8973
8974    fn control_handle(&self) -> &PeripheralControlHandle {
8975        &self.control_handle
8976    }
8977
8978    fn drop_without_shutdown(mut self) {
8979        // Safety: drops once, never accessed again due to mem::forget
8980        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8981        // Prevent Drop from running (which would shut down the channel)
8982        std::mem::forget(self);
8983    }
8984}
8985
8986impl PeripheralListenL2capResponder {
8987    /// Sends a response to the FIDL transaction.
8988    ///
8989    /// Sets the channel to shutdown if an error occurs.
8990    pub fn send(
8991        self,
8992        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
8993    ) -> Result<(), fidl::Error> {
8994        let _result = self.send_raw(result);
8995        if _result.is_err() {
8996            self.control_handle.shutdown();
8997        }
8998        self.drop_without_shutdown();
8999        _result
9000    }
9001
9002    /// Similar to "send" but does not shutdown the channel if an error occurs.
9003    pub fn send_no_shutdown_on_err(
9004        self,
9005        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
9006    ) -> Result<(), fidl::Error> {
9007        let _result = self.send_raw(result);
9008        self.drop_without_shutdown();
9009        _result
9010    }
9011
9012    fn send_raw(
9013        &self,
9014        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
9015    ) -> Result<(), fidl::Error> {
9016        self.control_handle.inner.send::<fidl::encoding::ResultType<
9017            ChannelListenerRegistryListenL2capResponse,
9018            i32,
9019        >>(
9020            result,
9021            self.tx_id,
9022            0x39c6e9001d102338,
9023            fidl::encoding::DynamicFlags::empty(),
9024        )
9025    }
9026}
9027
9028#[must_use = "FIDL methods require a response to be sent"]
9029#[derive(Debug)]
9030pub struct PeripheralAdvertiseResponder {
9031    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
9032    tx_id: u32,
9033}
9034
9035/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
9036/// if the responder is dropped without sending a response, so that the client
9037/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9038impl std::ops::Drop for PeripheralAdvertiseResponder {
9039    fn drop(&mut self) {
9040        self.control_handle.shutdown();
9041        // Safety: drops once, never accessed again
9042        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9043    }
9044}
9045
9046impl fidl::endpoints::Responder for PeripheralAdvertiseResponder {
9047    type ControlHandle = PeripheralControlHandle;
9048
9049    fn control_handle(&self) -> &PeripheralControlHandle {
9050        &self.control_handle
9051    }
9052
9053    fn drop_without_shutdown(mut self) {
9054        // Safety: drops once, never accessed again due to mem::forget
9055        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9056        // Prevent Drop from running (which would shut down the channel)
9057        std::mem::forget(self);
9058    }
9059}
9060
9061impl PeripheralAdvertiseResponder {
9062    /// Sends a response to the FIDL transaction.
9063    ///
9064    /// Sets the channel to shutdown if an error occurs.
9065    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9066        let _result = self.send_raw(result);
9067        if _result.is_err() {
9068            self.control_handle.shutdown();
9069        }
9070        self.drop_without_shutdown();
9071        _result
9072    }
9073
9074    /// Similar to "send" but does not shutdown the channel if an error occurs.
9075    pub fn send_no_shutdown_on_err(
9076        self,
9077        mut result: Result<(), PeripheralError>,
9078    ) -> Result<(), fidl::Error> {
9079        let _result = self.send_raw(result);
9080        self.drop_without_shutdown();
9081        _result
9082    }
9083
9084    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9085        self.control_handle.inner.send::<fidl::encoding::ResultType<
9086            fidl::encoding::EmptyStruct,
9087            PeripheralError,
9088        >>(
9089            result,
9090            self.tx_id,
9091            0x2d9ec9260c32c17f,
9092            fidl::encoding::DynamicFlags::empty(),
9093        )
9094    }
9095}
9096
9097#[must_use = "FIDL methods require a response to be sent"]
9098#[derive(Debug)]
9099pub struct PeripheralStartAdvertisingResponder {
9100    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
9101    tx_id: u32,
9102}
9103
9104/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
9105/// if the responder is dropped without sending a response, so that the client
9106/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9107impl std::ops::Drop for PeripheralStartAdvertisingResponder {
9108    fn drop(&mut self) {
9109        self.control_handle.shutdown();
9110        // Safety: drops once, never accessed again
9111        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9112    }
9113}
9114
9115impl fidl::endpoints::Responder for PeripheralStartAdvertisingResponder {
9116    type ControlHandle = PeripheralControlHandle;
9117
9118    fn control_handle(&self) -> &PeripheralControlHandle {
9119        &self.control_handle
9120    }
9121
9122    fn drop_without_shutdown(mut self) {
9123        // Safety: drops once, never accessed again due to mem::forget
9124        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9125        // Prevent Drop from running (which would shut down the channel)
9126        std::mem::forget(self);
9127    }
9128}
9129
9130impl PeripheralStartAdvertisingResponder {
9131    /// Sends a response to the FIDL transaction.
9132    ///
9133    /// Sets the channel to shutdown if an error occurs.
9134    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9135        let _result = self.send_raw(result);
9136        if _result.is_err() {
9137            self.control_handle.shutdown();
9138        }
9139        self.drop_without_shutdown();
9140        _result
9141    }
9142
9143    /// Similar to "send" but does not shutdown the channel if an error occurs.
9144    pub fn send_no_shutdown_on_err(
9145        self,
9146        mut result: Result<(), PeripheralError>,
9147    ) -> Result<(), fidl::Error> {
9148        let _result = self.send_raw(result);
9149        self.drop_without_shutdown();
9150        _result
9151    }
9152
9153    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9154        self.control_handle.inner.send::<fidl::encoding::ResultType<
9155            fidl::encoding::EmptyStruct,
9156            PeripheralError,
9157        >>(
9158            result,
9159            self.tx_id,
9160            0x5875c1c575f00f7d,
9161            fidl::encoding::DynamicFlags::empty(),
9162        )
9163    }
9164}
9165
9166#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9167pub struct PrivilegedPeripheralMarker;
9168
9169impl fidl::endpoints::ProtocolMarker for PrivilegedPeripheralMarker {
9170    type Proxy = PrivilegedPeripheralProxy;
9171    type RequestStream = PrivilegedPeripheralRequestStream;
9172    #[cfg(target_os = "fuchsia")]
9173    type SynchronousProxy = PrivilegedPeripheralSynchronousProxy;
9174
9175    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.PrivilegedPeripheral";
9176}
9177impl fidl::endpoints::DiscoverableProtocolMarker for PrivilegedPeripheralMarker {}
9178
9179pub trait PrivilegedPeripheralProxyInterface: Send + Sync {
9180    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
9181        + Send;
9182    fn r#listen_l2cap(
9183        &self,
9184        payload: ChannelListenerRegistryListenL2capRequest,
9185    ) -> Self::ListenL2capResponseFut;
9186    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralAdvertiseResult, fidl::Error>>
9187        + Send;
9188    fn r#advertise(
9189        &self,
9190        parameters: &AdvertisingParameters,
9191        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9192    ) -> Self::AdvertiseResponseFut;
9193    type StartAdvertisingResponseFut: std::future::Future<Output = Result<PeripheralStartAdvertisingResult, fidl::Error>>
9194        + Send;
9195    fn r#start_advertising(
9196        &self,
9197        parameters: &AdvertisingParameters,
9198        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9199    ) -> Self::StartAdvertisingResponseFut;
9200}
9201#[derive(Debug)]
9202#[cfg(target_os = "fuchsia")]
9203pub struct PrivilegedPeripheralSynchronousProxy {
9204    client: fidl::client::sync::Client,
9205}
9206
9207#[cfg(target_os = "fuchsia")]
9208impl fidl::endpoints::SynchronousProxy for PrivilegedPeripheralSynchronousProxy {
9209    type Proxy = PrivilegedPeripheralProxy;
9210    type Protocol = PrivilegedPeripheralMarker;
9211
9212    fn from_channel(inner: fidl::Channel) -> Self {
9213        Self::new(inner)
9214    }
9215
9216    fn into_channel(self) -> fidl::Channel {
9217        self.client.into_channel()
9218    }
9219
9220    fn as_channel(&self) -> &fidl::Channel {
9221        self.client.as_channel()
9222    }
9223}
9224
9225#[cfg(target_os = "fuchsia")]
9226impl PrivilegedPeripheralSynchronousProxy {
9227    pub fn new(channel: fidl::Channel) -> Self {
9228        let protocol_name =
9229            <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9230        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
9231    }
9232
9233    pub fn into_channel(self) -> fidl::Channel {
9234        self.client.into_channel()
9235    }
9236
9237    /// Waits until an event arrives and returns it. It is safe for other
9238    /// threads to make concurrent requests while waiting for an event.
9239    pub fn wait_for_event(
9240        &self,
9241        deadline: zx::MonotonicInstant,
9242    ) -> Result<PrivilegedPeripheralEvent, fidl::Error> {
9243        PrivilegedPeripheralEvent::decode(self.client.wait_for_event(deadline)?)
9244    }
9245
9246    /// Register a listener for incoming channels. The registry will assign a
9247    /// PSM value that is unique for the local device, as well as open a
9248    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
9249    /// event that all PSMs have been assigned, this call will fail with
9250    /// `ZX_ERR_NO_RESOURCES`.
9251    ///
9252    /// Note that the method of service discovery or advertising is defined by
9253    /// the service or protocol, so it is the responsibility of the caller to
9254    /// communicate the assigned PSM to any clients.
9255    pub fn r#listen_l2cap(
9256        &self,
9257        mut payload: ChannelListenerRegistryListenL2capRequest,
9258        ___deadline: zx::MonotonicInstant,
9259    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
9260        let _response = self.client.send_query::<
9261            ChannelListenerRegistryListenL2capRequest,
9262            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
9263        >(
9264            &mut payload,
9265            0x39c6e9001d102338,
9266            fidl::encoding::DynamicFlags::empty(),
9267            ___deadline,
9268        )?;
9269        Ok(_response.map(|x| x))
9270    }
9271
9272    /// Start advertising continuously as a LE peripheral. If advertising cannot
9273    /// be initiated then `advertised_peripheral` will be closed and an error
9274    /// will be returned.
9275    ///
9276    /// This method may be called any number of times. To reconfigure an
9277    /// advertisement, first close the original advertisement and then initiate
9278    /// a new advertisement after an empty response is returned.
9279    ///
9280    /// If the client closes its end of the
9281    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9282    /// advertising will be stopped. If the handle is closed before the request
9283    /// is fulfilled, advertising may be briefly enabled before it is
9284    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9285    /// the Peripheral protocol, but this may be changed in the future
9286    /// (https://fxbug.dev/42157682).
9287    ///
9288    /// + request `parameters` Parameters used while configuring the advertising
9289    ///   instance.
9290    /// + request `advertised_peripheral` Protocol that remains valid for the
9291    ///   duration of this advertising session.
9292    /// - response An empty response will be sent when the advertisement is
9293    ///   successfully stopped (due to release of the `advertised_peripheral`
9294    ///   protocol). To prevent overlapping similar advertisements and transient
9295    ///   errors with limited advertising resources, waiting for a response is
9296    ///   recommended before calling `Advertise` again.
9297    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9298    ///   `PeripheralError` will be returned.
9299    pub fn r#advertise(
9300        &self,
9301        mut parameters: &AdvertisingParameters,
9302        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9303        ___deadline: zx::MonotonicInstant,
9304    ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
9305        let _response = self.client.send_query::<
9306            PeripheralAdvertiseRequest,
9307            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9308        >(
9309            (parameters, advertised_peripheral,),
9310            0x2d9ec9260c32c17f,
9311            fidl::encoding::DynamicFlags::empty(),
9312            ___deadline,
9313        )?;
9314        Ok(_response.map(|x| x))
9315    }
9316
9317    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9318    /// has successfully initiated. If advertising cannot be initiated, then the response will
9319    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9320    ///
9321    /// This method can get called any number of times and successive calls can be made to
9322    /// reconfigure the advertising parameters. However only the most recent
9323    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9324    ///
9325    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9326    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9327    /// advertisements.
9328    ///
9329    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9330    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9331    /// advertising will be briefly enabled before it is terminated.
9332    ///
9333    /// + request `parameters` Parameters used while configuring the advertising instance.
9334    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9335    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9336    ///         initiated. In this case the `handle` will be closed.
9337    pub fn r#start_advertising(
9338        &self,
9339        mut parameters: &AdvertisingParameters,
9340        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9341        ___deadline: zx::MonotonicInstant,
9342    ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
9343        let _response = self.client.send_query::<
9344            PeripheralStartAdvertisingRequest,
9345            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9346        >(
9347            (parameters, handle,),
9348            0x5875c1c575f00f7d,
9349            fidl::encoding::DynamicFlags::empty(),
9350            ___deadline,
9351        )?;
9352        Ok(_response.map(|x| x))
9353    }
9354}
9355
9356#[cfg(target_os = "fuchsia")]
9357impl From<PrivilegedPeripheralSynchronousProxy> for zx::NullableHandle {
9358    fn from(value: PrivilegedPeripheralSynchronousProxy) -> Self {
9359        value.into_channel().into()
9360    }
9361}
9362
9363#[cfg(target_os = "fuchsia")]
9364impl From<fidl::Channel> for PrivilegedPeripheralSynchronousProxy {
9365    fn from(value: fidl::Channel) -> Self {
9366        Self::new(value)
9367    }
9368}
9369
9370#[cfg(target_os = "fuchsia")]
9371impl fidl::endpoints::FromClient for PrivilegedPeripheralSynchronousProxy {
9372    type Protocol = PrivilegedPeripheralMarker;
9373
9374    fn from_client(value: fidl::endpoints::ClientEnd<PrivilegedPeripheralMarker>) -> Self {
9375        Self::new(value.into_channel())
9376    }
9377}
9378
9379#[derive(Debug, Clone)]
9380pub struct PrivilegedPeripheralProxy {
9381    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
9382}
9383
9384impl fidl::endpoints::Proxy for PrivilegedPeripheralProxy {
9385    type Protocol = PrivilegedPeripheralMarker;
9386
9387    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
9388        Self::new(inner)
9389    }
9390
9391    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
9392        self.client.into_channel().map_err(|client| Self { client })
9393    }
9394
9395    fn as_channel(&self) -> &::fidl::AsyncChannel {
9396        self.client.as_channel()
9397    }
9398}
9399
9400impl PrivilegedPeripheralProxy {
9401    /// Create a new Proxy for fuchsia.bluetooth.le/PrivilegedPeripheral.
9402    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
9403        let protocol_name =
9404            <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9405        Self { client: fidl::client::Client::new(channel, protocol_name) }
9406    }
9407
9408    /// Get a Stream of events from the remote end of the protocol.
9409    ///
9410    /// # Panics
9411    ///
9412    /// Panics if the event stream was already taken.
9413    pub fn take_event_stream(&self) -> PrivilegedPeripheralEventStream {
9414        PrivilegedPeripheralEventStream { event_receiver: self.client.take_event_receiver() }
9415    }
9416
9417    /// Register a listener for incoming channels. The registry will assign a
9418    /// PSM value that is unique for the local device, as well as open a
9419    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
9420    /// event that all PSMs have been assigned, this call will fail with
9421    /// `ZX_ERR_NO_RESOURCES`.
9422    ///
9423    /// Note that the method of service discovery or advertising is defined by
9424    /// the service or protocol, so it is the responsibility of the caller to
9425    /// communicate the assigned PSM to any clients.
9426    pub fn r#listen_l2cap(
9427        &self,
9428        mut payload: ChannelListenerRegistryListenL2capRequest,
9429    ) -> fidl::client::QueryResponseFut<
9430        ChannelListenerRegistryListenL2capResult,
9431        fidl::encoding::DefaultFuchsiaResourceDialect,
9432    > {
9433        PrivilegedPeripheralProxyInterface::r#listen_l2cap(self, payload)
9434    }
9435
9436    /// Start advertising continuously as a LE peripheral. If advertising cannot
9437    /// be initiated then `advertised_peripheral` will be closed and an error
9438    /// will be returned.
9439    ///
9440    /// This method may be called any number of times. To reconfigure an
9441    /// advertisement, first close the original advertisement and then initiate
9442    /// a new advertisement after an empty response is returned.
9443    ///
9444    /// If the client closes its end of the
9445    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9446    /// advertising will be stopped. If the handle is closed before the request
9447    /// is fulfilled, advertising may be briefly enabled before it is
9448    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9449    /// the Peripheral protocol, but this may be changed in the future
9450    /// (https://fxbug.dev/42157682).
9451    ///
9452    /// + request `parameters` Parameters used while configuring the advertising
9453    ///   instance.
9454    /// + request `advertised_peripheral` Protocol that remains valid for the
9455    ///   duration of this advertising session.
9456    /// - response An empty response will be sent when the advertisement is
9457    ///   successfully stopped (due to release of the `advertised_peripheral`
9458    ///   protocol). To prevent overlapping similar advertisements and transient
9459    ///   errors with limited advertising resources, waiting for a response is
9460    ///   recommended before calling `Advertise` again.
9461    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9462    ///   `PeripheralError` will be returned.
9463    pub fn r#advertise(
9464        &self,
9465        mut parameters: &AdvertisingParameters,
9466        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9467    ) -> fidl::client::QueryResponseFut<
9468        PeripheralAdvertiseResult,
9469        fidl::encoding::DefaultFuchsiaResourceDialect,
9470    > {
9471        PrivilegedPeripheralProxyInterface::r#advertise(self, parameters, advertised_peripheral)
9472    }
9473
9474    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9475    /// has successfully initiated. If advertising cannot be initiated, then the response will
9476    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9477    ///
9478    /// This method can get called any number of times and successive calls can be made to
9479    /// reconfigure the advertising parameters. However only the most recent
9480    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9481    ///
9482    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9483    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9484    /// advertisements.
9485    ///
9486    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9487    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9488    /// advertising will be briefly enabled before it is terminated.
9489    ///
9490    /// + request `parameters` Parameters used while configuring the advertising instance.
9491    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9492    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9493    ///         initiated. In this case the `handle` will be closed.
9494    pub fn r#start_advertising(
9495        &self,
9496        mut parameters: &AdvertisingParameters,
9497        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9498    ) -> fidl::client::QueryResponseFut<
9499        PeripheralStartAdvertisingResult,
9500        fidl::encoding::DefaultFuchsiaResourceDialect,
9501    > {
9502        PrivilegedPeripheralProxyInterface::r#start_advertising(self, parameters, handle)
9503    }
9504}
9505
9506impl PrivilegedPeripheralProxyInterface for PrivilegedPeripheralProxy {
9507    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
9508        ChannelListenerRegistryListenL2capResult,
9509        fidl::encoding::DefaultFuchsiaResourceDialect,
9510    >;
9511    fn r#listen_l2cap(
9512        &self,
9513        mut payload: ChannelListenerRegistryListenL2capRequest,
9514    ) -> Self::ListenL2capResponseFut {
9515        fn _decode(
9516            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9517        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
9518            let _response = fidl::client::decode_transaction_body::<
9519                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
9520                fidl::encoding::DefaultFuchsiaResourceDialect,
9521                0x39c6e9001d102338,
9522            >(_buf?)?;
9523            Ok(_response.map(|x| x))
9524        }
9525        self.client.send_query_and_decode::<
9526            ChannelListenerRegistryListenL2capRequest,
9527            ChannelListenerRegistryListenL2capResult,
9528        >(
9529            &mut payload,
9530            0x39c6e9001d102338,
9531            fidl::encoding::DynamicFlags::empty(),
9532            _decode,
9533        )
9534    }
9535
9536    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
9537        PeripheralAdvertiseResult,
9538        fidl::encoding::DefaultFuchsiaResourceDialect,
9539    >;
9540    fn r#advertise(
9541        &self,
9542        mut parameters: &AdvertisingParameters,
9543        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9544    ) -> Self::AdvertiseResponseFut {
9545        fn _decode(
9546            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9547        ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
9548            let _response = fidl::client::decode_transaction_body::<
9549                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9550                fidl::encoding::DefaultFuchsiaResourceDialect,
9551                0x2d9ec9260c32c17f,
9552            >(_buf?)?;
9553            Ok(_response.map(|x| x))
9554        }
9555        self.client.send_query_and_decode::<PeripheralAdvertiseRequest, PeripheralAdvertiseResult>(
9556            (parameters, advertised_peripheral),
9557            0x2d9ec9260c32c17f,
9558            fidl::encoding::DynamicFlags::empty(),
9559            _decode,
9560        )
9561    }
9562
9563    type StartAdvertisingResponseFut = fidl::client::QueryResponseFut<
9564        PeripheralStartAdvertisingResult,
9565        fidl::encoding::DefaultFuchsiaResourceDialect,
9566    >;
9567    fn r#start_advertising(
9568        &self,
9569        mut parameters: &AdvertisingParameters,
9570        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9571    ) -> Self::StartAdvertisingResponseFut {
9572        fn _decode(
9573            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9574        ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
9575            let _response = fidl::client::decode_transaction_body::<
9576                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9577                fidl::encoding::DefaultFuchsiaResourceDialect,
9578                0x5875c1c575f00f7d,
9579            >(_buf?)?;
9580            Ok(_response.map(|x| x))
9581        }
9582        self.client.send_query_and_decode::<
9583            PeripheralStartAdvertisingRequest,
9584            PeripheralStartAdvertisingResult,
9585        >(
9586            (parameters, handle,),
9587            0x5875c1c575f00f7d,
9588            fidl::encoding::DynamicFlags::empty(),
9589            _decode,
9590        )
9591    }
9592}
9593
9594pub struct PrivilegedPeripheralEventStream {
9595    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9596}
9597
9598impl std::marker::Unpin for PrivilegedPeripheralEventStream {}
9599
9600impl futures::stream::FusedStream for PrivilegedPeripheralEventStream {
9601    fn is_terminated(&self) -> bool {
9602        self.event_receiver.is_terminated()
9603    }
9604}
9605
9606impl futures::Stream for PrivilegedPeripheralEventStream {
9607    type Item = Result<PrivilegedPeripheralEvent, fidl::Error>;
9608
9609    fn poll_next(
9610        mut self: std::pin::Pin<&mut Self>,
9611        cx: &mut std::task::Context<'_>,
9612    ) -> std::task::Poll<Option<Self::Item>> {
9613        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9614            &mut self.event_receiver,
9615            cx
9616        )?) {
9617            Some(buf) => std::task::Poll::Ready(Some(PrivilegedPeripheralEvent::decode(buf))),
9618            None => std::task::Poll::Ready(None),
9619        }
9620    }
9621}
9622
9623#[derive(Debug)]
9624pub enum PrivilegedPeripheralEvent {
9625    OnPeerConnected { peer: Peer, connection: fidl::endpoints::ClientEnd<ConnectionMarker> },
9626}
9627
9628impl PrivilegedPeripheralEvent {
9629    #[allow(irrefutable_let_patterns)]
9630    pub fn into_on_peer_connected(
9631        self,
9632    ) -> Option<(Peer, fidl::endpoints::ClientEnd<ConnectionMarker>)> {
9633        if let PrivilegedPeripheralEvent::OnPeerConnected { peer, connection } = self {
9634            Some((peer, connection))
9635        } else {
9636            None
9637        }
9638    }
9639
9640    /// Decodes a message buffer as a [`PrivilegedPeripheralEvent`].
9641    fn decode(
9642        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9643    ) -> Result<PrivilegedPeripheralEvent, fidl::Error> {
9644        let (bytes, _handles) = buf.split_mut();
9645        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9646        debug_assert_eq!(tx_header.tx_id, 0);
9647        match tx_header.ordinal {
9648            0x16135d464299e356 => {
9649                let mut out = fidl::new_empty!(
9650                    PeripheralOnPeerConnectedRequest,
9651                    fidl::encoding::DefaultFuchsiaResourceDialect
9652                );
9653                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralOnPeerConnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
9654                Ok((PrivilegedPeripheralEvent::OnPeerConnected {
9655                    peer: out.peer,
9656                    connection: out.connection,
9657                }))
9658            }
9659            _ => Err(fidl::Error::UnknownOrdinal {
9660                ordinal: tx_header.ordinal,
9661                protocol_name:
9662                    <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9663            }),
9664        }
9665    }
9666}
9667
9668/// A Stream of incoming requests for fuchsia.bluetooth.le/PrivilegedPeripheral.
9669pub struct PrivilegedPeripheralRequestStream {
9670    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9671    is_terminated: bool,
9672}
9673
9674impl std::marker::Unpin for PrivilegedPeripheralRequestStream {}
9675
9676impl futures::stream::FusedStream for PrivilegedPeripheralRequestStream {
9677    fn is_terminated(&self) -> bool {
9678        self.is_terminated
9679    }
9680}
9681
9682impl fidl::endpoints::RequestStream for PrivilegedPeripheralRequestStream {
9683    type Protocol = PrivilegedPeripheralMarker;
9684    type ControlHandle = PrivilegedPeripheralControlHandle;
9685
9686    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9687        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9688    }
9689
9690    fn control_handle(&self) -> Self::ControlHandle {
9691        PrivilegedPeripheralControlHandle { inner: self.inner.clone() }
9692    }
9693
9694    fn into_inner(
9695        self,
9696    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9697    {
9698        (self.inner, self.is_terminated)
9699    }
9700
9701    fn from_inner(
9702        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9703        is_terminated: bool,
9704    ) -> Self {
9705        Self { inner, is_terminated }
9706    }
9707}
9708
9709impl futures::Stream for PrivilegedPeripheralRequestStream {
9710    type Item = Result<PrivilegedPeripheralRequest, fidl::Error>;
9711
9712    fn poll_next(
9713        mut self: std::pin::Pin<&mut Self>,
9714        cx: &mut std::task::Context<'_>,
9715    ) -> std::task::Poll<Option<Self::Item>> {
9716        let this = &mut *self;
9717        if this.inner.check_shutdown(cx) {
9718            this.is_terminated = true;
9719            return std::task::Poll::Ready(None);
9720        }
9721        if this.is_terminated {
9722            panic!("polled PrivilegedPeripheralRequestStream after completion");
9723        }
9724        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9725            |bytes, handles| {
9726                match this.inner.channel().read_etc(cx, bytes, handles) {
9727                    std::task::Poll::Ready(Ok(())) => {}
9728                    std::task::Poll::Pending => return std::task::Poll::Pending,
9729                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9730                        this.is_terminated = true;
9731                        return std::task::Poll::Ready(None);
9732                    }
9733                    std::task::Poll::Ready(Err(e)) => {
9734                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9735                            e.into(),
9736                        ))));
9737                    }
9738                }
9739
9740                // A message has been received from the channel
9741                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9742
9743                std::task::Poll::Ready(Some(match header.ordinal {
9744                0x39c6e9001d102338 => {
9745                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9746                    let mut req = fidl::new_empty!(ChannelListenerRegistryListenL2capRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
9747                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
9748                    let control_handle = PrivilegedPeripheralControlHandle {
9749                        inner: this.inner.clone(),
9750                    };
9751                    Ok(PrivilegedPeripheralRequest::ListenL2cap {payload: req,
9752                        responder: PrivilegedPeripheralListenL2capResponder {
9753                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9754                            tx_id: header.tx_id,
9755                        },
9756                    })
9757                }
9758                0x2d9ec9260c32c17f => {
9759                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9760                    let mut req = fidl::new_empty!(PeripheralAdvertiseRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
9761                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
9762                    let control_handle = PrivilegedPeripheralControlHandle {
9763                        inner: this.inner.clone(),
9764                    };
9765                    Ok(PrivilegedPeripheralRequest::Advertise {parameters: req.parameters,
9766advertised_peripheral: req.advertised_peripheral,
9767
9768                        responder: PrivilegedPeripheralAdvertiseResponder {
9769                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9770                            tx_id: header.tx_id,
9771                        },
9772                    })
9773                }
9774                0x5875c1c575f00f7d => {
9775                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9776                    let mut req = fidl::new_empty!(PeripheralStartAdvertisingRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
9777                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralStartAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
9778                    let control_handle = PrivilegedPeripheralControlHandle {
9779                        inner: this.inner.clone(),
9780                    };
9781                    Ok(PrivilegedPeripheralRequest::StartAdvertising {parameters: req.parameters,
9782handle: req.handle,
9783
9784                        responder: PrivilegedPeripheralStartAdvertisingResponder {
9785                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9786                            tx_id: header.tx_id,
9787                        },
9788                    })
9789                }
9790                _ => Err(fidl::Error::UnknownOrdinal {
9791                    ordinal: header.ordinal,
9792                    protocol_name: <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9793                }),
9794            }))
9795            },
9796        )
9797    }
9798}
9799
9800/// Privileged version of the Peripheral protocol.
9801/// This protocol should only be routed to trusted and system components. Using this protocol will
9802/// enable the client to break normal privacy restrictions which could leak information about the
9803/// location or owner of the device.
9804///
9805/// Use cases which reveal information are noted in documentation and marked as only available
9806/// through PrivilegedPeripheral, and are an error if used through Peripheral.
9807#[derive(Debug)]
9808pub enum PrivilegedPeripheralRequest {
9809    /// Register a listener for incoming channels. The registry will assign a
9810    /// PSM value that is unique for the local device, as well as open a
9811    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
9812    /// event that all PSMs have been assigned, this call will fail with
9813    /// `ZX_ERR_NO_RESOURCES`.
9814    ///
9815    /// Note that the method of service discovery or advertising is defined by
9816    /// the service or protocol, so it is the responsibility of the caller to
9817    /// communicate the assigned PSM to any clients.
9818    ListenL2cap {
9819        payload: ChannelListenerRegistryListenL2capRequest,
9820        responder: PrivilegedPeripheralListenL2capResponder,
9821    },
9822    /// Start advertising continuously as a LE peripheral. If advertising cannot
9823    /// be initiated then `advertised_peripheral` will be closed and an error
9824    /// will be returned.
9825    ///
9826    /// This method may be called any number of times. To reconfigure an
9827    /// advertisement, first close the original advertisement and then initiate
9828    /// a new advertisement after an empty response is returned.
9829    ///
9830    /// If the client closes its end of the
9831    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9832    /// advertising will be stopped. If the handle is closed before the request
9833    /// is fulfilled, advertising may be briefly enabled before it is
9834    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9835    /// the Peripheral protocol, but this may be changed in the future
9836    /// (https://fxbug.dev/42157682).
9837    ///
9838    /// + request `parameters` Parameters used while configuring the advertising
9839    ///   instance.
9840    /// + request `advertised_peripheral` Protocol that remains valid for the
9841    ///   duration of this advertising session.
9842    /// - response An empty response will be sent when the advertisement is
9843    ///   successfully stopped (due to release of the `advertised_peripheral`
9844    ///   protocol). To prevent overlapping similar advertisements and transient
9845    ///   errors with limited advertising resources, waiting for a response is
9846    ///   recommended before calling `Advertise` again.
9847    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9848    ///   `PeripheralError` will be returned.
9849    Advertise {
9850        parameters: AdvertisingParameters,
9851        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9852        responder: PrivilegedPeripheralAdvertiseResponder,
9853    },
9854    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9855    /// has successfully initiated. If advertising cannot be initiated, then the response will
9856    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9857    ///
9858    /// This method can get called any number of times and successive calls can be made to
9859    /// reconfigure the advertising parameters. However only the most recent
9860    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9861    ///
9862    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9863    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9864    /// advertisements.
9865    ///
9866    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9867    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9868    /// advertising will be briefly enabled before it is terminated.
9869    ///
9870    /// + request `parameters` Parameters used while configuring the advertising instance.
9871    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9872    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9873    ///         initiated. In this case the `handle` will be closed.
9874    StartAdvertising {
9875        parameters: AdvertisingParameters,
9876        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9877        responder: PrivilegedPeripheralStartAdvertisingResponder,
9878    },
9879}
9880
9881impl PrivilegedPeripheralRequest {
9882    #[allow(irrefutable_let_patterns)]
9883    pub fn into_listen_l2cap(
9884        self,
9885    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PrivilegedPeripheralListenL2capResponder)>
9886    {
9887        if let PrivilegedPeripheralRequest::ListenL2cap { payload, responder } = self {
9888            Some((payload, responder))
9889        } else {
9890            None
9891        }
9892    }
9893
9894    #[allow(irrefutable_let_patterns)]
9895    pub fn into_advertise(
9896        self,
9897    ) -> Option<(
9898        AdvertisingParameters,
9899        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9900        PrivilegedPeripheralAdvertiseResponder,
9901    )> {
9902        if let PrivilegedPeripheralRequest::Advertise {
9903            parameters,
9904            advertised_peripheral,
9905            responder,
9906        } = self
9907        {
9908            Some((parameters, advertised_peripheral, responder))
9909        } else {
9910            None
9911        }
9912    }
9913
9914    #[allow(irrefutable_let_patterns)]
9915    pub fn into_start_advertising(
9916        self,
9917    ) -> Option<(
9918        AdvertisingParameters,
9919        fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9920        PrivilegedPeripheralStartAdvertisingResponder,
9921    )> {
9922        if let PrivilegedPeripheralRequest::StartAdvertising { parameters, handle, responder } =
9923            self
9924        {
9925            Some((parameters, handle, responder))
9926        } else {
9927            None
9928        }
9929    }
9930
9931    /// Name of the method defined in FIDL
9932    pub fn method_name(&self) -> &'static str {
9933        match *self {
9934            PrivilegedPeripheralRequest::ListenL2cap { .. } => "listen_l2cap",
9935            PrivilegedPeripheralRequest::Advertise { .. } => "advertise",
9936            PrivilegedPeripheralRequest::StartAdvertising { .. } => "start_advertising",
9937        }
9938    }
9939}
9940
9941#[derive(Debug, Clone)]
9942pub struct PrivilegedPeripheralControlHandle {
9943    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9944}
9945
9946impl fidl::endpoints::ControlHandle for PrivilegedPeripheralControlHandle {
9947    fn shutdown(&self) {
9948        self.inner.shutdown()
9949    }
9950
9951    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9952        self.inner.shutdown_with_epitaph(status)
9953    }
9954
9955    fn is_closed(&self) -> bool {
9956        self.inner.channel().is_closed()
9957    }
9958    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
9959        self.inner.channel().on_closed()
9960    }
9961
9962    #[cfg(target_os = "fuchsia")]
9963    fn signal_peer(
9964        &self,
9965        clear_mask: zx::Signals,
9966        set_mask: zx::Signals,
9967    ) -> Result<(), zx_status::Status> {
9968        use fidl::Peered;
9969        self.inner.channel().signal_peer(clear_mask, set_mask)
9970    }
9971}
9972
9973impl PrivilegedPeripheralControlHandle {
9974    pub fn send_on_peer_connected(
9975        &self,
9976        mut peer: &Peer,
9977        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
9978    ) -> Result<(), fidl::Error> {
9979        self.inner.send::<PeripheralOnPeerConnectedRequest>(
9980            (peer, connection),
9981            0,
9982            0x16135d464299e356,
9983            fidl::encoding::DynamicFlags::empty(),
9984        )
9985    }
9986}
9987
9988#[must_use = "FIDL methods require a response to be sent"]
9989#[derive(Debug)]
9990pub struct PrivilegedPeripheralListenL2capResponder {
9991    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
9992    tx_id: u32,
9993}
9994
9995/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
9996/// if the responder is dropped without sending a response, so that the client
9997/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9998impl std::ops::Drop for PrivilegedPeripheralListenL2capResponder {
9999    fn drop(&mut self) {
10000        self.control_handle.shutdown();
10001        // Safety: drops once, never accessed again
10002        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10003    }
10004}
10005
10006impl fidl::endpoints::Responder for PrivilegedPeripheralListenL2capResponder {
10007    type ControlHandle = PrivilegedPeripheralControlHandle;
10008
10009    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
10010        &self.control_handle
10011    }
10012
10013    fn drop_without_shutdown(mut self) {
10014        // Safety: drops once, never accessed again due to mem::forget
10015        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10016        // Prevent Drop from running (which would shut down the channel)
10017        std::mem::forget(self);
10018    }
10019}
10020
10021impl PrivilegedPeripheralListenL2capResponder {
10022    /// Sends a response to the FIDL transaction.
10023    ///
10024    /// Sets the channel to shutdown if an error occurs.
10025    pub fn send(
10026        self,
10027        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
10028    ) -> Result<(), fidl::Error> {
10029        let _result = self.send_raw(result);
10030        if _result.is_err() {
10031            self.control_handle.shutdown();
10032        }
10033        self.drop_without_shutdown();
10034        _result
10035    }
10036
10037    /// Similar to "send" but does not shutdown the channel if an error occurs.
10038    pub fn send_no_shutdown_on_err(
10039        self,
10040        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
10041    ) -> Result<(), fidl::Error> {
10042        let _result = self.send_raw(result);
10043        self.drop_without_shutdown();
10044        _result
10045    }
10046
10047    fn send_raw(
10048        &self,
10049        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
10050    ) -> Result<(), fidl::Error> {
10051        self.control_handle.inner.send::<fidl::encoding::ResultType<
10052            ChannelListenerRegistryListenL2capResponse,
10053            i32,
10054        >>(
10055            result,
10056            self.tx_id,
10057            0x39c6e9001d102338,
10058            fidl::encoding::DynamicFlags::empty(),
10059        )
10060    }
10061}
10062
10063#[must_use = "FIDL methods require a response to be sent"]
10064#[derive(Debug)]
10065pub struct PrivilegedPeripheralAdvertiseResponder {
10066    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
10067    tx_id: u32,
10068}
10069
10070/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
10071/// if the responder is dropped without sending a response, so that the client
10072/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10073impl std::ops::Drop for PrivilegedPeripheralAdvertiseResponder {
10074    fn drop(&mut self) {
10075        self.control_handle.shutdown();
10076        // Safety: drops once, never accessed again
10077        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10078    }
10079}
10080
10081impl fidl::endpoints::Responder for PrivilegedPeripheralAdvertiseResponder {
10082    type ControlHandle = PrivilegedPeripheralControlHandle;
10083
10084    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
10085        &self.control_handle
10086    }
10087
10088    fn drop_without_shutdown(mut self) {
10089        // Safety: drops once, never accessed again due to mem::forget
10090        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10091        // Prevent Drop from running (which would shut down the channel)
10092        std::mem::forget(self);
10093    }
10094}
10095
10096impl PrivilegedPeripheralAdvertiseResponder {
10097    /// Sends a response to the FIDL transaction.
10098    ///
10099    /// Sets the channel to shutdown if an error occurs.
10100    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
10101        let _result = self.send_raw(result);
10102        if _result.is_err() {
10103            self.control_handle.shutdown();
10104        }
10105        self.drop_without_shutdown();
10106        _result
10107    }
10108
10109    /// Similar to "send" but does not shutdown the channel if an error occurs.
10110    pub fn send_no_shutdown_on_err(
10111        self,
10112        mut result: Result<(), PeripheralError>,
10113    ) -> Result<(), fidl::Error> {
10114        let _result = self.send_raw(result);
10115        self.drop_without_shutdown();
10116        _result
10117    }
10118
10119    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
10120        self.control_handle.inner.send::<fidl::encoding::ResultType<
10121            fidl::encoding::EmptyStruct,
10122            PeripheralError,
10123        >>(
10124            result,
10125            self.tx_id,
10126            0x2d9ec9260c32c17f,
10127            fidl::encoding::DynamicFlags::empty(),
10128        )
10129    }
10130}
10131
10132#[must_use = "FIDL methods require a response to be sent"]
10133#[derive(Debug)]
10134pub struct PrivilegedPeripheralStartAdvertisingResponder {
10135    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
10136    tx_id: u32,
10137}
10138
10139/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
10140/// if the responder is dropped without sending a response, so that the client
10141/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10142impl std::ops::Drop for PrivilegedPeripheralStartAdvertisingResponder {
10143    fn drop(&mut self) {
10144        self.control_handle.shutdown();
10145        // Safety: drops once, never accessed again
10146        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10147    }
10148}
10149
10150impl fidl::endpoints::Responder for PrivilegedPeripheralStartAdvertisingResponder {
10151    type ControlHandle = PrivilegedPeripheralControlHandle;
10152
10153    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
10154        &self.control_handle
10155    }
10156
10157    fn drop_without_shutdown(mut self) {
10158        // Safety: drops once, never accessed again due to mem::forget
10159        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10160        // Prevent Drop from running (which would shut down the channel)
10161        std::mem::forget(self);
10162    }
10163}
10164
10165impl PrivilegedPeripheralStartAdvertisingResponder {
10166    /// Sends a response to the FIDL transaction.
10167    ///
10168    /// Sets the channel to shutdown if an error occurs.
10169    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
10170        let _result = self.send_raw(result);
10171        if _result.is_err() {
10172            self.control_handle.shutdown();
10173        }
10174        self.drop_without_shutdown();
10175        _result
10176    }
10177
10178    /// Similar to "send" but does not shutdown the channel if an error occurs.
10179    pub fn send_no_shutdown_on_err(
10180        self,
10181        mut result: Result<(), PeripheralError>,
10182    ) -> Result<(), fidl::Error> {
10183        let _result = self.send_raw(result);
10184        self.drop_without_shutdown();
10185        _result
10186    }
10187
10188    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
10189        self.control_handle.inner.send::<fidl::encoding::ResultType<
10190            fidl::encoding::EmptyStruct,
10191            PeripheralError,
10192        >>(
10193            result,
10194            self.tx_id,
10195            0x5875c1c575f00f7d,
10196            fidl::encoding::DynamicFlags::empty(),
10197        )
10198    }
10199}
10200
10201#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10202pub struct ScanResultWatcherMarker;
10203
10204impl fidl::endpoints::ProtocolMarker for ScanResultWatcherMarker {
10205    type Proxy = ScanResultWatcherProxy;
10206    type RequestStream = ScanResultWatcherRequestStream;
10207    #[cfg(target_os = "fuchsia")]
10208    type SynchronousProxy = ScanResultWatcherSynchronousProxy;
10209
10210    const DEBUG_NAME: &'static str = "(anonymous) ScanResultWatcher";
10211}
10212
10213pub trait ScanResultWatcherProxyInterface: Send + Sync {
10214    type WatchResponseFut: std::future::Future<Output = Result<Vec<Peer>, fidl::Error>> + Send;
10215    fn r#watch(&self) -> Self::WatchResponseFut;
10216}
10217#[derive(Debug)]
10218#[cfg(target_os = "fuchsia")]
10219pub struct ScanResultWatcherSynchronousProxy {
10220    client: fidl::client::sync::Client,
10221}
10222
10223#[cfg(target_os = "fuchsia")]
10224impl fidl::endpoints::SynchronousProxy for ScanResultWatcherSynchronousProxy {
10225    type Proxy = ScanResultWatcherProxy;
10226    type Protocol = ScanResultWatcherMarker;
10227
10228    fn from_channel(inner: fidl::Channel) -> Self {
10229        Self::new(inner)
10230    }
10231
10232    fn into_channel(self) -> fidl::Channel {
10233        self.client.into_channel()
10234    }
10235
10236    fn as_channel(&self) -> &fidl::Channel {
10237        self.client.as_channel()
10238    }
10239}
10240
10241#[cfg(target_os = "fuchsia")]
10242impl ScanResultWatcherSynchronousProxy {
10243    pub fn new(channel: fidl::Channel) -> Self {
10244        let protocol_name =
10245            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10246        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
10247    }
10248
10249    pub fn into_channel(self) -> fidl::Channel {
10250        self.client.into_channel()
10251    }
10252
10253    /// Waits until an event arrives and returns it. It is safe for other
10254    /// threads to make concurrent requests while waiting for an event.
10255    pub fn wait_for_event(
10256        &self,
10257        deadline: zx::MonotonicInstant,
10258    ) -> Result<ScanResultWatcherEvent, fidl::Error> {
10259        ScanResultWatcherEvent::decode(self.client.wait_for_event(deadline)?)
10260    }
10261
10262    /// Returns a list of all LE peers that satisfy the filters indicated in
10263    /// `ScanOptions`. The first response(s) will return matching discovered
10264    /// peers immediately. Subsequent calls receive a response only when peers
10265    /// have been scanned or updated since the last call. If a second call to
10266    /// `Watch` is erronously sent while one call is already pending, the scan
10267    /// will be canceled and the protocol will be closed.
10268    ///
10269    /// - response `updated` Peers that were added or updated since the last
10270    ///   call to Watch().
10271    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<Peer>, fidl::Error> {
10272        let _response = self
10273            .client
10274            .send_query::<fidl::encoding::EmptyPayload, ScanResultWatcherWatchResponse>(
10275                (),
10276                0x713a122e949f301a,
10277                fidl::encoding::DynamicFlags::empty(),
10278                ___deadline,
10279            )?;
10280        Ok(_response.updated)
10281    }
10282}
10283
10284#[cfg(target_os = "fuchsia")]
10285impl From<ScanResultWatcherSynchronousProxy> for zx::NullableHandle {
10286    fn from(value: ScanResultWatcherSynchronousProxy) -> Self {
10287        value.into_channel().into()
10288    }
10289}
10290
10291#[cfg(target_os = "fuchsia")]
10292impl From<fidl::Channel> for ScanResultWatcherSynchronousProxy {
10293    fn from(value: fidl::Channel) -> Self {
10294        Self::new(value)
10295    }
10296}
10297
10298#[cfg(target_os = "fuchsia")]
10299impl fidl::endpoints::FromClient for ScanResultWatcherSynchronousProxy {
10300    type Protocol = ScanResultWatcherMarker;
10301
10302    fn from_client(value: fidl::endpoints::ClientEnd<ScanResultWatcherMarker>) -> Self {
10303        Self::new(value.into_channel())
10304    }
10305}
10306
10307#[derive(Debug, Clone)]
10308pub struct ScanResultWatcherProxy {
10309    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10310}
10311
10312impl fidl::endpoints::Proxy for ScanResultWatcherProxy {
10313    type Protocol = ScanResultWatcherMarker;
10314
10315    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10316        Self::new(inner)
10317    }
10318
10319    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10320        self.client.into_channel().map_err(|client| Self { client })
10321    }
10322
10323    fn as_channel(&self) -> &::fidl::AsyncChannel {
10324        self.client.as_channel()
10325    }
10326}
10327
10328impl ScanResultWatcherProxy {
10329    /// Create a new Proxy for fuchsia.bluetooth.le/ScanResultWatcher.
10330    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10331        let protocol_name =
10332            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10333        Self { client: fidl::client::Client::new(channel, protocol_name) }
10334    }
10335
10336    /// Get a Stream of events from the remote end of the protocol.
10337    ///
10338    /// # Panics
10339    ///
10340    /// Panics if the event stream was already taken.
10341    pub fn take_event_stream(&self) -> ScanResultWatcherEventStream {
10342        ScanResultWatcherEventStream { event_receiver: self.client.take_event_receiver() }
10343    }
10344
10345    /// Returns a list of all LE peers that satisfy the filters indicated in
10346    /// `ScanOptions`. The first response(s) will return matching discovered
10347    /// peers immediately. Subsequent calls receive a response only when peers
10348    /// have been scanned or updated since the last call. If a second call to
10349    /// `Watch` is erronously sent while one call is already pending, the scan
10350    /// will be canceled and the protocol will be closed.
10351    ///
10352    /// - response `updated` Peers that were added or updated since the last
10353    ///   call to Watch().
10354    pub fn r#watch(
10355        &self,
10356    ) -> fidl::client::QueryResponseFut<Vec<Peer>, fidl::encoding::DefaultFuchsiaResourceDialect>
10357    {
10358        ScanResultWatcherProxyInterface::r#watch(self)
10359    }
10360}
10361
10362impl ScanResultWatcherProxyInterface for ScanResultWatcherProxy {
10363    type WatchResponseFut =
10364        fidl::client::QueryResponseFut<Vec<Peer>, fidl::encoding::DefaultFuchsiaResourceDialect>;
10365    fn r#watch(&self) -> Self::WatchResponseFut {
10366        fn _decode(
10367            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10368        ) -> Result<Vec<Peer>, fidl::Error> {
10369            let _response = fidl::client::decode_transaction_body::<
10370                ScanResultWatcherWatchResponse,
10371                fidl::encoding::DefaultFuchsiaResourceDialect,
10372                0x713a122e949f301a,
10373            >(_buf?)?;
10374            Ok(_response.updated)
10375        }
10376        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Peer>>(
10377            (),
10378            0x713a122e949f301a,
10379            fidl::encoding::DynamicFlags::empty(),
10380            _decode,
10381        )
10382    }
10383}
10384
10385pub struct ScanResultWatcherEventStream {
10386    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
10387}
10388
10389impl std::marker::Unpin for ScanResultWatcherEventStream {}
10390
10391impl futures::stream::FusedStream for ScanResultWatcherEventStream {
10392    fn is_terminated(&self) -> bool {
10393        self.event_receiver.is_terminated()
10394    }
10395}
10396
10397impl futures::Stream for ScanResultWatcherEventStream {
10398    type Item = Result<ScanResultWatcherEvent, fidl::Error>;
10399
10400    fn poll_next(
10401        mut self: std::pin::Pin<&mut Self>,
10402        cx: &mut std::task::Context<'_>,
10403    ) -> std::task::Poll<Option<Self::Item>> {
10404        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10405            &mut self.event_receiver,
10406            cx
10407        )?) {
10408            Some(buf) => std::task::Poll::Ready(Some(ScanResultWatcherEvent::decode(buf))),
10409            None => std::task::Poll::Ready(None),
10410        }
10411    }
10412}
10413
10414#[derive(Debug)]
10415pub enum ScanResultWatcherEvent {}
10416
10417impl ScanResultWatcherEvent {
10418    /// Decodes a message buffer as a [`ScanResultWatcherEvent`].
10419    fn decode(
10420        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10421    ) -> Result<ScanResultWatcherEvent, fidl::Error> {
10422        let (bytes, _handles) = buf.split_mut();
10423        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10424        debug_assert_eq!(tx_header.tx_id, 0);
10425        match tx_header.ordinal {
10426            _ => Err(fidl::Error::UnknownOrdinal {
10427                ordinal: tx_header.ordinal,
10428                protocol_name:
10429                    <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
10430            }),
10431        }
10432    }
10433}
10434
10435/// A Stream of incoming requests for fuchsia.bluetooth.le/ScanResultWatcher.
10436pub struct ScanResultWatcherRequestStream {
10437    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10438    is_terminated: bool,
10439}
10440
10441impl std::marker::Unpin for ScanResultWatcherRequestStream {}
10442
10443impl futures::stream::FusedStream for ScanResultWatcherRequestStream {
10444    fn is_terminated(&self) -> bool {
10445        self.is_terminated
10446    }
10447}
10448
10449impl fidl::endpoints::RequestStream for ScanResultWatcherRequestStream {
10450    type Protocol = ScanResultWatcherMarker;
10451    type ControlHandle = ScanResultWatcherControlHandle;
10452
10453    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
10454        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10455    }
10456
10457    fn control_handle(&self) -> Self::ControlHandle {
10458        ScanResultWatcherControlHandle { inner: self.inner.clone() }
10459    }
10460
10461    fn into_inner(
10462        self,
10463    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
10464    {
10465        (self.inner, self.is_terminated)
10466    }
10467
10468    fn from_inner(
10469        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10470        is_terminated: bool,
10471    ) -> Self {
10472        Self { inner, is_terminated }
10473    }
10474}
10475
10476impl futures::Stream for ScanResultWatcherRequestStream {
10477    type Item = Result<ScanResultWatcherRequest, fidl::Error>;
10478
10479    fn poll_next(
10480        mut self: std::pin::Pin<&mut Self>,
10481        cx: &mut std::task::Context<'_>,
10482    ) -> std::task::Poll<Option<Self::Item>> {
10483        let this = &mut *self;
10484        if this.inner.check_shutdown(cx) {
10485            this.is_terminated = true;
10486            return std::task::Poll::Ready(None);
10487        }
10488        if this.is_terminated {
10489            panic!("polled ScanResultWatcherRequestStream after completion");
10490        }
10491        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
10492            |bytes, handles| {
10493                match this.inner.channel().read_etc(cx, bytes, handles) {
10494                    std::task::Poll::Ready(Ok(())) => {}
10495                    std::task::Poll::Pending => return std::task::Poll::Pending,
10496                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
10497                        this.is_terminated = true;
10498                        return std::task::Poll::Ready(None);
10499                    }
10500                    std::task::Poll::Ready(Err(e)) => {
10501                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10502                            e.into(),
10503                        ))));
10504                    }
10505                }
10506
10507                // A message has been received from the channel
10508                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10509
10510                std::task::Poll::Ready(Some(match header.ordinal {
10511                    0x713a122e949f301a => {
10512                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10513                        let mut req = fidl::new_empty!(
10514                            fidl::encoding::EmptyPayload,
10515                            fidl::encoding::DefaultFuchsiaResourceDialect
10516                        );
10517                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10518                        let control_handle =
10519                            ScanResultWatcherControlHandle { inner: this.inner.clone() };
10520                        Ok(ScanResultWatcherRequest::Watch {
10521                            responder: ScanResultWatcherWatchResponder {
10522                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10523                                tx_id: header.tx_id,
10524                            },
10525                        })
10526                    }
10527                    _ => Err(fidl::Error::UnknownOrdinal {
10528                        ordinal: header.ordinal,
10529                        protocol_name:
10530                            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
10531                    }),
10532                }))
10533            },
10534        )
10535    }
10536}
10537
10538/// Represents an active scan procedure. This protocol remains valid for the
10539/// duration of a scan and can be used to obtain scan results. The client can
10540/// close the protocol to stop scanning. If a scan is stopped by the system, the
10541/// protocol will be closed with the epitaph `CANCELED` to communicate this to
10542/// the client.
10543#[derive(Debug)]
10544pub enum ScanResultWatcherRequest {
10545    /// Returns a list of all LE peers that satisfy the filters indicated in
10546    /// `ScanOptions`. The first response(s) will return matching discovered
10547    /// peers immediately. Subsequent calls receive a response only when peers
10548    /// have been scanned or updated since the last call. If a second call to
10549    /// `Watch` is erronously sent while one call is already pending, the scan
10550    /// will be canceled and the protocol will be closed.
10551    ///
10552    /// - response `updated` Peers that were added or updated since the last
10553    ///   call to Watch().
10554    Watch { responder: ScanResultWatcherWatchResponder },
10555}
10556
10557impl ScanResultWatcherRequest {
10558    #[allow(irrefutable_let_patterns)]
10559    pub fn into_watch(self) -> Option<(ScanResultWatcherWatchResponder)> {
10560        if let ScanResultWatcherRequest::Watch { responder } = self {
10561            Some((responder))
10562        } else {
10563            None
10564        }
10565    }
10566
10567    /// Name of the method defined in FIDL
10568    pub fn method_name(&self) -> &'static str {
10569        match *self {
10570            ScanResultWatcherRequest::Watch { .. } => "watch",
10571        }
10572    }
10573}
10574
10575#[derive(Debug, Clone)]
10576pub struct ScanResultWatcherControlHandle {
10577    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10578}
10579
10580impl fidl::endpoints::ControlHandle for ScanResultWatcherControlHandle {
10581    fn shutdown(&self) {
10582        self.inner.shutdown()
10583    }
10584
10585    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10586        self.inner.shutdown_with_epitaph(status)
10587    }
10588
10589    fn is_closed(&self) -> bool {
10590        self.inner.channel().is_closed()
10591    }
10592    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10593        self.inner.channel().on_closed()
10594    }
10595
10596    #[cfg(target_os = "fuchsia")]
10597    fn signal_peer(
10598        &self,
10599        clear_mask: zx::Signals,
10600        set_mask: zx::Signals,
10601    ) -> Result<(), zx_status::Status> {
10602        use fidl::Peered;
10603        self.inner.channel().signal_peer(clear_mask, set_mask)
10604    }
10605}
10606
10607impl ScanResultWatcherControlHandle {}
10608
10609#[must_use = "FIDL methods require a response to be sent"]
10610#[derive(Debug)]
10611pub struct ScanResultWatcherWatchResponder {
10612    control_handle: std::mem::ManuallyDrop<ScanResultWatcherControlHandle>,
10613    tx_id: u32,
10614}
10615
10616/// Set the the channel to be shutdown (see [`ScanResultWatcherControlHandle::shutdown`])
10617/// if the responder is dropped without sending a response, so that the client
10618/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10619impl std::ops::Drop for ScanResultWatcherWatchResponder {
10620    fn drop(&mut self) {
10621        self.control_handle.shutdown();
10622        // Safety: drops once, never accessed again
10623        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10624    }
10625}
10626
10627impl fidl::endpoints::Responder for ScanResultWatcherWatchResponder {
10628    type ControlHandle = ScanResultWatcherControlHandle;
10629
10630    fn control_handle(&self) -> &ScanResultWatcherControlHandle {
10631        &self.control_handle
10632    }
10633
10634    fn drop_without_shutdown(mut self) {
10635        // Safety: drops once, never accessed again due to mem::forget
10636        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10637        // Prevent Drop from running (which would shut down the channel)
10638        std::mem::forget(self);
10639    }
10640}
10641
10642impl ScanResultWatcherWatchResponder {
10643    /// Sends a response to the FIDL transaction.
10644    ///
10645    /// Sets the channel to shutdown if an error occurs.
10646    pub fn send(self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
10647        let _result = self.send_raw(updated);
10648        if _result.is_err() {
10649            self.control_handle.shutdown();
10650        }
10651        self.drop_without_shutdown();
10652        _result
10653    }
10654
10655    /// Similar to "send" but does not shutdown the channel if an error occurs.
10656    pub fn send_no_shutdown_on_err(self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
10657        let _result = self.send_raw(updated);
10658        self.drop_without_shutdown();
10659        _result
10660    }
10661
10662    fn send_raw(&self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
10663        self.control_handle.inner.send::<ScanResultWatcherWatchResponse>(
10664            (updated,),
10665            self.tx_id,
10666            0x713a122e949f301a,
10667            fidl::encoding::DynamicFlags::empty(),
10668        )
10669    }
10670}
10671
10672mod internal {
10673    use super::*;
10674
10675    impl fidl::encoding::ResourceTypeMarker for AdvertisedPeripheralOnConnectedRequest {
10676        type Borrowed<'a> = &'a mut Self;
10677        fn take_or_borrow<'a>(
10678            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10679        ) -> Self::Borrowed<'a> {
10680            value
10681        }
10682    }
10683
10684    unsafe impl fidl::encoding::TypeMarker for AdvertisedPeripheralOnConnectedRequest {
10685        type Owned = Self;
10686
10687        #[inline(always)]
10688        fn inline_align(_context: fidl::encoding::Context) -> usize {
10689            8
10690        }
10691
10692        #[inline(always)]
10693        fn inline_size(_context: fidl::encoding::Context) -> usize {
10694            24
10695        }
10696    }
10697
10698    unsafe impl
10699        fidl::encoding::Encode<
10700            AdvertisedPeripheralOnConnectedRequest,
10701            fidl::encoding::DefaultFuchsiaResourceDialect,
10702        > for &mut AdvertisedPeripheralOnConnectedRequest
10703    {
10704        #[inline]
10705        unsafe fn encode(
10706            self,
10707            encoder: &mut fidl::encoding::Encoder<
10708                '_,
10709                fidl::encoding::DefaultFuchsiaResourceDialect,
10710            >,
10711            offset: usize,
10712            _depth: fidl::encoding::Depth,
10713        ) -> fidl::Result<()> {
10714            encoder.debug_check_bounds::<AdvertisedPeripheralOnConnectedRequest>(offset);
10715            // Delegate to tuple encoding.
10716            fidl::encoding::Encode::<AdvertisedPeripheralOnConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10717                (
10718                    <Peer as fidl::encoding::ValueTypeMarker>::borrow(&self.peer),
10719                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.connection),
10720                ),
10721                encoder, offset, _depth
10722            )
10723        }
10724    }
10725    unsafe impl<
10726        T0: fidl::encoding::Encode<Peer, fidl::encoding::DefaultFuchsiaResourceDialect>,
10727        T1: fidl::encoding::Encode<
10728                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
10729                fidl::encoding::DefaultFuchsiaResourceDialect,
10730            >,
10731    >
10732        fidl::encoding::Encode<
10733            AdvertisedPeripheralOnConnectedRequest,
10734            fidl::encoding::DefaultFuchsiaResourceDialect,
10735        > for (T0, T1)
10736    {
10737        #[inline]
10738        unsafe fn encode(
10739            self,
10740            encoder: &mut fidl::encoding::Encoder<
10741                '_,
10742                fidl::encoding::DefaultFuchsiaResourceDialect,
10743            >,
10744            offset: usize,
10745            depth: fidl::encoding::Depth,
10746        ) -> fidl::Result<()> {
10747            encoder.debug_check_bounds::<AdvertisedPeripheralOnConnectedRequest>(offset);
10748            // Zero out padding regions. There's no need to apply masks
10749            // because the unmasked parts will be overwritten by fields.
10750            unsafe {
10751                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
10752                (ptr as *mut u64).write_unaligned(0);
10753            }
10754            // Write the fields.
10755            self.0.encode(encoder, offset + 0, depth)?;
10756            self.1.encode(encoder, offset + 16, depth)?;
10757            Ok(())
10758        }
10759    }
10760
10761    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10762        for AdvertisedPeripheralOnConnectedRequest
10763    {
10764        #[inline(always)]
10765        fn new_empty() -> Self {
10766            Self {
10767                peer: fidl::new_empty!(Peer, fidl::encoding::DefaultFuchsiaResourceDialect),
10768                connection: fidl::new_empty!(
10769                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
10770                    fidl::encoding::DefaultFuchsiaResourceDialect
10771                ),
10772            }
10773        }
10774
10775        #[inline]
10776        unsafe fn decode(
10777            &mut self,
10778            decoder: &mut fidl::encoding::Decoder<
10779                '_,
10780                fidl::encoding::DefaultFuchsiaResourceDialect,
10781            >,
10782            offset: usize,
10783            _depth: fidl::encoding::Depth,
10784        ) -> fidl::Result<()> {
10785            decoder.debug_check_bounds::<Self>(offset);
10786            // Verify that padding bytes are zero.
10787            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
10788            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10789            let mask = 0xffffffff00000000u64;
10790            let maskedval = padval & mask;
10791            if maskedval != 0 {
10792                return Err(fidl::Error::NonZeroPadding {
10793                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
10794                });
10795            }
10796            fidl::decode!(
10797                Peer,
10798                fidl::encoding::DefaultFuchsiaResourceDialect,
10799                &mut self.peer,
10800                decoder,
10801                offset + 0,
10802                _depth
10803            )?;
10804            fidl::decode!(
10805                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
10806                fidl::encoding::DefaultFuchsiaResourceDialect,
10807                &mut self.connection,
10808                decoder,
10809                offset + 16,
10810                _depth
10811            )?;
10812            Ok(())
10813        }
10814    }
10815
10816    impl fidl::encoding::ResourceTypeMarker for CentralConnectPeripheralRequest {
10817        type Borrowed<'a> = &'a mut Self;
10818        fn take_or_borrow<'a>(
10819            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10820        ) -> Self::Borrowed<'a> {
10821            value
10822        }
10823    }
10824
10825    unsafe impl fidl::encoding::TypeMarker for CentralConnectPeripheralRequest {
10826        type Owned = Self;
10827
10828        #[inline(always)]
10829        fn inline_align(_context: fidl::encoding::Context) -> usize {
10830            8
10831        }
10832
10833        #[inline(always)]
10834        fn inline_size(_context: fidl::encoding::Context) -> usize {
10835            40
10836        }
10837    }
10838
10839    unsafe impl
10840        fidl::encoding::Encode<
10841            CentralConnectPeripheralRequest,
10842            fidl::encoding::DefaultFuchsiaResourceDialect,
10843        > for &mut CentralConnectPeripheralRequest
10844    {
10845        #[inline]
10846        unsafe fn encode(
10847            self,
10848            encoder: &mut fidl::encoding::Encoder<
10849                '_,
10850                fidl::encoding::DefaultFuchsiaResourceDialect,
10851            >,
10852            offset: usize,
10853            _depth: fidl::encoding::Depth,
10854        ) -> fidl::Result<()> {
10855            encoder.debug_check_bounds::<CentralConnectPeripheralRequest>(offset);
10856            // Delegate to tuple encoding.
10857            fidl::encoding::Encode::<
10858                CentralConnectPeripheralRequest,
10859                fidl::encoding::DefaultFuchsiaResourceDialect,
10860            >::encode(
10861                (
10862                    <fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(
10863                        &self.identifier,
10864                    ),
10865                    <ConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
10866                    <fidl::encoding::Endpoint<
10867                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10868                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10869                        &mut self.gatt_client
10870                    ),
10871                ),
10872                encoder,
10873                offset,
10874                _depth,
10875            )
10876        }
10877    }
10878    unsafe impl<
10879        T0: fidl::encoding::Encode<
10880                fidl::encoding::BoundedString<16>,
10881                fidl::encoding::DefaultFuchsiaResourceDialect,
10882            >,
10883        T1: fidl::encoding::Encode<ConnectionOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
10884        T2: fidl::encoding::Encode<
10885                fidl::encoding::Endpoint<
10886                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10887                >,
10888                fidl::encoding::DefaultFuchsiaResourceDialect,
10889            >,
10890    >
10891        fidl::encoding::Encode<
10892            CentralConnectPeripheralRequest,
10893            fidl::encoding::DefaultFuchsiaResourceDialect,
10894        > for (T0, T1, T2)
10895    {
10896        #[inline]
10897        unsafe fn encode(
10898            self,
10899            encoder: &mut fidl::encoding::Encoder<
10900                '_,
10901                fidl::encoding::DefaultFuchsiaResourceDialect,
10902            >,
10903            offset: usize,
10904            depth: fidl::encoding::Depth,
10905        ) -> fidl::Result<()> {
10906            encoder.debug_check_bounds::<CentralConnectPeripheralRequest>(offset);
10907            // Zero out padding regions. There's no need to apply masks
10908            // because the unmasked parts will be overwritten by fields.
10909            unsafe {
10910                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
10911                (ptr as *mut u64).write_unaligned(0);
10912            }
10913            // Write the fields.
10914            self.0.encode(encoder, offset + 0, depth)?;
10915            self.1.encode(encoder, offset + 16, depth)?;
10916            self.2.encode(encoder, offset + 32, depth)?;
10917            Ok(())
10918        }
10919    }
10920
10921    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10922        for CentralConnectPeripheralRequest
10923    {
10924        #[inline(always)]
10925        fn new_empty() -> Self {
10926            Self {
10927                identifier: fidl::new_empty!(
10928                    fidl::encoding::BoundedString<16>,
10929                    fidl::encoding::DefaultFuchsiaResourceDialect
10930                ),
10931                options: fidl::new_empty!(
10932                    ConnectionOptions,
10933                    fidl::encoding::DefaultFuchsiaResourceDialect
10934                ),
10935                gatt_client: fidl::new_empty!(
10936                    fidl::encoding::Endpoint<
10937                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10938                    >,
10939                    fidl::encoding::DefaultFuchsiaResourceDialect
10940                ),
10941            }
10942        }
10943
10944        #[inline]
10945        unsafe fn decode(
10946            &mut self,
10947            decoder: &mut fidl::encoding::Decoder<
10948                '_,
10949                fidl::encoding::DefaultFuchsiaResourceDialect,
10950            >,
10951            offset: usize,
10952            _depth: fidl::encoding::Depth,
10953        ) -> fidl::Result<()> {
10954            decoder.debug_check_bounds::<Self>(offset);
10955            // Verify that padding bytes are zero.
10956            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
10957            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10958            let mask = 0xffffffff00000000u64;
10959            let maskedval = padval & mask;
10960            if maskedval != 0 {
10961                return Err(fidl::Error::NonZeroPadding {
10962                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
10963                });
10964            }
10965            fidl::decode!(
10966                fidl::encoding::BoundedString<16>,
10967                fidl::encoding::DefaultFuchsiaResourceDialect,
10968                &mut self.identifier,
10969                decoder,
10970                offset + 0,
10971                _depth
10972            )?;
10973            fidl::decode!(
10974                ConnectionOptions,
10975                fidl::encoding::DefaultFuchsiaResourceDialect,
10976                &mut self.options,
10977                decoder,
10978                offset + 16,
10979                _depth
10980            )?;
10981            fidl::decode!(
10982                fidl::encoding::Endpoint<
10983                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10984                >,
10985                fidl::encoding::DefaultFuchsiaResourceDialect,
10986                &mut self.gatt_client,
10987                decoder,
10988                offset + 32,
10989                _depth
10990            )?;
10991            Ok(())
10992        }
10993    }
10994
10995    impl fidl::encoding::ResourceTypeMarker for CentralConnectRequest {
10996        type Borrowed<'a> = &'a mut Self;
10997        fn take_or_borrow<'a>(
10998            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10999        ) -> Self::Borrowed<'a> {
11000            value
11001        }
11002    }
11003
11004    unsafe impl fidl::encoding::TypeMarker for CentralConnectRequest {
11005        type Owned = Self;
11006
11007        #[inline(always)]
11008        fn inline_align(_context: fidl::encoding::Context) -> usize {
11009            8
11010        }
11011
11012        #[inline(always)]
11013        fn inline_size(_context: fidl::encoding::Context) -> usize {
11014            32
11015        }
11016    }
11017
11018    unsafe impl
11019        fidl::encoding::Encode<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
11020        for &mut CentralConnectRequest
11021    {
11022        #[inline]
11023        unsafe fn encode(
11024            self,
11025            encoder: &mut fidl::encoding::Encoder<
11026                '_,
11027                fidl::encoding::DefaultFuchsiaResourceDialect,
11028            >,
11029            offset: usize,
11030            _depth: fidl::encoding::Depth,
11031        ) -> fidl::Result<()> {
11032            encoder.debug_check_bounds::<CentralConnectRequest>(offset);
11033            // Delegate to tuple encoding.
11034            fidl::encoding::Encode::<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
11035                (
11036                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
11037                    <ConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
11038                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
11039                ),
11040                encoder, offset, _depth
11041            )
11042        }
11043    }
11044    unsafe impl<
11045        T0: fidl::encoding::Encode<
11046                fidl_fuchsia_bluetooth::PeerId,
11047                fidl::encoding::DefaultFuchsiaResourceDialect,
11048            >,
11049        T1: fidl::encoding::Encode<ConnectionOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
11050        T2: fidl::encoding::Encode<
11051                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
11052                fidl::encoding::DefaultFuchsiaResourceDialect,
11053            >,
11054    >
11055        fidl::encoding::Encode<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
11056        for (T0, T1, T2)
11057    {
11058        #[inline]
11059        unsafe fn encode(
11060            self,
11061            encoder: &mut fidl::encoding::Encoder<
11062                '_,
11063                fidl::encoding::DefaultFuchsiaResourceDialect,
11064            >,
11065            offset: usize,
11066            depth: fidl::encoding::Depth,
11067        ) -> fidl::Result<()> {
11068            encoder.debug_check_bounds::<CentralConnectRequest>(offset);
11069            // Zero out padding regions. There's no need to apply masks
11070            // because the unmasked parts will be overwritten by fields.
11071            unsafe {
11072                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
11073                (ptr as *mut u64).write_unaligned(0);
11074            }
11075            // Write the fields.
11076            self.0.encode(encoder, offset + 0, depth)?;
11077            self.1.encode(encoder, offset + 8, depth)?;
11078            self.2.encode(encoder, offset + 24, depth)?;
11079            Ok(())
11080        }
11081    }
11082
11083    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11084        for CentralConnectRequest
11085    {
11086        #[inline(always)]
11087        fn new_empty() -> Self {
11088            Self {
11089                id: fidl::new_empty!(
11090                    fidl_fuchsia_bluetooth::PeerId,
11091                    fidl::encoding::DefaultFuchsiaResourceDialect
11092                ),
11093                options: fidl::new_empty!(
11094                    ConnectionOptions,
11095                    fidl::encoding::DefaultFuchsiaResourceDialect
11096                ),
11097                handle: fidl::new_empty!(
11098                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
11099                    fidl::encoding::DefaultFuchsiaResourceDialect
11100                ),
11101            }
11102        }
11103
11104        #[inline]
11105        unsafe fn decode(
11106            &mut self,
11107            decoder: &mut fidl::encoding::Decoder<
11108                '_,
11109                fidl::encoding::DefaultFuchsiaResourceDialect,
11110            >,
11111            offset: usize,
11112            _depth: fidl::encoding::Depth,
11113        ) -> fidl::Result<()> {
11114            decoder.debug_check_bounds::<Self>(offset);
11115            // Verify that padding bytes are zero.
11116            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
11117            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11118            let mask = 0xffffffff00000000u64;
11119            let maskedval = padval & mask;
11120            if maskedval != 0 {
11121                return Err(fidl::Error::NonZeroPadding {
11122                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
11123                });
11124            }
11125            fidl::decode!(
11126                fidl_fuchsia_bluetooth::PeerId,
11127                fidl::encoding::DefaultFuchsiaResourceDialect,
11128                &mut self.id,
11129                decoder,
11130                offset + 0,
11131                _depth
11132            )?;
11133            fidl::decode!(
11134                ConnectionOptions,
11135                fidl::encoding::DefaultFuchsiaResourceDialect,
11136                &mut self.options,
11137                decoder,
11138                offset + 8,
11139                _depth
11140            )?;
11141            fidl::decode!(
11142                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
11143                fidl::encoding::DefaultFuchsiaResourceDialect,
11144                &mut self.handle,
11145                decoder,
11146                offset + 24,
11147                _depth
11148            )?;
11149            Ok(())
11150        }
11151    }
11152
11153    impl fidl::encoding::ResourceTypeMarker for CentralScanRequest {
11154        type Borrowed<'a> = &'a mut Self;
11155        fn take_or_borrow<'a>(
11156            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11157        ) -> Self::Borrowed<'a> {
11158            value
11159        }
11160    }
11161
11162    unsafe impl fidl::encoding::TypeMarker for CentralScanRequest {
11163        type Owned = Self;
11164
11165        #[inline(always)]
11166        fn inline_align(_context: fidl::encoding::Context) -> usize {
11167            8
11168        }
11169
11170        #[inline(always)]
11171        fn inline_size(_context: fidl::encoding::Context) -> usize {
11172            24
11173        }
11174    }
11175
11176    unsafe impl
11177        fidl::encoding::Encode<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
11178        for &mut CentralScanRequest
11179    {
11180        #[inline]
11181        unsafe fn encode(
11182            self,
11183            encoder: &mut fidl::encoding::Encoder<
11184                '_,
11185                fidl::encoding::DefaultFuchsiaResourceDialect,
11186            >,
11187            offset: usize,
11188            _depth: fidl::encoding::Depth,
11189        ) -> fidl::Result<()> {
11190            encoder.debug_check_bounds::<CentralScanRequest>(offset);
11191            // Delegate to tuple encoding.
11192            fidl::encoding::Encode::<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
11193                (
11194                    <ScanOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
11195                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.result_watcher),
11196                ),
11197                encoder, offset, _depth
11198            )
11199        }
11200    }
11201    unsafe impl<
11202        T0: fidl::encoding::Encode<ScanOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
11203        T1: fidl::encoding::Encode<
11204                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
11205                fidl::encoding::DefaultFuchsiaResourceDialect,
11206            >,
11207    > fidl::encoding::Encode<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
11208        for (T0, T1)
11209    {
11210        #[inline]
11211        unsafe fn encode(
11212            self,
11213            encoder: &mut fidl::encoding::Encoder<
11214                '_,
11215                fidl::encoding::DefaultFuchsiaResourceDialect,
11216            >,
11217            offset: usize,
11218            depth: fidl::encoding::Depth,
11219        ) -> fidl::Result<()> {
11220            encoder.debug_check_bounds::<CentralScanRequest>(offset);
11221            // Zero out padding regions. There's no need to apply masks
11222            // because the unmasked parts will be overwritten by fields.
11223            unsafe {
11224                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
11225                (ptr as *mut u64).write_unaligned(0);
11226            }
11227            // Write the fields.
11228            self.0.encode(encoder, offset + 0, depth)?;
11229            self.1.encode(encoder, offset + 16, depth)?;
11230            Ok(())
11231        }
11232    }
11233
11234    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11235        for CentralScanRequest
11236    {
11237        #[inline(always)]
11238        fn new_empty() -> Self {
11239            Self {
11240                options: fidl::new_empty!(
11241                    ScanOptions,
11242                    fidl::encoding::DefaultFuchsiaResourceDialect
11243                ),
11244                result_watcher: fidl::new_empty!(
11245                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
11246                    fidl::encoding::DefaultFuchsiaResourceDialect
11247                ),
11248            }
11249        }
11250
11251        #[inline]
11252        unsafe fn decode(
11253            &mut self,
11254            decoder: &mut fidl::encoding::Decoder<
11255                '_,
11256                fidl::encoding::DefaultFuchsiaResourceDialect,
11257            >,
11258            offset: usize,
11259            _depth: fidl::encoding::Depth,
11260        ) -> fidl::Result<()> {
11261            decoder.debug_check_bounds::<Self>(offset);
11262            // Verify that padding bytes are zero.
11263            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
11264            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11265            let mask = 0xffffffff00000000u64;
11266            let maskedval = padval & mask;
11267            if maskedval != 0 {
11268                return Err(fidl::Error::NonZeroPadding {
11269                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
11270                });
11271            }
11272            fidl::decode!(
11273                ScanOptions,
11274                fidl::encoding::DefaultFuchsiaResourceDialect,
11275                &mut self.options,
11276                decoder,
11277                offset + 0,
11278                _depth
11279            )?;
11280            fidl::decode!(
11281                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
11282                fidl::encoding::DefaultFuchsiaResourceDialect,
11283                &mut self.result_watcher,
11284                decoder,
11285                offset + 16,
11286                _depth
11287            )?;
11288            Ok(())
11289        }
11290    }
11291
11292    impl fidl::encoding::ResourceTypeMarker for ChannelListenerAcceptRequest {
11293        type Borrowed<'a> = &'a mut Self;
11294        fn take_or_borrow<'a>(
11295            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11296        ) -> Self::Borrowed<'a> {
11297            value
11298        }
11299    }
11300
11301    unsafe impl fidl::encoding::TypeMarker for ChannelListenerAcceptRequest {
11302        type Owned = Self;
11303
11304        #[inline(always)]
11305        fn inline_align(_context: fidl::encoding::Context) -> usize {
11306            4
11307        }
11308
11309        #[inline(always)]
11310        fn inline_size(_context: fidl::encoding::Context) -> usize {
11311            4
11312        }
11313    }
11314
11315    unsafe impl
11316        fidl::encoding::Encode<
11317            ChannelListenerAcceptRequest,
11318            fidl::encoding::DefaultFuchsiaResourceDialect,
11319        > for &mut ChannelListenerAcceptRequest
11320    {
11321        #[inline]
11322        unsafe fn encode(
11323            self,
11324            encoder: &mut fidl::encoding::Encoder<
11325                '_,
11326                fidl::encoding::DefaultFuchsiaResourceDialect,
11327            >,
11328            offset: usize,
11329            _depth: fidl::encoding::Depth,
11330        ) -> fidl::Result<()> {
11331            encoder.debug_check_bounds::<ChannelListenerAcceptRequest>(offset);
11332            // Delegate to tuple encoding.
11333            fidl::encoding::Encode::<
11334                ChannelListenerAcceptRequest,
11335                fidl::encoding::DefaultFuchsiaResourceDialect,
11336            >::encode(
11337                (<fidl::encoding::Endpoint<
11338                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
11339                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11340                    &mut self.channel
11341                ),),
11342                encoder,
11343                offset,
11344                _depth,
11345            )
11346        }
11347    }
11348    unsafe impl<
11349        T0: fidl::encoding::Encode<
11350                fidl::encoding::Endpoint<
11351                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
11352                >,
11353                fidl::encoding::DefaultFuchsiaResourceDialect,
11354            >,
11355    >
11356        fidl::encoding::Encode<
11357            ChannelListenerAcceptRequest,
11358            fidl::encoding::DefaultFuchsiaResourceDialect,
11359        > for (T0,)
11360    {
11361        #[inline]
11362        unsafe fn encode(
11363            self,
11364            encoder: &mut fidl::encoding::Encoder<
11365                '_,
11366                fidl::encoding::DefaultFuchsiaResourceDialect,
11367            >,
11368            offset: usize,
11369            depth: fidl::encoding::Depth,
11370        ) -> fidl::Result<()> {
11371            encoder.debug_check_bounds::<ChannelListenerAcceptRequest>(offset);
11372            // Zero out padding regions. There's no need to apply masks
11373            // because the unmasked parts will be overwritten by fields.
11374            // Write the fields.
11375            self.0.encode(encoder, offset + 0, depth)?;
11376            Ok(())
11377        }
11378    }
11379
11380    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11381        for ChannelListenerAcceptRequest
11382    {
11383        #[inline(always)]
11384        fn new_empty() -> Self {
11385            Self {
11386                channel: fidl::new_empty!(
11387                    fidl::encoding::Endpoint<
11388                        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
11389                    >,
11390                    fidl::encoding::DefaultFuchsiaResourceDialect
11391                ),
11392            }
11393        }
11394
11395        #[inline]
11396        unsafe fn decode(
11397            &mut self,
11398            decoder: &mut fidl::encoding::Decoder<
11399                '_,
11400                fidl::encoding::DefaultFuchsiaResourceDialect,
11401            >,
11402            offset: usize,
11403            _depth: fidl::encoding::Depth,
11404        ) -> fidl::Result<()> {
11405            decoder.debug_check_bounds::<Self>(offset);
11406            // Verify that padding bytes are zero.
11407            fidl::decode!(
11408                fidl::encoding::Endpoint<
11409                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
11410                >,
11411                fidl::encoding::DefaultFuchsiaResourceDialect,
11412                &mut self.channel,
11413                decoder,
11414                offset + 0,
11415                _depth
11416            )?;
11417            Ok(())
11418        }
11419    }
11420
11421    impl fidl::encoding::ResourceTypeMarker for ConnectionRequestGattClientRequest {
11422        type Borrowed<'a> = &'a mut Self;
11423        fn take_or_borrow<'a>(
11424            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11425        ) -> Self::Borrowed<'a> {
11426            value
11427        }
11428    }
11429
11430    unsafe impl fidl::encoding::TypeMarker for ConnectionRequestGattClientRequest {
11431        type Owned = Self;
11432
11433        #[inline(always)]
11434        fn inline_align(_context: fidl::encoding::Context) -> usize {
11435            4
11436        }
11437
11438        #[inline(always)]
11439        fn inline_size(_context: fidl::encoding::Context) -> usize {
11440            4
11441        }
11442    }
11443
11444    unsafe impl
11445        fidl::encoding::Encode<
11446            ConnectionRequestGattClientRequest,
11447            fidl::encoding::DefaultFuchsiaResourceDialect,
11448        > for &mut ConnectionRequestGattClientRequest
11449    {
11450        #[inline]
11451        unsafe fn encode(
11452            self,
11453            encoder: &mut fidl::encoding::Encoder<
11454                '_,
11455                fidl::encoding::DefaultFuchsiaResourceDialect,
11456            >,
11457            offset: usize,
11458            _depth: fidl::encoding::Depth,
11459        ) -> fidl::Result<()> {
11460            encoder.debug_check_bounds::<ConnectionRequestGattClientRequest>(offset);
11461            // Delegate to tuple encoding.
11462            fidl::encoding::Encode::<
11463                ConnectionRequestGattClientRequest,
11464                fidl::encoding::DefaultFuchsiaResourceDialect,
11465            >::encode(
11466                (<fidl::encoding::Endpoint<
11467                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
11468                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11469                    &mut self.client
11470                ),),
11471                encoder,
11472                offset,
11473                _depth,
11474            )
11475        }
11476    }
11477    unsafe impl<
11478        T0: fidl::encoding::Encode<
11479                fidl::encoding::Endpoint<
11480                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
11481                >,
11482                fidl::encoding::DefaultFuchsiaResourceDialect,
11483            >,
11484    >
11485        fidl::encoding::Encode<
11486            ConnectionRequestGattClientRequest,
11487            fidl::encoding::DefaultFuchsiaResourceDialect,
11488        > for (T0,)
11489    {
11490        #[inline]
11491        unsafe fn encode(
11492            self,
11493            encoder: &mut fidl::encoding::Encoder<
11494                '_,
11495                fidl::encoding::DefaultFuchsiaResourceDialect,
11496            >,
11497            offset: usize,
11498            depth: fidl::encoding::Depth,
11499        ) -> fidl::Result<()> {
11500            encoder.debug_check_bounds::<ConnectionRequestGattClientRequest>(offset);
11501            // Zero out padding regions. There's no need to apply masks
11502            // because the unmasked parts will be overwritten by fields.
11503            // Write the fields.
11504            self.0.encode(encoder, offset + 0, depth)?;
11505            Ok(())
11506        }
11507    }
11508
11509    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11510        for ConnectionRequestGattClientRequest
11511    {
11512        #[inline(always)]
11513        fn new_empty() -> Self {
11514            Self {
11515                client: fidl::new_empty!(
11516                    fidl::encoding::Endpoint<
11517                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
11518                    >,
11519                    fidl::encoding::DefaultFuchsiaResourceDialect
11520                ),
11521            }
11522        }
11523
11524        #[inline]
11525        unsafe fn decode(
11526            &mut self,
11527            decoder: &mut fidl::encoding::Decoder<
11528                '_,
11529                fidl::encoding::DefaultFuchsiaResourceDialect,
11530            >,
11531            offset: usize,
11532            _depth: fidl::encoding::Depth,
11533        ) -> fidl::Result<()> {
11534            decoder.debug_check_bounds::<Self>(offset);
11535            // Verify that padding bytes are zero.
11536            fidl::decode!(
11537                fidl::encoding::Endpoint<
11538                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
11539                >,
11540                fidl::encoding::DefaultFuchsiaResourceDialect,
11541                &mut self.client,
11542                decoder,
11543                offset + 0,
11544                _depth
11545            )?;
11546            Ok(())
11547        }
11548    }
11549
11550    impl fidl::encoding::ResourceTypeMarker for PeripheralAdvertiseRequest {
11551        type Borrowed<'a> = &'a mut Self;
11552        fn take_or_borrow<'a>(
11553            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11554        ) -> Self::Borrowed<'a> {
11555            value
11556        }
11557    }
11558
11559    unsafe impl fidl::encoding::TypeMarker for PeripheralAdvertiseRequest {
11560        type Owned = Self;
11561
11562        #[inline(always)]
11563        fn inline_align(_context: fidl::encoding::Context) -> usize {
11564            8
11565        }
11566
11567        #[inline(always)]
11568        fn inline_size(_context: fidl::encoding::Context) -> usize {
11569            24
11570        }
11571    }
11572
11573    unsafe impl
11574        fidl::encoding::Encode<
11575            PeripheralAdvertiseRequest,
11576            fidl::encoding::DefaultFuchsiaResourceDialect,
11577        > for &mut PeripheralAdvertiseRequest
11578    {
11579        #[inline]
11580        unsafe fn encode(
11581            self,
11582            encoder: &mut fidl::encoding::Encoder<
11583                '_,
11584                fidl::encoding::DefaultFuchsiaResourceDialect,
11585            >,
11586            offset: usize,
11587            _depth: fidl::encoding::Depth,
11588        ) -> fidl::Result<()> {
11589            encoder.debug_check_bounds::<PeripheralAdvertiseRequest>(offset);
11590            // Delegate to tuple encoding.
11591            fidl::encoding::Encode::<
11592                PeripheralAdvertiseRequest,
11593                fidl::encoding::DefaultFuchsiaResourceDialect,
11594            >::encode(
11595                (
11596                    <AdvertisingParameters as fidl::encoding::ValueTypeMarker>::borrow(
11597                        &self.parameters,
11598                    ),
11599                    <fidl::encoding::Endpoint<
11600                        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
11601                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11602                        &mut self.advertised_peripheral,
11603                    ),
11604                ),
11605                encoder,
11606                offset,
11607                _depth,
11608            )
11609        }
11610    }
11611    unsafe impl<
11612        T0: fidl::encoding::Encode<
11613                AdvertisingParameters,
11614                fidl::encoding::DefaultFuchsiaResourceDialect,
11615            >,
11616        T1: fidl::encoding::Encode<
11617                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>>,
11618                fidl::encoding::DefaultFuchsiaResourceDialect,
11619            >,
11620    >
11621        fidl::encoding::Encode<
11622            PeripheralAdvertiseRequest,
11623            fidl::encoding::DefaultFuchsiaResourceDialect,
11624        > for (T0, T1)
11625    {
11626        #[inline]
11627        unsafe fn encode(
11628            self,
11629            encoder: &mut fidl::encoding::Encoder<
11630                '_,
11631                fidl::encoding::DefaultFuchsiaResourceDialect,
11632            >,
11633            offset: usize,
11634            depth: fidl::encoding::Depth,
11635        ) -> fidl::Result<()> {
11636            encoder.debug_check_bounds::<PeripheralAdvertiseRequest>(offset);
11637            // Zero out padding regions. There's no need to apply masks
11638            // because the unmasked parts will be overwritten by fields.
11639            unsafe {
11640                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
11641                (ptr as *mut u64).write_unaligned(0);
11642            }
11643            // Write the fields.
11644            self.0.encode(encoder, offset + 0, depth)?;
11645            self.1.encode(encoder, offset + 16, depth)?;
11646            Ok(())
11647        }
11648    }
11649
11650    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11651        for PeripheralAdvertiseRequest
11652    {
11653        #[inline(always)]
11654        fn new_empty() -> Self {
11655            Self {
11656                parameters: fidl::new_empty!(
11657                    AdvertisingParameters,
11658                    fidl::encoding::DefaultFuchsiaResourceDialect
11659                ),
11660                advertised_peripheral: fidl::new_empty!(
11661                    fidl::encoding::Endpoint<
11662                        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
11663                    >,
11664                    fidl::encoding::DefaultFuchsiaResourceDialect
11665                ),
11666            }
11667        }
11668
11669        #[inline]
11670        unsafe fn decode(
11671            &mut self,
11672            decoder: &mut fidl::encoding::Decoder<
11673                '_,
11674                fidl::encoding::DefaultFuchsiaResourceDialect,
11675            >,
11676            offset: usize,
11677            _depth: fidl::encoding::Depth,
11678        ) -> fidl::Result<()> {
11679            decoder.debug_check_bounds::<Self>(offset);
11680            // Verify that padding bytes are zero.
11681            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
11682            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11683            let mask = 0xffffffff00000000u64;
11684            let maskedval = padval & mask;
11685            if maskedval != 0 {
11686                return Err(fidl::Error::NonZeroPadding {
11687                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
11688                });
11689            }
11690            fidl::decode!(
11691                AdvertisingParameters,
11692                fidl::encoding::DefaultFuchsiaResourceDialect,
11693                &mut self.parameters,
11694                decoder,
11695                offset + 0,
11696                _depth
11697            )?;
11698            fidl::decode!(
11699                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>>,
11700                fidl::encoding::DefaultFuchsiaResourceDialect,
11701                &mut self.advertised_peripheral,
11702                decoder,
11703                offset + 16,
11704                _depth
11705            )?;
11706            Ok(())
11707        }
11708    }
11709
11710    impl fidl::encoding::ResourceTypeMarker for PeripheralOnPeerConnectedRequest {
11711        type Borrowed<'a> = &'a mut Self;
11712        fn take_or_borrow<'a>(
11713            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11714        ) -> Self::Borrowed<'a> {
11715            value
11716        }
11717    }
11718
11719    unsafe impl fidl::encoding::TypeMarker for PeripheralOnPeerConnectedRequest {
11720        type Owned = Self;
11721
11722        #[inline(always)]
11723        fn inline_align(_context: fidl::encoding::Context) -> usize {
11724            8
11725        }
11726
11727        #[inline(always)]
11728        fn inline_size(_context: fidl::encoding::Context) -> usize {
11729            24
11730        }
11731    }
11732
11733    unsafe impl
11734        fidl::encoding::Encode<
11735            PeripheralOnPeerConnectedRequest,
11736            fidl::encoding::DefaultFuchsiaResourceDialect,
11737        > for &mut PeripheralOnPeerConnectedRequest
11738    {
11739        #[inline]
11740        unsafe fn encode(
11741            self,
11742            encoder: &mut fidl::encoding::Encoder<
11743                '_,
11744                fidl::encoding::DefaultFuchsiaResourceDialect,
11745            >,
11746            offset: usize,
11747            _depth: fidl::encoding::Depth,
11748        ) -> fidl::Result<()> {
11749            encoder.debug_check_bounds::<PeripheralOnPeerConnectedRequest>(offset);
11750            // Delegate to tuple encoding.
11751            fidl::encoding::Encode::<PeripheralOnPeerConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
11752                (
11753                    <Peer as fidl::encoding::ValueTypeMarker>::borrow(&self.peer),
11754                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.connection),
11755                ),
11756                encoder, offset, _depth
11757            )
11758        }
11759    }
11760    unsafe impl<
11761        T0: fidl::encoding::Encode<Peer, fidl::encoding::DefaultFuchsiaResourceDialect>,
11762        T1: fidl::encoding::Encode<
11763                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
11764                fidl::encoding::DefaultFuchsiaResourceDialect,
11765            >,
11766    >
11767        fidl::encoding::Encode<
11768            PeripheralOnPeerConnectedRequest,
11769            fidl::encoding::DefaultFuchsiaResourceDialect,
11770        > for (T0, T1)
11771    {
11772        #[inline]
11773        unsafe fn encode(
11774            self,
11775            encoder: &mut fidl::encoding::Encoder<
11776                '_,
11777                fidl::encoding::DefaultFuchsiaResourceDialect,
11778            >,
11779            offset: usize,
11780            depth: fidl::encoding::Depth,
11781        ) -> fidl::Result<()> {
11782            encoder.debug_check_bounds::<PeripheralOnPeerConnectedRequest>(offset);
11783            // Zero out padding regions. There's no need to apply masks
11784            // because the unmasked parts will be overwritten by fields.
11785            unsafe {
11786                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
11787                (ptr as *mut u64).write_unaligned(0);
11788            }
11789            // Write the fields.
11790            self.0.encode(encoder, offset + 0, depth)?;
11791            self.1.encode(encoder, offset + 16, depth)?;
11792            Ok(())
11793        }
11794    }
11795
11796    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11797        for PeripheralOnPeerConnectedRequest
11798    {
11799        #[inline(always)]
11800        fn new_empty() -> Self {
11801            Self {
11802                peer: fidl::new_empty!(Peer, fidl::encoding::DefaultFuchsiaResourceDialect),
11803                connection: fidl::new_empty!(
11804                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
11805                    fidl::encoding::DefaultFuchsiaResourceDialect
11806                ),
11807            }
11808        }
11809
11810        #[inline]
11811        unsafe fn decode(
11812            &mut self,
11813            decoder: &mut fidl::encoding::Decoder<
11814                '_,
11815                fidl::encoding::DefaultFuchsiaResourceDialect,
11816            >,
11817            offset: usize,
11818            _depth: fidl::encoding::Depth,
11819        ) -> fidl::Result<()> {
11820            decoder.debug_check_bounds::<Self>(offset);
11821            // Verify that padding bytes are zero.
11822            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
11823            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11824            let mask = 0xffffffff00000000u64;
11825            let maskedval = padval & mask;
11826            if maskedval != 0 {
11827                return Err(fidl::Error::NonZeroPadding {
11828                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
11829                });
11830            }
11831            fidl::decode!(
11832                Peer,
11833                fidl::encoding::DefaultFuchsiaResourceDialect,
11834                &mut self.peer,
11835                decoder,
11836                offset + 0,
11837                _depth
11838            )?;
11839            fidl::decode!(
11840                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
11841                fidl::encoding::DefaultFuchsiaResourceDialect,
11842                &mut self.connection,
11843                decoder,
11844                offset + 16,
11845                _depth
11846            )?;
11847            Ok(())
11848        }
11849    }
11850
11851    impl fidl::encoding::ResourceTypeMarker for PeripheralStartAdvertisingRequest {
11852        type Borrowed<'a> = &'a mut Self;
11853        fn take_or_borrow<'a>(
11854            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11855        ) -> Self::Borrowed<'a> {
11856            value
11857        }
11858    }
11859
11860    unsafe impl fidl::encoding::TypeMarker for PeripheralStartAdvertisingRequest {
11861        type Owned = Self;
11862
11863        #[inline(always)]
11864        fn inline_align(_context: fidl::encoding::Context) -> usize {
11865            8
11866        }
11867
11868        #[inline(always)]
11869        fn inline_size(_context: fidl::encoding::Context) -> usize {
11870            24
11871        }
11872    }
11873
11874    unsafe impl
11875        fidl::encoding::Encode<
11876            PeripheralStartAdvertisingRequest,
11877            fidl::encoding::DefaultFuchsiaResourceDialect,
11878        > for &mut PeripheralStartAdvertisingRequest
11879    {
11880        #[inline]
11881        unsafe fn encode(
11882            self,
11883            encoder: &mut fidl::encoding::Encoder<
11884                '_,
11885                fidl::encoding::DefaultFuchsiaResourceDialect,
11886            >,
11887            offset: usize,
11888            _depth: fidl::encoding::Depth,
11889        ) -> fidl::Result<()> {
11890            encoder.debug_check_bounds::<PeripheralStartAdvertisingRequest>(offset);
11891            // Delegate to tuple encoding.
11892            fidl::encoding::Encode::<PeripheralStartAdvertisingRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
11893                (
11894                    <AdvertisingParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.parameters),
11895                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
11896                ),
11897                encoder, offset, _depth
11898            )
11899        }
11900    }
11901    unsafe impl<
11902        T0: fidl::encoding::Encode<
11903                AdvertisingParameters,
11904                fidl::encoding::DefaultFuchsiaResourceDialect,
11905            >,
11906        T1: fidl::encoding::Encode<
11907                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
11908                fidl::encoding::DefaultFuchsiaResourceDialect,
11909            >,
11910    >
11911        fidl::encoding::Encode<
11912            PeripheralStartAdvertisingRequest,
11913            fidl::encoding::DefaultFuchsiaResourceDialect,
11914        > for (T0, T1)
11915    {
11916        #[inline]
11917        unsafe fn encode(
11918            self,
11919            encoder: &mut fidl::encoding::Encoder<
11920                '_,
11921                fidl::encoding::DefaultFuchsiaResourceDialect,
11922            >,
11923            offset: usize,
11924            depth: fidl::encoding::Depth,
11925        ) -> fidl::Result<()> {
11926            encoder.debug_check_bounds::<PeripheralStartAdvertisingRequest>(offset);
11927            // Zero out padding regions. There's no need to apply masks
11928            // because the unmasked parts will be overwritten by fields.
11929            unsafe {
11930                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
11931                (ptr as *mut u64).write_unaligned(0);
11932            }
11933            // Write the fields.
11934            self.0.encode(encoder, offset + 0, depth)?;
11935            self.1.encode(encoder, offset + 16, depth)?;
11936            Ok(())
11937        }
11938    }
11939
11940    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11941        for PeripheralStartAdvertisingRequest
11942    {
11943        #[inline(always)]
11944        fn new_empty() -> Self {
11945            Self {
11946                parameters: fidl::new_empty!(
11947                    AdvertisingParameters,
11948                    fidl::encoding::DefaultFuchsiaResourceDialect
11949                ),
11950                handle: fidl::new_empty!(
11951                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
11952                    fidl::encoding::DefaultFuchsiaResourceDialect
11953                ),
11954            }
11955        }
11956
11957        #[inline]
11958        unsafe fn decode(
11959            &mut self,
11960            decoder: &mut fidl::encoding::Decoder<
11961                '_,
11962                fidl::encoding::DefaultFuchsiaResourceDialect,
11963            >,
11964            offset: usize,
11965            _depth: fidl::encoding::Depth,
11966        ) -> fidl::Result<()> {
11967            decoder.debug_check_bounds::<Self>(offset);
11968            // Verify that padding bytes are zero.
11969            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
11970            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11971            let mask = 0xffffffff00000000u64;
11972            let maskedval = padval & mask;
11973            if maskedval != 0 {
11974                return Err(fidl::Error::NonZeroPadding {
11975                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
11976                });
11977            }
11978            fidl::decode!(
11979                AdvertisingParameters,
11980                fidl::encoding::DefaultFuchsiaResourceDialect,
11981                &mut self.parameters,
11982                decoder,
11983                offset + 0,
11984                _depth
11985            )?;
11986            fidl::decode!(
11987                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
11988                fidl::encoding::DefaultFuchsiaResourceDialect,
11989                &mut self.handle,
11990                decoder,
11991                offset + 16,
11992                _depth
11993            )?;
11994            Ok(())
11995        }
11996    }
11997
11998    impl CentralCreateConnectedIsochronousGroupRequest {
11999        #[inline(always)]
12000        fn max_ordinal_present(&self) -> u64 {
12001            if let Some(_) = self.cig {
12002                return 3;
12003            }
12004            if let Some(_) = self.cis_requested_parameters {
12005                return 2;
12006            }
12007            if let Some(_) = self.cig_parameters {
12008                return 1;
12009            }
12010            0
12011        }
12012    }
12013
12014    impl fidl::encoding::ResourceTypeMarker for CentralCreateConnectedIsochronousGroupRequest {
12015        type Borrowed<'a> = &'a mut Self;
12016        fn take_or_borrow<'a>(
12017            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12018        ) -> Self::Borrowed<'a> {
12019            value
12020        }
12021    }
12022
12023    unsafe impl fidl::encoding::TypeMarker for CentralCreateConnectedIsochronousGroupRequest {
12024        type Owned = Self;
12025
12026        #[inline(always)]
12027        fn inline_align(_context: fidl::encoding::Context) -> usize {
12028            8
12029        }
12030
12031        #[inline(always)]
12032        fn inline_size(_context: fidl::encoding::Context) -> usize {
12033            16
12034        }
12035    }
12036
12037    unsafe impl
12038        fidl::encoding::Encode<
12039            CentralCreateConnectedIsochronousGroupRequest,
12040            fidl::encoding::DefaultFuchsiaResourceDialect,
12041        > for &mut CentralCreateConnectedIsochronousGroupRequest
12042    {
12043        unsafe fn encode(
12044            self,
12045            encoder: &mut fidl::encoding::Encoder<
12046                '_,
12047                fidl::encoding::DefaultFuchsiaResourceDialect,
12048            >,
12049            offset: usize,
12050            mut depth: fidl::encoding::Depth,
12051        ) -> fidl::Result<()> {
12052            encoder.debug_check_bounds::<CentralCreateConnectedIsochronousGroupRequest>(offset);
12053            // Vector header
12054            let max_ordinal: u64 = self.max_ordinal_present();
12055            encoder.write_num(max_ordinal, offset);
12056            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12057            // Calling encoder.out_of_line_offset(0) is not allowed.
12058            if max_ordinal == 0 {
12059                return Ok(());
12060            }
12061            depth.increment()?;
12062            let envelope_size = 8;
12063            let bytes_len = max_ordinal as usize * envelope_size;
12064            #[allow(unused_variables)]
12065            let offset = encoder.out_of_line_offset(bytes_len);
12066            let mut _prev_end_offset: usize = 0;
12067            if 1 > max_ordinal {
12068                return Ok(());
12069            }
12070
12071            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12072            // are envelope_size bytes.
12073            let cur_offset: usize = (1 - 1) * envelope_size;
12074
12075            // Zero reserved fields.
12076            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12077
12078            // Safety:
12079            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12080            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12081            //   envelope_size bytes, there is always sufficient room.
12082            fidl::encoding::encode_in_envelope_optional::<
12083                CigParameters,
12084                fidl::encoding::DefaultFuchsiaResourceDialect,
12085            >(
12086                self.cig_parameters
12087                    .as_ref()
12088                    .map(<CigParameters as fidl::encoding::ValueTypeMarker>::borrow),
12089                encoder,
12090                offset + cur_offset,
12091                depth,
12092            )?;
12093
12094            _prev_end_offset = cur_offset + envelope_size;
12095            if 2 > max_ordinal {
12096                return Ok(());
12097            }
12098
12099            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12100            // are envelope_size bytes.
12101            let cur_offset: usize = (2 - 1) * envelope_size;
12102
12103            // Zero reserved fields.
12104            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12105
12106            // Safety:
12107            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12108            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12109            //   envelope_size bytes, there is always sufficient room.
12110            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect>(
12111            self.cis_requested_parameters.as_mut().map(<fidl::encoding::Vector<CisRequestedParameters, 31> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
12112            encoder, offset + cur_offset, depth
12113        )?;
12114
12115            _prev_end_offset = cur_offset + envelope_size;
12116            if 3 > max_ordinal {
12117                return Ok(());
12118            }
12119
12120            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12121            // are envelope_size bytes.
12122            let cur_offset: usize = (3 - 1) * envelope_size;
12123
12124            // Zero reserved fields.
12125            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12126
12127            // Safety:
12128            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12129            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12130            //   envelope_size bytes, there is always sufficient room.
12131            fidl::encoding::encode_in_envelope_optional::<
12132                fidl::encoding::Endpoint<
12133                    fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
12134                >,
12135                fidl::encoding::DefaultFuchsiaResourceDialect,
12136            >(
12137                self.cig.as_mut().map(
12138                    <fidl::encoding::Endpoint<
12139                        fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
12140                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12141                ),
12142                encoder,
12143                offset + cur_offset,
12144                depth,
12145            )?;
12146
12147            _prev_end_offset = cur_offset + envelope_size;
12148
12149            Ok(())
12150        }
12151    }
12152
12153    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12154        for CentralCreateConnectedIsochronousGroupRequest
12155    {
12156        #[inline(always)]
12157        fn new_empty() -> Self {
12158            Self::default()
12159        }
12160
12161        unsafe fn decode(
12162            &mut self,
12163            decoder: &mut fidl::encoding::Decoder<
12164                '_,
12165                fidl::encoding::DefaultFuchsiaResourceDialect,
12166            >,
12167            offset: usize,
12168            mut depth: fidl::encoding::Depth,
12169        ) -> fidl::Result<()> {
12170            decoder.debug_check_bounds::<Self>(offset);
12171            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12172                None => return Err(fidl::Error::NotNullable),
12173                Some(len) => len,
12174            };
12175            // Calling decoder.out_of_line_offset(0) is not allowed.
12176            if len == 0 {
12177                return Ok(());
12178            };
12179            depth.increment()?;
12180            let envelope_size = 8;
12181            let bytes_len = len * envelope_size;
12182            let offset = decoder.out_of_line_offset(bytes_len)?;
12183            // Decode the envelope for each type.
12184            let mut _next_ordinal_to_read = 0;
12185            let mut next_offset = offset;
12186            let end_offset = offset + bytes_len;
12187            _next_ordinal_to_read += 1;
12188            if next_offset >= end_offset {
12189                return Ok(());
12190            }
12191
12192            // Decode unknown envelopes for gaps in ordinals.
12193            while _next_ordinal_to_read < 1 {
12194                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12195                _next_ordinal_to_read += 1;
12196                next_offset += envelope_size;
12197            }
12198
12199            let next_out_of_line = decoder.next_out_of_line();
12200            let handles_before = decoder.remaining_handles();
12201            if let Some((inlined, num_bytes, num_handles)) =
12202                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12203            {
12204                let member_inline_size =
12205                    <CigParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12206                if inlined != (member_inline_size <= 4) {
12207                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12208                }
12209                let inner_offset;
12210                let mut inner_depth = depth.clone();
12211                if inlined {
12212                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12213                    inner_offset = next_offset;
12214                } else {
12215                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12216                    inner_depth.increment()?;
12217                }
12218                let val_ref = self.cig_parameters.get_or_insert_with(|| {
12219                    fidl::new_empty!(CigParameters, fidl::encoding::DefaultFuchsiaResourceDialect)
12220                });
12221                fidl::decode!(
12222                    CigParameters,
12223                    fidl::encoding::DefaultFuchsiaResourceDialect,
12224                    val_ref,
12225                    decoder,
12226                    inner_offset,
12227                    inner_depth
12228                )?;
12229                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12230                {
12231                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12232                }
12233                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12234                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12235                }
12236            }
12237
12238            next_offset += envelope_size;
12239            _next_ordinal_to_read += 1;
12240            if next_offset >= end_offset {
12241                return Ok(());
12242            }
12243
12244            // Decode unknown envelopes for gaps in ordinals.
12245            while _next_ordinal_to_read < 2 {
12246                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12247                _next_ordinal_to_read += 1;
12248                next_offset += envelope_size;
12249            }
12250
12251            let next_out_of_line = decoder.next_out_of_line();
12252            let handles_before = decoder.remaining_handles();
12253            if let Some((inlined, num_bytes, num_handles)) =
12254                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12255            {
12256                let member_inline_size = <fidl::encoding::Vector<CisRequestedParameters, 31> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12257                if inlined != (member_inline_size <= 4) {
12258                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12259                }
12260                let inner_offset;
12261                let mut inner_depth = depth.clone();
12262                if inlined {
12263                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12264                    inner_offset = next_offset;
12265                } else {
12266                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12267                    inner_depth.increment()?;
12268                }
12269                let val_ref =
12270                self.cis_requested_parameters.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect));
12271                fidl::decode!(fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12272                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12273                {
12274                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12275                }
12276                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12277                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12278                }
12279            }
12280
12281            next_offset += envelope_size;
12282            _next_ordinal_to_read += 1;
12283            if next_offset >= end_offset {
12284                return Ok(());
12285            }
12286
12287            // Decode unknown envelopes for gaps in ordinals.
12288            while _next_ordinal_to_read < 3 {
12289                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12290                _next_ordinal_to_read += 1;
12291                next_offset += envelope_size;
12292            }
12293
12294            let next_out_of_line = decoder.next_out_of_line();
12295            let handles_before = decoder.remaining_handles();
12296            if let Some((inlined, num_bytes, num_handles)) =
12297                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12298            {
12299                let member_inline_size = <fidl::encoding::Endpoint<
12300                    fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
12301                > as fidl::encoding::TypeMarker>::inline_size(
12302                    decoder.context
12303                );
12304                if inlined != (member_inline_size <= 4) {
12305                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12306                }
12307                let inner_offset;
12308                let mut inner_depth = depth.clone();
12309                if inlined {
12310                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12311                    inner_offset = next_offset;
12312                } else {
12313                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12314                    inner_depth.increment()?;
12315                }
12316                let val_ref = self.cig.get_or_insert_with(|| {
12317                    fidl::new_empty!(
12318                        fidl::encoding::Endpoint<
12319                            fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
12320                        >,
12321                        fidl::encoding::DefaultFuchsiaResourceDialect
12322                    )
12323                });
12324                fidl::decode!(
12325                    fidl::encoding::Endpoint<
12326                        fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
12327                    >,
12328                    fidl::encoding::DefaultFuchsiaResourceDialect,
12329                    val_ref,
12330                    decoder,
12331                    inner_offset,
12332                    inner_depth
12333                )?;
12334                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12335                {
12336                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12337                }
12338                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12339                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12340                }
12341            }
12342
12343            next_offset += envelope_size;
12344
12345            // Decode the remaining unknown envelopes.
12346            while next_offset < end_offset {
12347                _next_ordinal_to_read += 1;
12348                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12349                next_offset += envelope_size;
12350            }
12351
12352            Ok(())
12353        }
12354    }
12355
12356    impl CentralSyncToPeriodicAdvertisingRequest {
12357        #[inline(always)]
12358        fn max_ordinal_present(&self) -> u64 {
12359            if let Some(_) = self.config {
12360                return 4;
12361            }
12362            if let Some(_) = self.sync {
12363                return 3;
12364            }
12365            if let Some(_) = self.advertising_sid {
12366                return 2;
12367            }
12368            if let Some(_) = self.peer_id {
12369                return 1;
12370            }
12371            0
12372        }
12373    }
12374
12375    impl fidl::encoding::ResourceTypeMarker for CentralSyncToPeriodicAdvertisingRequest {
12376        type Borrowed<'a> = &'a mut Self;
12377        fn take_or_borrow<'a>(
12378            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12379        ) -> Self::Borrowed<'a> {
12380            value
12381        }
12382    }
12383
12384    unsafe impl fidl::encoding::TypeMarker for CentralSyncToPeriodicAdvertisingRequest {
12385        type Owned = Self;
12386
12387        #[inline(always)]
12388        fn inline_align(_context: fidl::encoding::Context) -> usize {
12389            8
12390        }
12391
12392        #[inline(always)]
12393        fn inline_size(_context: fidl::encoding::Context) -> usize {
12394            16
12395        }
12396    }
12397
12398    unsafe impl
12399        fidl::encoding::Encode<
12400            CentralSyncToPeriodicAdvertisingRequest,
12401            fidl::encoding::DefaultFuchsiaResourceDialect,
12402        > for &mut CentralSyncToPeriodicAdvertisingRequest
12403    {
12404        unsafe fn encode(
12405            self,
12406            encoder: &mut fidl::encoding::Encoder<
12407                '_,
12408                fidl::encoding::DefaultFuchsiaResourceDialect,
12409            >,
12410            offset: usize,
12411            mut depth: fidl::encoding::Depth,
12412        ) -> fidl::Result<()> {
12413            encoder.debug_check_bounds::<CentralSyncToPeriodicAdvertisingRequest>(offset);
12414            // Vector header
12415            let max_ordinal: u64 = self.max_ordinal_present();
12416            encoder.write_num(max_ordinal, offset);
12417            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12418            // Calling encoder.out_of_line_offset(0) is not allowed.
12419            if max_ordinal == 0 {
12420                return Ok(());
12421            }
12422            depth.increment()?;
12423            let envelope_size = 8;
12424            let bytes_len = max_ordinal as usize * envelope_size;
12425            #[allow(unused_variables)]
12426            let offset = encoder.out_of_line_offset(bytes_len);
12427            let mut _prev_end_offset: usize = 0;
12428            if 1 > max_ordinal {
12429                return Ok(());
12430            }
12431
12432            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12433            // are envelope_size bytes.
12434            let cur_offset: usize = (1 - 1) * envelope_size;
12435
12436            // Zero reserved fields.
12437            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12438
12439            // Safety:
12440            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12441            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12442            //   envelope_size bytes, there is always sufficient room.
12443            fidl::encoding::encode_in_envelope_optional::<
12444                fidl_fuchsia_bluetooth::PeerId,
12445                fidl::encoding::DefaultFuchsiaResourceDialect,
12446            >(
12447                self.peer_id.as_ref().map(
12448                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow,
12449                ),
12450                encoder,
12451                offset + cur_offset,
12452                depth,
12453            )?;
12454
12455            _prev_end_offset = cur_offset + envelope_size;
12456            if 2 > max_ordinal {
12457                return Ok(());
12458            }
12459
12460            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12461            // are envelope_size bytes.
12462            let cur_offset: usize = (2 - 1) * envelope_size;
12463
12464            // Zero reserved fields.
12465            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12466
12467            // Safety:
12468            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12469            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12470            //   envelope_size bytes, there is always sufficient room.
12471            fidl::encoding::encode_in_envelope_optional::<
12472                u8,
12473                fidl::encoding::DefaultFuchsiaResourceDialect,
12474            >(
12475                self.advertising_sid.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
12476                encoder,
12477                offset + cur_offset,
12478                depth,
12479            )?;
12480
12481            _prev_end_offset = cur_offset + envelope_size;
12482            if 3 > max_ordinal {
12483                return Ok(());
12484            }
12485
12486            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12487            // are envelope_size bytes.
12488            let cur_offset: usize = (3 - 1) * envelope_size;
12489
12490            // Zero reserved fields.
12491            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12492
12493            // Safety:
12494            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12495            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12496            //   envelope_size bytes, there is always sufficient room.
12497            fidl::encoding::encode_in_envelope_optional::<
12498                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>>,
12499                fidl::encoding::DefaultFuchsiaResourceDialect,
12500            >(
12501                self.sync.as_mut().map(
12502                    <fidl::encoding::Endpoint<
12503                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
12504                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12505                ),
12506                encoder,
12507                offset + cur_offset,
12508                depth,
12509            )?;
12510
12511            _prev_end_offset = cur_offset + envelope_size;
12512            if 4 > max_ordinal {
12513                return Ok(());
12514            }
12515
12516            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12517            // are envelope_size bytes.
12518            let cur_offset: usize = (4 - 1) * envelope_size;
12519
12520            // Zero reserved fields.
12521            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12522
12523            // Safety:
12524            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12525            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12526            //   envelope_size bytes, there is always sufficient room.
12527            fidl::encoding::encode_in_envelope_optional::<PeriodicAdvertisingSyncConfiguration, fidl::encoding::DefaultFuchsiaResourceDialect>(
12528            self.config.as_ref().map(<PeriodicAdvertisingSyncConfiguration as fidl::encoding::ValueTypeMarker>::borrow),
12529            encoder, offset + cur_offset, depth
12530        )?;
12531
12532            _prev_end_offset = cur_offset + envelope_size;
12533
12534            Ok(())
12535        }
12536    }
12537
12538    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12539        for CentralSyncToPeriodicAdvertisingRequest
12540    {
12541        #[inline(always)]
12542        fn new_empty() -> Self {
12543            Self::default()
12544        }
12545
12546        unsafe fn decode(
12547            &mut self,
12548            decoder: &mut fidl::encoding::Decoder<
12549                '_,
12550                fidl::encoding::DefaultFuchsiaResourceDialect,
12551            >,
12552            offset: usize,
12553            mut depth: fidl::encoding::Depth,
12554        ) -> fidl::Result<()> {
12555            decoder.debug_check_bounds::<Self>(offset);
12556            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12557                None => return Err(fidl::Error::NotNullable),
12558                Some(len) => len,
12559            };
12560            // Calling decoder.out_of_line_offset(0) is not allowed.
12561            if len == 0 {
12562                return Ok(());
12563            };
12564            depth.increment()?;
12565            let envelope_size = 8;
12566            let bytes_len = len * envelope_size;
12567            let offset = decoder.out_of_line_offset(bytes_len)?;
12568            // Decode the envelope for each type.
12569            let mut _next_ordinal_to_read = 0;
12570            let mut next_offset = offset;
12571            let end_offset = offset + bytes_len;
12572            _next_ordinal_to_read += 1;
12573            if next_offset >= end_offset {
12574                return Ok(());
12575            }
12576
12577            // Decode unknown envelopes for gaps in ordinals.
12578            while _next_ordinal_to_read < 1 {
12579                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12580                _next_ordinal_to_read += 1;
12581                next_offset += envelope_size;
12582            }
12583
12584            let next_out_of_line = decoder.next_out_of_line();
12585            let handles_before = decoder.remaining_handles();
12586            if let Some((inlined, num_bytes, num_handles)) =
12587                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12588            {
12589                let member_inline_size =
12590                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::TypeMarker>::inline_size(
12591                        decoder.context,
12592                    );
12593                if inlined != (member_inline_size <= 4) {
12594                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12595                }
12596                let inner_offset;
12597                let mut inner_depth = depth.clone();
12598                if inlined {
12599                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12600                    inner_offset = next_offset;
12601                } else {
12602                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12603                    inner_depth.increment()?;
12604                }
12605                let val_ref = self.peer_id.get_or_insert_with(|| {
12606                    fidl::new_empty!(
12607                        fidl_fuchsia_bluetooth::PeerId,
12608                        fidl::encoding::DefaultFuchsiaResourceDialect
12609                    )
12610                });
12611                fidl::decode!(
12612                    fidl_fuchsia_bluetooth::PeerId,
12613                    fidl::encoding::DefaultFuchsiaResourceDialect,
12614                    val_ref,
12615                    decoder,
12616                    inner_offset,
12617                    inner_depth
12618                )?;
12619                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12620                {
12621                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12622                }
12623                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12624                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12625                }
12626            }
12627
12628            next_offset += envelope_size;
12629            _next_ordinal_to_read += 1;
12630            if next_offset >= end_offset {
12631                return Ok(());
12632            }
12633
12634            // Decode unknown envelopes for gaps in ordinals.
12635            while _next_ordinal_to_read < 2 {
12636                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12637                _next_ordinal_to_read += 1;
12638                next_offset += envelope_size;
12639            }
12640
12641            let next_out_of_line = decoder.next_out_of_line();
12642            let handles_before = decoder.remaining_handles();
12643            if let Some((inlined, num_bytes, num_handles)) =
12644                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12645            {
12646                let member_inline_size =
12647                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12648                if inlined != (member_inline_size <= 4) {
12649                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12650                }
12651                let inner_offset;
12652                let mut inner_depth = depth.clone();
12653                if inlined {
12654                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12655                    inner_offset = next_offset;
12656                } else {
12657                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12658                    inner_depth.increment()?;
12659                }
12660                let val_ref = self.advertising_sid.get_or_insert_with(|| {
12661                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
12662                });
12663                fidl::decode!(
12664                    u8,
12665                    fidl::encoding::DefaultFuchsiaResourceDialect,
12666                    val_ref,
12667                    decoder,
12668                    inner_offset,
12669                    inner_depth
12670                )?;
12671                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12672                {
12673                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12674                }
12675                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12676                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12677                }
12678            }
12679
12680            next_offset += envelope_size;
12681            _next_ordinal_to_read += 1;
12682            if next_offset >= end_offset {
12683                return Ok(());
12684            }
12685
12686            // Decode unknown envelopes for gaps in ordinals.
12687            while _next_ordinal_to_read < 3 {
12688                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12689                _next_ordinal_to_read += 1;
12690                next_offset += envelope_size;
12691            }
12692
12693            let next_out_of_line = decoder.next_out_of_line();
12694            let handles_before = decoder.remaining_handles();
12695            if let Some((inlined, num_bytes, num_handles)) =
12696                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12697            {
12698                let member_inline_size = <fidl::encoding::Endpoint<
12699                    fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
12700                > as fidl::encoding::TypeMarker>::inline_size(
12701                    decoder.context
12702                );
12703                if inlined != (member_inline_size <= 4) {
12704                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12705                }
12706                let inner_offset;
12707                let mut inner_depth = depth.clone();
12708                if inlined {
12709                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12710                    inner_offset = next_offset;
12711                } else {
12712                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12713                    inner_depth.increment()?;
12714                }
12715                let val_ref = self.sync.get_or_insert_with(|| {
12716                    fidl::new_empty!(
12717                        fidl::encoding::Endpoint<
12718                            fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
12719                        >,
12720                        fidl::encoding::DefaultFuchsiaResourceDialect
12721                    )
12722                });
12723                fidl::decode!(
12724                    fidl::encoding::Endpoint<
12725                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
12726                    >,
12727                    fidl::encoding::DefaultFuchsiaResourceDialect,
12728                    val_ref,
12729                    decoder,
12730                    inner_offset,
12731                    inner_depth
12732                )?;
12733                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12734                {
12735                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12736                }
12737                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12738                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12739                }
12740            }
12741
12742            next_offset += envelope_size;
12743            _next_ordinal_to_read += 1;
12744            if next_offset >= end_offset {
12745                return Ok(());
12746            }
12747
12748            // Decode unknown envelopes for gaps in ordinals.
12749            while _next_ordinal_to_read < 4 {
12750                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12751                _next_ordinal_to_read += 1;
12752                next_offset += envelope_size;
12753            }
12754
12755            let next_out_of_line = decoder.next_out_of_line();
12756            let handles_before = decoder.remaining_handles();
12757            if let Some((inlined, num_bytes, num_handles)) =
12758                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12759            {
12760                let member_inline_size = <PeriodicAdvertisingSyncConfiguration as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12761                if inlined != (member_inline_size <= 4) {
12762                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12763                }
12764                let inner_offset;
12765                let mut inner_depth = depth.clone();
12766                if inlined {
12767                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12768                    inner_offset = next_offset;
12769                } else {
12770                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12771                    inner_depth.increment()?;
12772                }
12773                let val_ref = self.config.get_or_insert_with(|| {
12774                    fidl::new_empty!(
12775                        PeriodicAdvertisingSyncConfiguration,
12776                        fidl::encoding::DefaultFuchsiaResourceDialect
12777                    )
12778                });
12779                fidl::decode!(
12780                    PeriodicAdvertisingSyncConfiguration,
12781                    fidl::encoding::DefaultFuchsiaResourceDialect,
12782                    val_ref,
12783                    decoder,
12784                    inner_offset,
12785                    inner_depth
12786                )?;
12787                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12788                {
12789                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12790                }
12791                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12792                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12793                }
12794            }
12795
12796            next_offset += envelope_size;
12797
12798            // Decode the remaining unknown envelopes.
12799            while next_offset < end_offset {
12800                _next_ordinal_to_read += 1;
12801                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12802                next_offset += envelope_size;
12803            }
12804
12805            Ok(())
12806        }
12807    }
12808
12809    impl ChannelListenerRegistryListenL2capRequest {
12810        #[inline(always)]
12811        fn max_ordinal_present(&self) -> u64 {
12812            if let Some(_) = self.listener {
12813                return 2;
12814            }
12815            if let Some(_) = self.parameters {
12816                return 1;
12817            }
12818            0
12819        }
12820    }
12821
12822    impl fidl::encoding::ResourceTypeMarker for ChannelListenerRegistryListenL2capRequest {
12823        type Borrowed<'a> = &'a mut Self;
12824        fn take_or_borrow<'a>(
12825            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12826        ) -> Self::Borrowed<'a> {
12827            value
12828        }
12829    }
12830
12831    unsafe impl fidl::encoding::TypeMarker for ChannelListenerRegistryListenL2capRequest {
12832        type Owned = Self;
12833
12834        #[inline(always)]
12835        fn inline_align(_context: fidl::encoding::Context) -> usize {
12836            8
12837        }
12838
12839        #[inline(always)]
12840        fn inline_size(_context: fidl::encoding::Context) -> usize {
12841            16
12842        }
12843    }
12844
12845    unsafe impl
12846        fidl::encoding::Encode<
12847            ChannelListenerRegistryListenL2capRequest,
12848            fidl::encoding::DefaultFuchsiaResourceDialect,
12849        > for &mut ChannelListenerRegistryListenL2capRequest
12850    {
12851        unsafe fn encode(
12852            self,
12853            encoder: &mut fidl::encoding::Encoder<
12854                '_,
12855                fidl::encoding::DefaultFuchsiaResourceDialect,
12856            >,
12857            offset: usize,
12858            mut depth: fidl::encoding::Depth,
12859        ) -> fidl::Result<()> {
12860            encoder.debug_check_bounds::<ChannelListenerRegistryListenL2capRequest>(offset);
12861            // Vector header
12862            let max_ordinal: u64 = self.max_ordinal_present();
12863            encoder.write_num(max_ordinal, offset);
12864            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12865            // Calling encoder.out_of_line_offset(0) is not allowed.
12866            if max_ordinal == 0 {
12867                return Ok(());
12868            }
12869            depth.increment()?;
12870            let envelope_size = 8;
12871            let bytes_len = max_ordinal as usize * envelope_size;
12872            #[allow(unused_variables)]
12873            let offset = encoder.out_of_line_offset(bytes_len);
12874            let mut _prev_end_offset: usize = 0;
12875            if 1 > max_ordinal {
12876                return Ok(());
12877            }
12878
12879            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12880            // are envelope_size bytes.
12881            let cur_offset: usize = (1 - 1) * envelope_size;
12882
12883            // Zero reserved fields.
12884            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12885
12886            // Safety:
12887            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12888            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12889            //   envelope_size bytes, there is always sufficient room.
12890            fidl::encoding::encode_in_envelope_optional::<
12891                AcceptedChannelParameters,
12892                fidl::encoding::DefaultFuchsiaResourceDialect,
12893            >(
12894                self.parameters
12895                    .as_ref()
12896                    .map(<AcceptedChannelParameters as fidl::encoding::ValueTypeMarker>::borrow),
12897                encoder,
12898                offset + cur_offset,
12899                depth,
12900            )?;
12901
12902            _prev_end_offset = cur_offset + envelope_size;
12903            if 2 > max_ordinal {
12904                return Ok(());
12905            }
12906
12907            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12908            // are envelope_size bytes.
12909            let cur_offset: usize = (2 - 1) * envelope_size;
12910
12911            // Zero reserved fields.
12912            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12913
12914            // Safety:
12915            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12916            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12917            //   envelope_size bytes, there is always sufficient room.
12918            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
12919            self.listener.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
12920            encoder, offset + cur_offset, depth
12921        )?;
12922
12923            _prev_end_offset = cur_offset + envelope_size;
12924
12925            Ok(())
12926        }
12927    }
12928
12929    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12930        for ChannelListenerRegistryListenL2capRequest
12931    {
12932        #[inline(always)]
12933        fn new_empty() -> Self {
12934            Self::default()
12935        }
12936
12937        unsafe fn decode(
12938            &mut self,
12939            decoder: &mut fidl::encoding::Decoder<
12940                '_,
12941                fidl::encoding::DefaultFuchsiaResourceDialect,
12942            >,
12943            offset: usize,
12944            mut depth: fidl::encoding::Depth,
12945        ) -> fidl::Result<()> {
12946            decoder.debug_check_bounds::<Self>(offset);
12947            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12948                None => return Err(fidl::Error::NotNullable),
12949                Some(len) => len,
12950            };
12951            // Calling decoder.out_of_line_offset(0) is not allowed.
12952            if len == 0 {
12953                return Ok(());
12954            };
12955            depth.increment()?;
12956            let envelope_size = 8;
12957            let bytes_len = len * envelope_size;
12958            let offset = decoder.out_of_line_offset(bytes_len)?;
12959            // Decode the envelope for each type.
12960            let mut _next_ordinal_to_read = 0;
12961            let mut next_offset = offset;
12962            let end_offset = offset + bytes_len;
12963            _next_ordinal_to_read += 1;
12964            if next_offset >= end_offset {
12965                return Ok(());
12966            }
12967
12968            // Decode unknown envelopes for gaps in ordinals.
12969            while _next_ordinal_to_read < 1 {
12970                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12971                _next_ordinal_to_read += 1;
12972                next_offset += envelope_size;
12973            }
12974
12975            let next_out_of_line = decoder.next_out_of_line();
12976            let handles_before = decoder.remaining_handles();
12977            if let Some((inlined, num_bytes, num_handles)) =
12978                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12979            {
12980                let member_inline_size =
12981                    <AcceptedChannelParameters as fidl::encoding::TypeMarker>::inline_size(
12982                        decoder.context,
12983                    );
12984                if inlined != (member_inline_size <= 4) {
12985                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12986                }
12987                let inner_offset;
12988                let mut inner_depth = depth.clone();
12989                if inlined {
12990                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12991                    inner_offset = next_offset;
12992                } else {
12993                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12994                    inner_depth.increment()?;
12995                }
12996                let val_ref = self.parameters.get_or_insert_with(|| {
12997                    fidl::new_empty!(
12998                        AcceptedChannelParameters,
12999                        fidl::encoding::DefaultFuchsiaResourceDialect
13000                    )
13001                });
13002                fidl::decode!(
13003                    AcceptedChannelParameters,
13004                    fidl::encoding::DefaultFuchsiaResourceDialect,
13005                    val_ref,
13006                    decoder,
13007                    inner_offset,
13008                    inner_depth
13009                )?;
13010                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13011                {
13012                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13013                }
13014                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13015                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13016                }
13017            }
13018
13019            next_offset += envelope_size;
13020            _next_ordinal_to_read += 1;
13021            if next_offset >= end_offset {
13022                return Ok(());
13023            }
13024
13025            // Decode unknown envelopes for gaps in ordinals.
13026            while _next_ordinal_to_read < 2 {
13027                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13028                _next_ordinal_to_read += 1;
13029                next_offset += envelope_size;
13030            }
13031
13032            let next_out_of_line = decoder.next_out_of_line();
13033            let handles_before = decoder.remaining_handles();
13034            if let Some((inlined, num_bytes, num_handles)) =
13035                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13036            {
13037                let member_inline_size = <fidl::encoding::Endpoint<
13038                    fidl::endpoints::ClientEnd<ChannelListenerMarker>,
13039                > as fidl::encoding::TypeMarker>::inline_size(
13040                    decoder.context
13041                );
13042                if inlined != (member_inline_size <= 4) {
13043                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13044                }
13045                let inner_offset;
13046                let mut inner_depth = depth.clone();
13047                if inlined {
13048                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13049                    inner_offset = next_offset;
13050                } else {
13051                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13052                    inner_depth.increment()?;
13053                }
13054                let val_ref = self.listener.get_or_insert_with(|| {
13055                    fidl::new_empty!(
13056                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
13057                        fidl::encoding::DefaultFuchsiaResourceDialect
13058                    )
13059                });
13060                fidl::decode!(
13061                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
13062                    fidl::encoding::DefaultFuchsiaResourceDialect,
13063                    val_ref,
13064                    decoder,
13065                    inner_offset,
13066                    inner_depth
13067                )?;
13068                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13069                {
13070                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13071                }
13072                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13073                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13074                }
13075            }
13076
13077            next_offset += envelope_size;
13078
13079            // Decode the remaining unknown envelopes.
13080            while next_offset < end_offset {
13081                _next_ordinal_to_read += 1;
13082                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13083                next_offset += envelope_size;
13084            }
13085
13086            Ok(())
13087        }
13088    }
13089
13090    impl CisRequestedParameters {
13091        #[inline(always)]
13092        fn max_ordinal_present(&self) -> u64 {
13093            if let Some(_) = self.max_sdu_size_incoming {
13094                return 4;
13095            }
13096            if let Some(_) = self.max_sdu_size_outgoing {
13097                return 3;
13098            }
13099            if let Some(_) = self.connection_stream {
13100                return 2;
13101            }
13102            if let Some(_) = self.cis_id {
13103                return 1;
13104            }
13105            0
13106        }
13107    }
13108
13109    impl fidl::encoding::ResourceTypeMarker for CisRequestedParameters {
13110        type Borrowed<'a> = &'a mut Self;
13111        fn take_or_borrow<'a>(
13112            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13113        ) -> Self::Borrowed<'a> {
13114            value
13115        }
13116    }
13117
13118    unsafe impl fidl::encoding::TypeMarker for CisRequestedParameters {
13119        type Owned = Self;
13120
13121        #[inline(always)]
13122        fn inline_align(_context: fidl::encoding::Context) -> usize {
13123            8
13124        }
13125
13126        #[inline(always)]
13127        fn inline_size(_context: fidl::encoding::Context) -> usize {
13128            16
13129        }
13130    }
13131
13132    unsafe impl
13133        fidl::encoding::Encode<
13134            CisRequestedParameters,
13135            fidl::encoding::DefaultFuchsiaResourceDialect,
13136        > for &mut CisRequestedParameters
13137    {
13138        unsafe fn encode(
13139            self,
13140            encoder: &mut fidl::encoding::Encoder<
13141                '_,
13142                fidl::encoding::DefaultFuchsiaResourceDialect,
13143            >,
13144            offset: usize,
13145            mut depth: fidl::encoding::Depth,
13146        ) -> fidl::Result<()> {
13147            encoder.debug_check_bounds::<CisRequestedParameters>(offset);
13148            // Vector header
13149            let max_ordinal: u64 = self.max_ordinal_present();
13150            encoder.write_num(max_ordinal, offset);
13151            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13152            // Calling encoder.out_of_line_offset(0) is not allowed.
13153            if max_ordinal == 0 {
13154                return Ok(());
13155            }
13156            depth.increment()?;
13157            let envelope_size = 8;
13158            let bytes_len = max_ordinal as usize * envelope_size;
13159            #[allow(unused_variables)]
13160            let offset = encoder.out_of_line_offset(bytes_len);
13161            let mut _prev_end_offset: usize = 0;
13162            if 1 > max_ordinal {
13163                return Ok(());
13164            }
13165
13166            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13167            // are envelope_size bytes.
13168            let cur_offset: usize = (1 - 1) * envelope_size;
13169
13170            // Zero reserved fields.
13171            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13172
13173            // Safety:
13174            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13175            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13176            //   envelope_size bytes, there is always sufficient room.
13177            fidl::encoding::encode_in_envelope_optional::<
13178                u8,
13179                fidl::encoding::DefaultFuchsiaResourceDialect,
13180            >(
13181                self.cis_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
13182                encoder,
13183                offset + cur_offset,
13184                depth,
13185            )?;
13186
13187            _prev_end_offset = cur_offset + envelope_size;
13188            if 2 > max_ordinal {
13189                return Ok(());
13190            }
13191
13192            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13193            // are envelope_size bytes.
13194            let cur_offset: usize = (2 - 1) * envelope_size;
13195
13196            // Zero reserved fields.
13197            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13198
13199            // Safety:
13200            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13201            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13202            //   envelope_size bytes, there is always sufficient room.
13203            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
13204            self.connection_stream.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
13205            encoder, offset + cur_offset, depth
13206        )?;
13207
13208            _prev_end_offset = cur_offset + envelope_size;
13209            if 3 > max_ordinal {
13210                return Ok(());
13211            }
13212
13213            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13214            // are envelope_size bytes.
13215            let cur_offset: usize = (3 - 1) * envelope_size;
13216
13217            // Zero reserved fields.
13218            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13219
13220            // Safety:
13221            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13222            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13223            //   envelope_size bytes, there is always sufficient room.
13224            fidl::encoding::encode_in_envelope_optional::<
13225                u16,
13226                fidl::encoding::DefaultFuchsiaResourceDialect,
13227            >(
13228                self.max_sdu_size_outgoing
13229                    .as_ref()
13230                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
13231                encoder,
13232                offset + cur_offset,
13233                depth,
13234            )?;
13235
13236            _prev_end_offset = cur_offset + envelope_size;
13237            if 4 > max_ordinal {
13238                return Ok(());
13239            }
13240
13241            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13242            // are envelope_size bytes.
13243            let cur_offset: usize = (4 - 1) * envelope_size;
13244
13245            // Zero reserved fields.
13246            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13247
13248            // Safety:
13249            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13250            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13251            //   envelope_size bytes, there is always sufficient room.
13252            fidl::encoding::encode_in_envelope_optional::<
13253                u16,
13254                fidl::encoding::DefaultFuchsiaResourceDialect,
13255            >(
13256                self.max_sdu_size_incoming
13257                    .as_ref()
13258                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
13259                encoder,
13260                offset + cur_offset,
13261                depth,
13262            )?;
13263
13264            _prev_end_offset = cur_offset + envelope_size;
13265
13266            Ok(())
13267        }
13268    }
13269
13270    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13271        for CisRequestedParameters
13272    {
13273        #[inline(always)]
13274        fn new_empty() -> Self {
13275            Self::default()
13276        }
13277
13278        unsafe fn decode(
13279            &mut self,
13280            decoder: &mut fidl::encoding::Decoder<
13281                '_,
13282                fidl::encoding::DefaultFuchsiaResourceDialect,
13283            >,
13284            offset: usize,
13285            mut depth: fidl::encoding::Depth,
13286        ) -> fidl::Result<()> {
13287            decoder.debug_check_bounds::<Self>(offset);
13288            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13289                None => return Err(fidl::Error::NotNullable),
13290                Some(len) => len,
13291            };
13292            // Calling decoder.out_of_line_offset(0) is not allowed.
13293            if len == 0 {
13294                return Ok(());
13295            };
13296            depth.increment()?;
13297            let envelope_size = 8;
13298            let bytes_len = len * envelope_size;
13299            let offset = decoder.out_of_line_offset(bytes_len)?;
13300            // Decode the envelope for each type.
13301            let mut _next_ordinal_to_read = 0;
13302            let mut next_offset = offset;
13303            let end_offset = offset + bytes_len;
13304            _next_ordinal_to_read += 1;
13305            if next_offset >= end_offset {
13306                return Ok(());
13307            }
13308
13309            // Decode unknown envelopes for gaps in ordinals.
13310            while _next_ordinal_to_read < 1 {
13311                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13312                _next_ordinal_to_read += 1;
13313                next_offset += envelope_size;
13314            }
13315
13316            let next_out_of_line = decoder.next_out_of_line();
13317            let handles_before = decoder.remaining_handles();
13318            if let Some((inlined, num_bytes, num_handles)) =
13319                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13320            {
13321                let member_inline_size =
13322                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13323                if inlined != (member_inline_size <= 4) {
13324                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13325                }
13326                let inner_offset;
13327                let mut inner_depth = depth.clone();
13328                if inlined {
13329                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13330                    inner_offset = next_offset;
13331                } else {
13332                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13333                    inner_depth.increment()?;
13334                }
13335                let val_ref = self.cis_id.get_or_insert_with(|| {
13336                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
13337                });
13338                fidl::decode!(
13339                    u8,
13340                    fidl::encoding::DefaultFuchsiaResourceDialect,
13341                    val_ref,
13342                    decoder,
13343                    inner_offset,
13344                    inner_depth
13345                )?;
13346                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13347                {
13348                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13349                }
13350                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13351                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13352                }
13353            }
13354
13355            next_offset += envelope_size;
13356            _next_ordinal_to_read += 1;
13357            if next_offset >= end_offset {
13358                return Ok(());
13359            }
13360
13361            // Decode unknown envelopes for gaps in ordinals.
13362            while _next_ordinal_to_read < 2 {
13363                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13364                _next_ordinal_to_read += 1;
13365                next_offset += envelope_size;
13366            }
13367
13368            let next_out_of_line = decoder.next_out_of_line();
13369            let handles_before = decoder.remaining_handles();
13370            if let Some((inlined, num_bytes, num_handles)) =
13371                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13372            {
13373                let member_inline_size = <fidl::encoding::Endpoint<
13374                    fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
13375                > as fidl::encoding::TypeMarker>::inline_size(
13376                    decoder.context
13377                );
13378                if inlined != (member_inline_size <= 4) {
13379                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13380                }
13381                let inner_offset;
13382                let mut inner_depth = depth.clone();
13383                if inlined {
13384                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13385                    inner_offset = next_offset;
13386                } else {
13387                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13388                    inner_depth.increment()?;
13389                }
13390                let val_ref = self.connection_stream.get_or_insert_with(|| {
13391                    fidl::new_empty!(
13392                        fidl::encoding::Endpoint<
13393                            fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
13394                        >,
13395                        fidl::encoding::DefaultFuchsiaResourceDialect
13396                    )
13397                });
13398                fidl::decode!(
13399                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
13400                    fidl::encoding::DefaultFuchsiaResourceDialect,
13401                    val_ref,
13402                    decoder,
13403                    inner_offset,
13404                    inner_depth
13405                )?;
13406                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13407                {
13408                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13409                }
13410                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13411                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13412                }
13413            }
13414
13415            next_offset += envelope_size;
13416            _next_ordinal_to_read += 1;
13417            if next_offset >= end_offset {
13418                return Ok(());
13419            }
13420
13421            // Decode unknown envelopes for gaps in ordinals.
13422            while _next_ordinal_to_read < 3 {
13423                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13424                _next_ordinal_to_read += 1;
13425                next_offset += envelope_size;
13426            }
13427
13428            let next_out_of_line = decoder.next_out_of_line();
13429            let handles_before = decoder.remaining_handles();
13430            if let Some((inlined, num_bytes, num_handles)) =
13431                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13432            {
13433                let member_inline_size =
13434                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13435                if inlined != (member_inline_size <= 4) {
13436                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13437                }
13438                let inner_offset;
13439                let mut inner_depth = depth.clone();
13440                if inlined {
13441                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13442                    inner_offset = next_offset;
13443                } else {
13444                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13445                    inner_depth.increment()?;
13446                }
13447                let val_ref = self.max_sdu_size_outgoing.get_or_insert_with(|| {
13448                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
13449                });
13450                fidl::decode!(
13451                    u16,
13452                    fidl::encoding::DefaultFuchsiaResourceDialect,
13453                    val_ref,
13454                    decoder,
13455                    inner_offset,
13456                    inner_depth
13457                )?;
13458                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13459                {
13460                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13461                }
13462                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13463                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13464                }
13465            }
13466
13467            next_offset += envelope_size;
13468            _next_ordinal_to_read += 1;
13469            if next_offset >= end_offset {
13470                return Ok(());
13471            }
13472
13473            // Decode unknown envelopes for gaps in ordinals.
13474            while _next_ordinal_to_read < 4 {
13475                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13476                _next_ordinal_to_read += 1;
13477                next_offset += envelope_size;
13478            }
13479
13480            let next_out_of_line = decoder.next_out_of_line();
13481            let handles_before = decoder.remaining_handles();
13482            if let Some((inlined, num_bytes, num_handles)) =
13483                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13484            {
13485                let member_inline_size =
13486                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13487                if inlined != (member_inline_size <= 4) {
13488                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13489                }
13490                let inner_offset;
13491                let mut inner_depth = depth.clone();
13492                if inlined {
13493                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13494                    inner_offset = next_offset;
13495                } else {
13496                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13497                    inner_depth.increment()?;
13498                }
13499                let val_ref = self.max_sdu_size_incoming.get_or_insert_with(|| {
13500                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
13501                });
13502                fidl::decode!(
13503                    u16,
13504                    fidl::encoding::DefaultFuchsiaResourceDialect,
13505                    val_ref,
13506                    decoder,
13507                    inner_offset,
13508                    inner_depth
13509                )?;
13510                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13511                {
13512                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13513                }
13514                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13515                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13516                }
13517            }
13518
13519            next_offset += envelope_size;
13520
13521            // Decode the remaining unknown envelopes.
13522            while next_offset < end_offset {
13523                _next_ordinal_to_read += 1;
13524                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13525                next_offset += envelope_size;
13526            }
13527
13528            Ok(())
13529        }
13530    }
13531
13532    impl ConnectionAcceptCisRequest {
13533        #[inline(always)]
13534        fn max_ordinal_present(&self) -> u64 {
13535            if let Some(_) = self.connection_stream {
13536                return 3;
13537            }
13538            if let Some(_) = self.cis_id {
13539                return 2;
13540            }
13541            if let Some(_) = self.cig_id {
13542                return 1;
13543            }
13544            0
13545        }
13546    }
13547
13548    impl fidl::encoding::ResourceTypeMarker for ConnectionAcceptCisRequest {
13549        type Borrowed<'a> = &'a mut Self;
13550        fn take_or_borrow<'a>(
13551            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13552        ) -> Self::Borrowed<'a> {
13553            value
13554        }
13555    }
13556
13557    unsafe impl fidl::encoding::TypeMarker for ConnectionAcceptCisRequest {
13558        type Owned = Self;
13559
13560        #[inline(always)]
13561        fn inline_align(_context: fidl::encoding::Context) -> usize {
13562            8
13563        }
13564
13565        #[inline(always)]
13566        fn inline_size(_context: fidl::encoding::Context) -> usize {
13567            16
13568        }
13569    }
13570
13571    unsafe impl
13572        fidl::encoding::Encode<
13573            ConnectionAcceptCisRequest,
13574            fidl::encoding::DefaultFuchsiaResourceDialect,
13575        > for &mut ConnectionAcceptCisRequest
13576    {
13577        unsafe fn encode(
13578            self,
13579            encoder: &mut fidl::encoding::Encoder<
13580                '_,
13581                fidl::encoding::DefaultFuchsiaResourceDialect,
13582            >,
13583            offset: usize,
13584            mut depth: fidl::encoding::Depth,
13585        ) -> fidl::Result<()> {
13586            encoder.debug_check_bounds::<ConnectionAcceptCisRequest>(offset);
13587            // Vector header
13588            let max_ordinal: u64 = self.max_ordinal_present();
13589            encoder.write_num(max_ordinal, offset);
13590            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13591            // Calling encoder.out_of_line_offset(0) is not allowed.
13592            if max_ordinal == 0 {
13593                return Ok(());
13594            }
13595            depth.increment()?;
13596            let envelope_size = 8;
13597            let bytes_len = max_ordinal as usize * envelope_size;
13598            #[allow(unused_variables)]
13599            let offset = encoder.out_of_line_offset(bytes_len);
13600            let mut _prev_end_offset: usize = 0;
13601            if 1 > max_ordinal {
13602                return Ok(());
13603            }
13604
13605            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13606            // are envelope_size bytes.
13607            let cur_offset: usize = (1 - 1) * envelope_size;
13608
13609            // Zero reserved fields.
13610            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13611
13612            // Safety:
13613            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13614            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13615            //   envelope_size bytes, there is always sufficient room.
13616            fidl::encoding::encode_in_envelope_optional::<
13617                u8,
13618                fidl::encoding::DefaultFuchsiaResourceDialect,
13619            >(
13620                self.cig_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
13621                encoder,
13622                offset + cur_offset,
13623                depth,
13624            )?;
13625
13626            _prev_end_offset = cur_offset + envelope_size;
13627            if 2 > max_ordinal {
13628                return Ok(());
13629            }
13630
13631            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13632            // are envelope_size bytes.
13633            let cur_offset: usize = (2 - 1) * envelope_size;
13634
13635            // Zero reserved fields.
13636            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13637
13638            // Safety:
13639            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13640            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13641            //   envelope_size bytes, there is always sufficient room.
13642            fidl::encoding::encode_in_envelope_optional::<
13643                u8,
13644                fidl::encoding::DefaultFuchsiaResourceDialect,
13645            >(
13646                self.cis_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
13647                encoder,
13648                offset + cur_offset,
13649                depth,
13650            )?;
13651
13652            _prev_end_offset = cur_offset + envelope_size;
13653            if 3 > max_ordinal {
13654                return Ok(());
13655            }
13656
13657            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13658            // are envelope_size bytes.
13659            let cur_offset: usize = (3 - 1) * envelope_size;
13660
13661            // Zero reserved fields.
13662            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13663
13664            // Safety:
13665            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13666            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13667            //   envelope_size bytes, there is always sufficient room.
13668            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
13669            self.connection_stream.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
13670            encoder, offset + cur_offset, depth
13671        )?;
13672
13673            _prev_end_offset = cur_offset + envelope_size;
13674
13675            Ok(())
13676        }
13677    }
13678
13679    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13680        for ConnectionAcceptCisRequest
13681    {
13682        #[inline(always)]
13683        fn new_empty() -> Self {
13684            Self::default()
13685        }
13686
13687        unsafe fn decode(
13688            &mut self,
13689            decoder: &mut fidl::encoding::Decoder<
13690                '_,
13691                fidl::encoding::DefaultFuchsiaResourceDialect,
13692            >,
13693            offset: usize,
13694            mut depth: fidl::encoding::Depth,
13695        ) -> fidl::Result<()> {
13696            decoder.debug_check_bounds::<Self>(offset);
13697            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13698                None => return Err(fidl::Error::NotNullable),
13699                Some(len) => len,
13700            };
13701            // Calling decoder.out_of_line_offset(0) is not allowed.
13702            if len == 0 {
13703                return Ok(());
13704            };
13705            depth.increment()?;
13706            let envelope_size = 8;
13707            let bytes_len = len * envelope_size;
13708            let offset = decoder.out_of_line_offset(bytes_len)?;
13709            // Decode the envelope for each type.
13710            let mut _next_ordinal_to_read = 0;
13711            let mut next_offset = offset;
13712            let end_offset = offset + bytes_len;
13713            _next_ordinal_to_read += 1;
13714            if next_offset >= end_offset {
13715                return Ok(());
13716            }
13717
13718            // Decode unknown envelopes for gaps in ordinals.
13719            while _next_ordinal_to_read < 1 {
13720                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13721                _next_ordinal_to_read += 1;
13722                next_offset += envelope_size;
13723            }
13724
13725            let next_out_of_line = decoder.next_out_of_line();
13726            let handles_before = decoder.remaining_handles();
13727            if let Some((inlined, num_bytes, num_handles)) =
13728                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13729            {
13730                let member_inline_size =
13731                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13732                if inlined != (member_inline_size <= 4) {
13733                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13734                }
13735                let inner_offset;
13736                let mut inner_depth = depth.clone();
13737                if inlined {
13738                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13739                    inner_offset = next_offset;
13740                } else {
13741                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13742                    inner_depth.increment()?;
13743                }
13744                let val_ref = self.cig_id.get_or_insert_with(|| {
13745                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
13746                });
13747                fidl::decode!(
13748                    u8,
13749                    fidl::encoding::DefaultFuchsiaResourceDialect,
13750                    val_ref,
13751                    decoder,
13752                    inner_offset,
13753                    inner_depth
13754                )?;
13755                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13756                {
13757                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13758                }
13759                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13760                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13761                }
13762            }
13763
13764            next_offset += envelope_size;
13765            _next_ordinal_to_read += 1;
13766            if next_offset >= end_offset {
13767                return Ok(());
13768            }
13769
13770            // Decode unknown envelopes for gaps in ordinals.
13771            while _next_ordinal_to_read < 2 {
13772                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13773                _next_ordinal_to_read += 1;
13774                next_offset += envelope_size;
13775            }
13776
13777            let next_out_of_line = decoder.next_out_of_line();
13778            let handles_before = decoder.remaining_handles();
13779            if let Some((inlined, num_bytes, num_handles)) =
13780                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13781            {
13782                let member_inline_size =
13783                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13784                if inlined != (member_inline_size <= 4) {
13785                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13786                }
13787                let inner_offset;
13788                let mut inner_depth = depth.clone();
13789                if inlined {
13790                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13791                    inner_offset = next_offset;
13792                } else {
13793                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13794                    inner_depth.increment()?;
13795                }
13796                let val_ref = self.cis_id.get_or_insert_with(|| {
13797                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
13798                });
13799                fidl::decode!(
13800                    u8,
13801                    fidl::encoding::DefaultFuchsiaResourceDialect,
13802                    val_ref,
13803                    decoder,
13804                    inner_offset,
13805                    inner_depth
13806                )?;
13807                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13808                {
13809                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13810                }
13811                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13812                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13813                }
13814            }
13815
13816            next_offset += envelope_size;
13817            _next_ordinal_to_read += 1;
13818            if next_offset >= end_offset {
13819                return Ok(());
13820            }
13821
13822            // Decode unknown envelopes for gaps in ordinals.
13823            while _next_ordinal_to_read < 3 {
13824                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13825                _next_ordinal_to_read += 1;
13826                next_offset += envelope_size;
13827            }
13828
13829            let next_out_of_line = decoder.next_out_of_line();
13830            let handles_before = decoder.remaining_handles();
13831            if let Some((inlined, num_bytes, num_handles)) =
13832                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13833            {
13834                let member_inline_size = <fidl::encoding::Endpoint<
13835                    fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
13836                > as fidl::encoding::TypeMarker>::inline_size(
13837                    decoder.context
13838                );
13839                if inlined != (member_inline_size <= 4) {
13840                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13841                }
13842                let inner_offset;
13843                let mut inner_depth = depth.clone();
13844                if inlined {
13845                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13846                    inner_offset = next_offset;
13847                } else {
13848                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13849                    inner_depth.increment()?;
13850                }
13851                let val_ref = self.connection_stream.get_or_insert_with(|| {
13852                    fidl::new_empty!(
13853                        fidl::encoding::Endpoint<
13854                            fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
13855                        >,
13856                        fidl::encoding::DefaultFuchsiaResourceDialect
13857                    )
13858                });
13859                fidl::decode!(
13860                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
13861                    fidl::encoding::DefaultFuchsiaResourceDialect,
13862                    val_ref,
13863                    decoder,
13864                    inner_offset,
13865                    inner_depth
13866                )?;
13867                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13868                {
13869                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13870                }
13871                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13872                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13873                }
13874            }
13875
13876            next_offset += envelope_size;
13877
13878            // Decode the remaining unknown envelopes.
13879            while next_offset < end_offset {
13880                _next_ordinal_to_read += 1;
13881                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13882                next_offset += envelope_size;
13883            }
13884
13885            Ok(())
13886        }
13887    }
13888
13889    impl ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
13890        #[inline(always)]
13891        fn max_ordinal_present(&self) -> u64 {
13892            if let Some(_) = self.config {
13893                return 2;
13894            }
13895            if let Some(_) = self.sync {
13896                return 1;
13897            }
13898            0
13899        }
13900    }
13901
13902    impl fidl::encoding::ResourceTypeMarker for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
13903        type Borrowed<'a> = &'a mut Self;
13904        fn take_or_borrow<'a>(
13905            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13906        ) -> Self::Borrowed<'a> {
13907            value
13908        }
13909    }
13910
13911    unsafe impl fidl::encoding::TypeMarker for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
13912        type Owned = Self;
13913
13914        #[inline(always)]
13915        fn inline_align(_context: fidl::encoding::Context) -> usize {
13916            8
13917        }
13918
13919        #[inline(always)]
13920        fn inline_size(_context: fidl::encoding::Context) -> usize {
13921            16
13922        }
13923    }
13924
13925    unsafe impl
13926        fidl::encoding::Encode<
13927            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
13928            fidl::encoding::DefaultFuchsiaResourceDialect,
13929        > for &mut ConnectionAcceptPeriodicAdvertisingSyncTransferRequest
13930    {
13931        unsafe fn encode(
13932            self,
13933            encoder: &mut fidl::encoding::Encoder<
13934                '_,
13935                fidl::encoding::DefaultFuchsiaResourceDialect,
13936            >,
13937            offset: usize,
13938            mut depth: fidl::encoding::Depth,
13939        ) -> fidl::Result<()> {
13940            encoder.debug_check_bounds::<ConnectionAcceptPeriodicAdvertisingSyncTransferRequest>(
13941                offset,
13942            );
13943            // Vector header
13944            let max_ordinal: u64 = self.max_ordinal_present();
13945            encoder.write_num(max_ordinal, offset);
13946            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13947            // Calling encoder.out_of_line_offset(0) is not allowed.
13948            if max_ordinal == 0 {
13949                return Ok(());
13950            }
13951            depth.increment()?;
13952            let envelope_size = 8;
13953            let bytes_len = max_ordinal as usize * envelope_size;
13954            #[allow(unused_variables)]
13955            let offset = encoder.out_of_line_offset(bytes_len);
13956            let mut _prev_end_offset: usize = 0;
13957            if 1 > max_ordinal {
13958                return Ok(());
13959            }
13960
13961            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13962            // are envelope_size bytes.
13963            let cur_offset: usize = (1 - 1) * envelope_size;
13964
13965            // Zero reserved fields.
13966            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13967
13968            // Safety:
13969            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13970            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13971            //   envelope_size bytes, there is always sufficient room.
13972            fidl::encoding::encode_in_envelope_optional::<
13973                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>>,
13974                fidl::encoding::DefaultFuchsiaResourceDialect,
13975            >(
13976                self.sync.as_mut().map(
13977                    <fidl::encoding::Endpoint<
13978                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
13979                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13980                ),
13981                encoder,
13982                offset + cur_offset,
13983                depth,
13984            )?;
13985
13986            _prev_end_offset = cur_offset + envelope_size;
13987            if 2 > max_ordinal {
13988                return Ok(());
13989            }
13990
13991            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13992            // are envelope_size bytes.
13993            let cur_offset: usize = (2 - 1) * envelope_size;
13994
13995            // Zero reserved fields.
13996            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13997
13998            // Safety:
13999            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14000            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14001            //   envelope_size bytes, there is always sufficient room.
14002            fidl::encoding::encode_in_envelope_optional::<PeriodicAdvertisingSyncConfiguration, fidl::encoding::DefaultFuchsiaResourceDialect>(
14003            self.config.as_ref().map(<PeriodicAdvertisingSyncConfiguration as fidl::encoding::ValueTypeMarker>::borrow),
14004            encoder, offset + cur_offset, depth
14005        )?;
14006
14007            _prev_end_offset = cur_offset + envelope_size;
14008
14009            Ok(())
14010        }
14011    }
14012
14013    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14014        for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest
14015    {
14016        #[inline(always)]
14017        fn new_empty() -> Self {
14018            Self::default()
14019        }
14020
14021        unsafe fn decode(
14022            &mut self,
14023            decoder: &mut fidl::encoding::Decoder<
14024                '_,
14025                fidl::encoding::DefaultFuchsiaResourceDialect,
14026            >,
14027            offset: usize,
14028            mut depth: fidl::encoding::Depth,
14029        ) -> fidl::Result<()> {
14030            decoder.debug_check_bounds::<Self>(offset);
14031            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14032                None => return Err(fidl::Error::NotNullable),
14033                Some(len) => len,
14034            };
14035            // Calling decoder.out_of_line_offset(0) is not allowed.
14036            if len == 0 {
14037                return Ok(());
14038            };
14039            depth.increment()?;
14040            let envelope_size = 8;
14041            let bytes_len = len * envelope_size;
14042            let offset = decoder.out_of_line_offset(bytes_len)?;
14043            // Decode the envelope for each type.
14044            let mut _next_ordinal_to_read = 0;
14045            let mut next_offset = offset;
14046            let end_offset = offset + bytes_len;
14047            _next_ordinal_to_read += 1;
14048            if next_offset >= end_offset {
14049                return Ok(());
14050            }
14051
14052            // Decode unknown envelopes for gaps in ordinals.
14053            while _next_ordinal_to_read < 1 {
14054                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14055                _next_ordinal_to_read += 1;
14056                next_offset += envelope_size;
14057            }
14058
14059            let next_out_of_line = decoder.next_out_of_line();
14060            let handles_before = decoder.remaining_handles();
14061            if let Some((inlined, num_bytes, num_handles)) =
14062                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14063            {
14064                let member_inline_size = <fidl::encoding::Endpoint<
14065                    fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
14066                > as fidl::encoding::TypeMarker>::inline_size(
14067                    decoder.context
14068                );
14069                if inlined != (member_inline_size <= 4) {
14070                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14071                }
14072                let inner_offset;
14073                let mut inner_depth = depth.clone();
14074                if inlined {
14075                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14076                    inner_offset = next_offset;
14077                } else {
14078                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14079                    inner_depth.increment()?;
14080                }
14081                let val_ref = self.sync.get_or_insert_with(|| {
14082                    fidl::new_empty!(
14083                        fidl::encoding::Endpoint<
14084                            fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
14085                        >,
14086                        fidl::encoding::DefaultFuchsiaResourceDialect
14087                    )
14088                });
14089                fidl::decode!(
14090                    fidl::encoding::Endpoint<
14091                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
14092                    >,
14093                    fidl::encoding::DefaultFuchsiaResourceDialect,
14094                    val_ref,
14095                    decoder,
14096                    inner_offset,
14097                    inner_depth
14098                )?;
14099                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14100                {
14101                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14102                }
14103                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14104                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14105                }
14106            }
14107
14108            next_offset += envelope_size;
14109            _next_ordinal_to_read += 1;
14110            if next_offset >= end_offset {
14111                return Ok(());
14112            }
14113
14114            // Decode unknown envelopes for gaps in ordinals.
14115            while _next_ordinal_to_read < 2 {
14116                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14117                _next_ordinal_to_read += 1;
14118                next_offset += envelope_size;
14119            }
14120
14121            let next_out_of_line = decoder.next_out_of_line();
14122            let handles_before = decoder.remaining_handles();
14123            if let Some((inlined, num_bytes, num_handles)) =
14124                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14125            {
14126                let member_inline_size = <PeriodicAdvertisingSyncConfiguration as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14127                if inlined != (member_inline_size <= 4) {
14128                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14129                }
14130                let inner_offset;
14131                let mut inner_depth = depth.clone();
14132                if inlined {
14133                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14134                    inner_offset = next_offset;
14135                } else {
14136                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14137                    inner_depth.increment()?;
14138                }
14139                let val_ref = self.config.get_or_insert_with(|| {
14140                    fidl::new_empty!(
14141                        PeriodicAdvertisingSyncConfiguration,
14142                        fidl::encoding::DefaultFuchsiaResourceDialect
14143                    )
14144                });
14145                fidl::decode!(
14146                    PeriodicAdvertisingSyncConfiguration,
14147                    fidl::encoding::DefaultFuchsiaResourceDialect,
14148                    val_ref,
14149                    decoder,
14150                    inner_offset,
14151                    inner_depth
14152                )?;
14153                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14154                {
14155                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14156                }
14157                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14158                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14159                }
14160            }
14161
14162            next_offset += envelope_size;
14163
14164            // Decode the remaining unknown envelopes.
14165            while next_offset < end_offset {
14166                _next_ordinal_to_read += 1;
14167                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14168                next_offset += envelope_size;
14169            }
14170
14171            Ok(())
14172        }
14173    }
14174
14175    impl ConnectionConnectL2capRequest {
14176        #[inline(always)]
14177        fn max_ordinal_present(&self) -> u64 {
14178            if let Some(_) = self.psm {
14179                return 3;
14180            }
14181            if let Some(_) = self.channel {
14182                return 2;
14183            }
14184            if let Some(_) = self.parameters {
14185                return 1;
14186            }
14187            0
14188        }
14189    }
14190
14191    impl fidl::encoding::ResourceTypeMarker for ConnectionConnectL2capRequest {
14192        type Borrowed<'a> = &'a mut Self;
14193        fn take_or_borrow<'a>(
14194            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14195        ) -> Self::Borrowed<'a> {
14196            value
14197        }
14198    }
14199
14200    unsafe impl fidl::encoding::TypeMarker for ConnectionConnectL2capRequest {
14201        type Owned = Self;
14202
14203        #[inline(always)]
14204        fn inline_align(_context: fidl::encoding::Context) -> usize {
14205            8
14206        }
14207
14208        #[inline(always)]
14209        fn inline_size(_context: fidl::encoding::Context) -> usize {
14210            16
14211        }
14212    }
14213
14214    unsafe impl
14215        fidl::encoding::Encode<
14216            ConnectionConnectL2capRequest,
14217            fidl::encoding::DefaultFuchsiaResourceDialect,
14218        > for &mut ConnectionConnectL2capRequest
14219    {
14220        unsafe fn encode(
14221            self,
14222            encoder: &mut fidl::encoding::Encoder<
14223                '_,
14224                fidl::encoding::DefaultFuchsiaResourceDialect,
14225            >,
14226            offset: usize,
14227            mut depth: fidl::encoding::Depth,
14228        ) -> fidl::Result<()> {
14229            encoder.debug_check_bounds::<ConnectionConnectL2capRequest>(offset);
14230            // Vector header
14231            let max_ordinal: u64 = self.max_ordinal_present();
14232            encoder.write_num(max_ordinal, offset);
14233            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14234            // Calling encoder.out_of_line_offset(0) is not allowed.
14235            if max_ordinal == 0 {
14236                return Ok(());
14237            }
14238            depth.increment()?;
14239            let envelope_size = 8;
14240            let bytes_len = max_ordinal as usize * envelope_size;
14241            #[allow(unused_variables)]
14242            let offset = encoder.out_of_line_offset(bytes_len);
14243            let mut _prev_end_offset: usize = 0;
14244            if 1 > max_ordinal {
14245                return Ok(());
14246            }
14247
14248            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14249            // are envelope_size bytes.
14250            let cur_offset: usize = (1 - 1) * envelope_size;
14251
14252            // Zero reserved fields.
14253            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14254
14255            // Safety:
14256            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14257            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14258            //   envelope_size bytes, there is always sufficient room.
14259            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth::ChannelParameters, fidl::encoding::DefaultFuchsiaResourceDialect>(
14260            self.parameters.as_ref().map(<fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::ValueTypeMarker>::borrow),
14261            encoder, offset + cur_offset, depth
14262        )?;
14263
14264            _prev_end_offset = cur_offset + envelope_size;
14265            if 2 > max_ordinal {
14266                return Ok(());
14267            }
14268
14269            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14270            // are envelope_size bytes.
14271            let cur_offset: usize = (2 - 1) * envelope_size;
14272
14273            // Zero reserved fields.
14274            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14275
14276            // Safety:
14277            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14278            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14279            //   envelope_size bytes, there is always sufficient room.
14280            fidl::encoding::encode_in_envelope_optional::<
14281                fidl::encoding::Endpoint<
14282                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14283                >,
14284                fidl::encoding::DefaultFuchsiaResourceDialect,
14285            >(
14286                self.channel.as_mut().map(
14287                    <fidl::encoding::Endpoint<
14288                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14289                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14290                ),
14291                encoder,
14292                offset + cur_offset,
14293                depth,
14294            )?;
14295
14296            _prev_end_offset = cur_offset + envelope_size;
14297            if 3 > max_ordinal {
14298                return Ok(());
14299            }
14300
14301            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14302            // are envelope_size bytes.
14303            let cur_offset: usize = (3 - 1) * envelope_size;
14304
14305            // Zero reserved fields.
14306            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14307
14308            // Safety:
14309            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14310            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14311            //   envelope_size bytes, there is always sufficient room.
14312            fidl::encoding::encode_in_envelope_optional::<
14313                u16,
14314                fidl::encoding::DefaultFuchsiaResourceDialect,
14315            >(
14316                self.psm.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
14317                encoder,
14318                offset + cur_offset,
14319                depth,
14320            )?;
14321
14322            _prev_end_offset = cur_offset + envelope_size;
14323
14324            Ok(())
14325        }
14326    }
14327
14328    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14329        for ConnectionConnectL2capRequest
14330    {
14331        #[inline(always)]
14332        fn new_empty() -> Self {
14333            Self::default()
14334        }
14335
14336        unsafe fn decode(
14337            &mut self,
14338            decoder: &mut fidl::encoding::Decoder<
14339                '_,
14340                fidl::encoding::DefaultFuchsiaResourceDialect,
14341            >,
14342            offset: usize,
14343            mut depth: fidl::encoding::Depth,
14344        ) -> fidl::Result<()> {
14345            decoder.debug_check_bounds::<Self>(offset);
14346            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14347                None => return Err(fidl::Error::NotNullable),
14348                Some(len) => len,
14349            };
14350            // Calling decoder.out_of_line_offset(0) is not allowed.
14351            if len == 0 {
14352                return Ok(());
14353            };
14354            depth.increment()?;
14355            let envelope_size = 8;
14356            let bytes_len = len * envelope_size;
14357            let offset = decoder.out_of_line_offset(bytes_len)?;
14358            // Decode the envelope for each type.
14359            let mut _next_ordinal_to_read = 0;
14360            let mut next_offset = offset;
14361            let end_offset = offset + bytes_len;
14362            _next_ordinal_to_read += 1;
14363            if next_offset >= end_offset {
14364                return Ok(());
14365            }
14366
14367            // Decode unknown envelopes for gaps in ordinals.
14368            while _next_ordinal_to_read < 1 {
14369                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14370                _next_ordinal_to_read += 1;
14371                next_offset += envelope_size;
14372            }
14373
14374            let next_out_of_line = decoder.next_out_of_line();
14375            let handles_before = decoder.remaining_handles();
14376            if let Some((inlined, num_bytes, num_handles)) =
14377                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14378            {
14379                let member_inline_size = <fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14380                if inlined != (member_inline_size <= 4) {
14381                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14382                }
14383                let inner_offset;
14384                let mut inner_depth = depth.clone();
14385                if inlined {
14386                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14387                    inner_offset = next_offset;
14388                } else {
14389                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14390                    inner_depth.increment()?;
14391                }
14392                let val_ref = self.parameters.get_or_insert_with(|| {
14393                    fidl::new_empty!(
14394                        fidl_fuchsia_bluetooth::ChannelParameters,
14395                        fidl::encoding::DefaultFuchsiaResourceDialect
14396                    )
14397                });
14398                fidl::decode!(
14399                    fidl_fuchsia_bluetooth::ChannelParameters,
14400                    fidl::encoding::DefaultFuchsiaResourceDialect,
14401                    val_ref,
14402                    decoder,
14403                    inner_offset,
14404                    inner_depth
14405                )?;
14406                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14407                {
14408                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14409                }
14410                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14411                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14412                }
14413            }
14414
14415            next_offset += envelope_size;
14416            _next_ordinal_to_read += 1;
14417            if next_offset >= end_offset {
14418                return Ok(());
14419            }
14420
14421            // Decode unknown envelopes for gaps in ordinals.
14422            while _next_ordinal_to_read < 2 {
14423                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14424                _next_ordinal_to_read += 1;
14425                next_offset += envelope_size;
14426            }
14427
14428            let next_out_of_line = decoder.next_out_of_line();
14429            let handles_before = decoder.remaining_handles();
14430            if let Some((inlined, num_bytes, num_handles)) =
14431                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14432            {
14433                let member_inline_size = <fidl::encoding::Endpoint<
14434                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14435                > as fidl::encoding::TypeMarker>::inline_size(
14436                    decoder.context
14437                );
14438                if inlined != (member_inline_size <= 4) {
14439                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14440                }
14441                let inner_offset;
14442                let mut inner_depth = depth.clone();
14443                if inlined {
14444                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14445                    inner_offset = next_offset;
14446                } else {
14447                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14448                    inner_depth.increment()?;
14449                }
14450                let val_ref = self.channel.get_or_insert_with(|| {
14451                    fidl::new_empty!(
14452                        fidl::encoding::Endpoint<
14453                            fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14454                        >,
14455                        fidl::encoding::DefaultFuchsiaResourceDialect
14456                    )
14457                });
14458                fidl::decode!(
14459                    fidl::encoding::Endpoint<
14460                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14461                    >,
14462                    fidl::encoding::DefaultFuchsiaResourceDialect,
14463                    val_ref,
14464                    decoder,
14465                    inner_offset,
14466                    inner_depth
14467                )?;
14468                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14469                {
14470                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14471                }
14472                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14473                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14474                }
14475            }
14476
14477            next_offset += envelope_size;
14478            _next_ordinal_to_read += 1;
14479            if next_offset >= end_offset {
14480                return Ok(());
14481            }
14482
14483            // Decode unknown envelopes for gaps in ordinals.
14484            while _next_ordinal_to_read < 3 {
14485                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14486                _next_ordinal_to_read += 1;
14487                next_offset += envelope_size;
14488            }
14489
14490            let next_out_of_line = decoder.next_out_of_line();
14491            let handles_before = decoder.remaining_handles();
14492            if let Some((inlined, num_bytes, num_handles)) =
14493                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14494            {
14495                let member_inline_size =
14496                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14497                if inlined != (member_inline_size <= 4) {
14498                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14499                }
14500                let inner_offset;
14501                let mut inner_depth = depth.clone();
14502                if inlined {
14503                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14504                    inner_offset = next_offset;
14505                } else {
14506                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14507                    inner_depth.increment()?;
14508                }
14509                let val_ref = self.psm.get_or_insert_with(|| {
14510                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
14511                });
14512                fidl::decode!(
14513                    u16,
14514                    fidl::encoding::DefaultFuchsiaResourceDialect,
14515                    val_ref,
14516                    decoder,
14517                    inner_offset,
14518                    inner_depth
14519                )?;
14520                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14521                {
14522                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14523                }
14524                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14525                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14526                }
14527            }
14528
14529            next_offset += envelope_size;
14530
14531            // Decode the remaining unknown envelopes.
14532            while next_offset < end_offset {
14533                _next_ordinal_to_read += 1;
14534                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14535                next_offset += envelope_size;
14536            }
14537
14538            Ok(())
14539        }
14540    }
14541}