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 ChannelListenerRegistryListenL2capRequest {
126    /// Accepted parameters for the local side of the channel.
127    pub parameters: Option<AcceptedChannelParameters>,
128    /// The channel listener protocol to open.
129    pub listener: Option<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
130    #[doc(hidden)]
131    pub __source_breaking: fidl::marker::SourceBreaking,
132}
133
134impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
135    for ChannelListenerRegistryListenL2capRequest
136{
137}
138
139#[derive(Debug, Default, PartialEq)]
140pub struct CisRequestedParameters {
141    /// ID selected to uniquely identify a stream within a CIG. All `cis_id`s
142    /// must be distinct within a single creation request.
143    /// Required.
144    pub cis_id: Option<u8>,
145    /// The channel that will be used for operations on the stream.
146    /// Required.
147    pub connection_stream: Option<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
148    /// Maximum SDU size (central => peripheral). This is a function of the
149    /// codec being used. Unidirectional streams should set the unused
150    /// direction to 0.
151    /// Optional. If not provided, a value of 0 will be used (unidirectional)
152    pub max_sdu_size_outgoing: Option<u16>,
153    /// Maximum SDU size (peripheral => central). This is a function of the
154    /// codec being used. Unidirectional streams should set the unused
155    /// direction to 0.
156    /// Optional. If not provided, a value of 0 will be used (unidirectional)
157    pub max_sdu_size_incoming: Option<u16>,
158    #[doc(hidden)]
159    pub __source_breaking: fidl::marker::SourceBreaking,
160}
161
162impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CisRequestedParameters {}
163
164#[derive(Debug, Default, PartialEq)]
165pub struct ConnectionAcceptCisRequest {
166    /// Identifier of the CIG that contains the requested CIS. Required.
167    pub cig_id: Option<u8>,
168    /// Identifier of the requested CIS. Required.
169    pub cis_id: Option<u8>,
170    /// When the stream is established, the server will invoke
171    /// IsochronousStream::OnCisEstablished() on this channel. Required.
172    ///
173    /// If the client end of this channel is closed, requests of the corresponding CIG/CIS
174    /// combination will be rejected until/unless another call is made to AcceptCis() with
175    /// the same CIG/CIS parameters.
176    pub connection_stream: Option<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
177    #[doc(hidden)]
178    pub __source_breaking: fidl::marker::SourceBreaking,
179}
180
181impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
182    for ConnectionAcceptCisRequest
183{
184}
185
186#[derive(Debug, Default, PartialEq)]
187pub struct ConnectionConnectL2capRequest {
188    /// Parameters for the local side of the channel.
189    pub parameters: Option<fidl_fuchsia_bluetooth::ChannelParameters>,
190    /// The channel protocol to open.
191    pub channel: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>>,
192    /// The PSM of the remote side to connect to.
193    pub psm: Option<u16>,
194    #[doc(hidden)]
195    pub __source_breaking: fidl::marker::SourceBreaking,
196}
197
198impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
199    for ConnectionConnectL2capRequest
200{
201}
202
203#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
204pub struct AdvertisedPeripheralMarker;
205
206impl fidl::endpoints::ProtocolMarker for AdvertisedPeripheralMarker {
207    type Proxy = AdvertisedPeripheralProxy;
208    type RequestStream = AdvertisedPeripheralRequestStream;
209    #[cfg(target_os = "fuchsia")]
210    type SynchronousProxy = AdvertisedPeripheralSynchronousProxy;
211
212    const DEBUG_NAME: &'static str = "(anonymous) AdvertisedPeripheral";
213}
214
215pub trait AdvertisedPeripheralProxyInterface: Send + Sync {
216    type OnConnectedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
217    fn r#on_connected(
218        &self,
219        peer: &Peer,
220        connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
221    ) -> Self::OnConnectedResponseFut;
222}
223#[derive(Debug)]
224#[cfg(target_os = "fuchsia")]
225pub struct AdvertisedPeripheralSynchronousProxy {
226    client: fidl::client::sync::Client,
227}
228
229#[cfg(target_os = "fuchsia")]
230impl fidl::endpoints::SynchronousProxy for AdvertisedPeripheralSynchronousProxy {
231    type Proxy = AdvertisedPeripheralProxy;
232    type Protocol = AdvertisedPeripheralMarker;
233
234    fn from_channel(inner: fidl::Channel) -> Self {
235        Self::new(inner)
236    }
237
238    fn into_channel(self) -> fidl::Channel {
239        self.client.into_channel()
240    }
241
242    fn as_channel(&self) -> &fidl::Channel {
243        self.client.as_channel()
244    }
245}
246
247#[cfg(target_os = "fuchsia")]
248impl AdvertisedPeripheralSynchronousProxy {
249    pub fn new(channel: fidl::Channel) -> Self {
250        let protocol_name =
251            <AdvertisedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
252        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
253    }
254
255    pub fn into_channel(self) -> fidl::Channel {
256        self.client.into_channel()
257    }
258
259    /// Waits until an event arrives and returns it. It is safe for other
260    /// threads to make concurrent requests while waiting for an event.
261    pub fn wait_for_event(
262        &self,
263        deadline: zx::MonotonicInstant,
264    ) -> Result<AdvertisedPeripheralEvent, fidl::Error> {
265        AdvertisedPeripheralEvent::decode(self.client.wait_for_event(deadline)?)
266    }
267
268    /// Called when a remote LE central connects to this peripheral when
269    /// connectable advertising is enabled via
270    /// [`fuchsia.bluetooth.le/Peripheral.Advertise`]. When this call is made,
271    /// the system has paused advertising, and will not continue until it
272    /// receives a response.
273    ///
274    /// The returned [`fuchsia.bluetooth.le/Connection`] protocol can be used to
275    /// interact with the peer. It also represents a peripheral's ownership over
276    /// the connection: the client can drop the protocol to request a
277    /// disconnection. Similarly, the protocol is closed by the system to
278    /// indicate that the connection to the peer has been lost.
279    ///
280    /// + request `peer` Information about the central that initiated the
281    ///   connection.
282    /// + request `connection` Represents the connection.
283    /// - response An empty response should be sent to acknowledge the
284    ///   connection and resume advertising (for flow control).
285    pub fn r#on_connected(
286        &self,
287        mut peer: &Peer,
288        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
289        ___deadline: zx::MonotonicInstant,
290    ) -> Result<(), fidl::Error> {
291        let _response = self
292            .client
293            .send_query::<AdvertisedPeripheralOnConnectedRequest, fidl::encoding::EmptyPayload>(
294                (peer, connection),
295                0x607b7716457eb178,
296                fidl::encoding::DynamicFlags::empty(),
297                ___deadline,
298            )?;
299        Ok(_response)
300    }
301}
302
303#[cfg(target_os = "fuchsia")]
304impl From<AdvertisedPeripheralSynchronousProxy> for zx::Handle {
305    fn from(value: AdvertisedPeripheralSynchronousProxy) -> Self {
306        value.into_channel().into()
307    }
308}
309
310#[cfg(target_os = "fuchsia")]
311impl From<fidl::Channel> for AdvertisedPeripheralSynchronousProxy {
312    fn from(value: fidl::Channel) -> Self {
313        Self::new(value)
314    }
315}
316
317#[cfg(target_os = "fuchsia")]
318impl fidl::endpoints::FromClient for AdvertisedPeripheralSynchronousProxy {
319    type Protocol = AdvertisedPeripheralMarker;
320
321    fn from_client(value: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>) -> Self {
322        Self::new(value.into_channel())
323    }
324}
325
326#[derive(Debug, Clone)]
327pub struct AdvertisedPeripheralProxy {
328    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
329}
330
331impl fidl::endpoints::Proxy for AdvertisedPeripheralProxy {
332    type Protocol = AdvertisedPeripheralMarker;
333
334    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
335        Self::new(inner)
336    }
337
338    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
339        self.client.into_channel().map_err(|client| Self { client })
340    }
341
342    fn as_channel(&self) -> &::fidl::AsyncChannel {
343        self.client.as_channel()
344    }
345}
346
347impl AdvertisedPeripheralProxy {
348    /// Create a new Proxy for fuchsia.bluetooth.le/AdvertisedPeripheral.
349    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
350        let protocol_name =
351            <AdvertisedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
352        Self { client: fidl::client::Client::new(channel, protocol_name) }
353    }
354
355    /// Get a Stream of events from the remote end of the protocol.
356    ///
357    /// # Panics
358    ///
359    /// Panics if the event stream was already taken.
360    pub fn take_event_stream(&self) -> AdvertisedPeripheralEventStream {
361        AdvertisedPeripheralEventStream { event_receiver: self.client.take_event_receiver() }
362    }
363
364    /// Called when a remote LE central connects to this peripheral when
365    /// connectable advertising is enabled via
366    /// [`fuchsia.bluetooth.le/Peripheral.Advertise`]. When this call is made,
367    /// the system has paused advertising, and will not continue until it
368    /// receives a response.
369    ///
370    /// The returned [`fuchsia.bluetooth.le/Connection`] protocol can be used to
371    /// interact with the peer. It also represents a peripheral's ownership over
372    /// the connection: the client can drop the protocol to request a
373    /// disconnection. Similarly, the protocol is closed by the system to
374    /// indicate that the connection to the peer has been lost.
375    ///
376    /// + request `peer` Information about the central that initiated the
377    ///   connection.
378    /// + request `connection` Represents the connection.
379    /// - response An empty response should be sent to acknowledge the
380    ///   connection and resume advertising (for flow control).
381    pub fn r#on_connected(
382        &self,
383        mut peer: &Peer,
384        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
385    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
386        AdvertisedPeripheralProxyInterface::r#on_connected(self, peer, connection)
387    }
388}
389
390impl AdvertisedPeripheralProxyInterface for AdvertisedPeripheralProxy {
391    type OnConnectedResponseFut =
392        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
393    fn r#on_connected(
394        &self,
395        mut peer: &Peer,
396        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
397    ) -> Self::OnConnectedResponseFut {
398        fn _decode(
399            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
400        ) -> Result<(), fidl::Error> {
401            let _response = fidl::client::decode_transaction_body::<
402                fidl::encoding::EmptyPayload,
403                fidl::encoding::DefaultFuchsiaResourceDialect,
404                0x607b7716457eb178,
405            >(_buf?)?;
406            Ok(_response)
407        }
408        self.client.send_query_and_decode::<AdvertisedPeripheralOnConnectedRequest, ()>(
409            (peer, connection),
410            0x607b7716457eb178,
411            fidl::encoding::DynamicFlags::empty(),
412            _decode,
413        )
414    }
415}
416
417pub struct AdvertisedPeripheralEventStream {
418    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
419}
420
421impl std::marker::Unpin for AdvertisedPeripheralEventStream {}
422
423impl futures::stream::FusedStream for AdvertisedPeripheralEventStream {
424    fn is_terminated(&self) -> bool {
425        self.event_receiver.is_terminated()
426    }
427}
428
429impl futures::Stream for AdvertisedPeripheralEventStream {
430    type Item = Result<AdvertisedPeripheralEvent, fidl::Error>;
431
432    fn poll_next(
433        mut self: std::pin::Pin<&mut Self>,
434        cx: &mut std::task::Context<'_>,
435    ) -> std::task::Poll<Option<Self::Item>> {
436        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
437            &mut self.event_receiver,
438            cx
439        )?) {
440            Some(buf) => std::task::Poll::Ready(Some(AdvertisedPeripheralEvent::decode(buf))),
441            None => std::task::Poll::Ready(None),
442        }
443    }
444}
445
446#[derive(Debug)]
447pub enum AdvertisedPeripheralEvent {}
448
449impl AdvertisedPeripheralEvent {
450    /// Decodes a message buffer as a [`AdvertisedPeripheralEvent`].
451    fn decode(
452        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
453    ) -> Result<AdvertisedPeripheralEvent, fidl::Error> {
454        let (bytes, _handles) = buf.split_mut();
455        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
456        debug_assert_eq!(tx_header.tx_id, 0);
457        match tx_header.ordinal {
458            _ => Err(fidl::Error::UnknownOrdinal {
459                ordinal: tx_header.ordinal,
460                protocol_name:
461                    <AdvertisedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
462            }),
463        }
464    }
465}
466
467/// A Stream of incoming requests for fuchsia.bluetooth.le/AdvertisedPeripheral.
468pub struct AdvertisedPeripheralRequestStream {
469    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
470    is_terminated: bool,
471}
472
473impl std::marker::Unpin for AdvertisedPeripheralRequestStream {}
474
475impl futures::stream::FusedStream for AdvertisedPeripheralRequestStream {
476    fn is_terminated(&self) -> bool {
477        self.is_terminated
478    }
479}
480
481impl fidl::endpoints::RequestStream for AdvertisedPeripheralRequestStream {
482    type Protocol = AdvertisedPeripheralMarker;
483    type ControlHandle = AdvertisedPeripheralControlHandle;
484
485    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
486        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
487    }
488
489    fn control_handle(&self) -> Self::ControlHandle {
490        AdvertisedPeripheralControlHandle { inner: self.inner.clone() }
491    }
492
493    fn into_inner(
494        self,
495    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
496    {
497        (self.inner, self.is_terminated)
498    }
499
500    fn from_inner(
501        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
502        is_terminated: bool,
503    ) -> Self {
504        Self { inner, is_terminated }
505    }
506}
507
508impl futures::Stream for AdvertisedPeripheralRequestStream {
509    type Item = Result<AdvertisedPeripheralRequest, fidl::Error>;
510
511    fn poll_next(
512        mut self: std::pin::Pin<&mut Self>,
513        cx: &mut std::task::Context<'_>,
514    ) -> std::task::Poll<Option<Self::Item>> {
515        let this = &mut *self;
516        if this.inner.check_shutdown(cx) {
517            this.is_terminated = true;
518            return std::task::Poll::Ready(None);
519        }
520        if this.is_terminated {
521            panic!("polled AdvertisedPeripheralRequestStream after completion");
522        }
523        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
524            |bytes, handles| {
525                match this.inner.channel().read_etc(cx, bytes, handles) {
526                    std::task::Poll::Ready(Ok(())) => {}
527                    std::task::Poll::Pending => return std::task::Poll::Pending,
528                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
529                        this.is_terminated = true;
530                        return std::task::Poll::Ready(None);
531                    }
532                    std::task::Poll::Ready(Err(e)) => {
533                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
534                            e.into(),
535                        ))))
536                    }
537                }
538
539                // A message has been received from the channel
540                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
541
542                std::task::Poll::Ready(Some(match header.ordinal {
543                0x607b7716457eb178 => {
544                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
545                    let mut req = fidl::new_empty!(AdvertisedPeripheralOnConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
546                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AdvertisedPeripheralOnConnectedRequest>(&header, _body_bytes, handles, &mut req)?;
547                    let control_handle = AdvertisedPeripheralControlHandle {
548                        inner: this.inner.clone(),
549                    };
550                    Ok(AdvertisedPeripheralRequest::OnConnected {peer: req.peer,
551connection: req.connection,
552
553                        responder: AdvertisedPeripheralOnConnectedResponder {
554                            control_handle: std::mem::ManuallyDrop::new(control_handle),
555                            tx_id: header.tx_id,
556                        },
557                    })
558                }
559                _ => Err(fidl::Error::UnknownOrdinal {
560                    ordinal: header.ordinal,
561                    protocol_name: <AdvertisedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
562                }),
563            }))
564            },
565        )
566    }
567}
568
569/// Protocol that is valid for the duration of advertising. The caller can close
570/// the protocol to stop advertising. If the system internally stops advertising
571/// for any reason, the protocol will be closed to communicate this to the
572/// client.
573#[derive(Debug)]
574pub enum AdvertisedPeripheralRequest {
575    /// Called when a remote LE central connects to this peripheral when
576    /// connectable advertising is enabled via
577    /// [`fuchsia.bluetooth.le/Peripheral.Advertise`]. When this call is made,
578    /// the system has paused advertising, and will not continue until it
579    /// receives a response.
580    ///
581    /// The returned [`fuchsia.bluetooth.le/Connection`] protocol can be used to
582    /// interact with the peer. It also represents a peripheral's ownership over
583    /// the connection: the client can drop the protocol to request a
584    /// disconnection. Similarly, the protocol is closed by the system to
585    /// indicate that the connection to the peer has been lost.
586    ///
587    /// + request `peer` Information about the central that initiated the
588    ///   connection.
589    /// + request `connection` Represents the connection.
590    /// - response An empty response should be sent to acknowledge the
591    ///   connection and resume advertising (for flow control).
592    OnConnected {
593        peer: Peer,
594        connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
595        responder: AdvertisedPeripheralOnConnectedResponder,
596    },
597}
598
599impl AdvertisedPeripheralRequest {
600    #[allow(irrefutable_let_patterns)]
601    pub fn into_on_connected(
602        self,
603    ) -> Option<(
604        Peer,
605        fidl::endpoints::ClientEnd<ConnectionMarker>,
606        AdvertisedPeripheralOnConnectedResponder,
607    )> {
608        if let AdvertisedPeripheralRequest::OnConnected { peer, connection, responder } = self {
609            Some((peer, connection, responder))
610        } else {
611            None
612        }
613    }
614
615    /// Name of the method defined in FIDL
616    pub fn method_name(&self) -> &'static str {
617        match *self {
618            AdvertisedPeripheralRequest::OnConnected { .. } => "on_connected",
619        }
620    }
621}
622
623#[derive(Debug, Clone)]
624pub struct AdvertisedPeripheralControlHandle {
625    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
626}
627
628impl fidl::endpoints::ControlHandle for AdvertisedPeripheralControlHandle {
629    fn shutdown(&self) {
630        self.inner.shutdown()
631    }
632    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
633        self.inner.shutdown_with_epitaph(status)
634    }
635
636    fn is_closed(&self) -> bool {
637        self.inner.channel().is_closed()
638    }
639    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
640        self.inner.channel().on_closed()
641    }
642
643    #[cfg(target_os = "fuchsia")]
644    fn signal_peer(
645        &self,
646        clear_mask: zx::Signals,
647        set_mask: zx::Signals,
648    ) -> Result<(), zx_status::Status> {
649        use fidl::Peered;
650        self.inner.channel().signal_peer(clear_mask, set_mask)
651    }
652}
653
654impl AdvertisedPeripheralControlHandle {}
655
656#[must_use = "FIDL methods require a response to be sent"]
657#[derive(Debug)]
658pub struct AdvertisedPeripheralOnConnectedResponder {
659    control_handle: std::mem::ManuallyDrop<AdvertisedPeripheralControlHandle>,
660    tx_id: u32,
661}
662
663/// Set the the channel to be shutdown (see [`AdvertisedPeripheralControlHandle::shutdown`])
664/// if the responder is dropped without sending a response, so that the client
665/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
666impl std::ops::Drop for AdvertisedPeripheralOnConnectedResponder {
667    fn drop(&mut self) {
668        self.control_handle.shutdown();
669        // Safety: drops once, never accessed again
670        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
671    }
672}
673
674impl fidl::endpoints::Responder for AdvertisedPeripheralOnConnectedResponder {
675    type ControlHandle = AdvertisedPeripheralControlHandle;
676
677    fn control_handle(&self) -> &AdvertisedPeripheralControlHandle {
678        &self.control_handle
679    }
680
681    fn drop_without_shutdown(mut self) {
682        // Safety: drops once, never accessed again due to mem::forget
683        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
684        // Prevent Drop from running (which would shut down the channel)
685        std::mem::forget(self);
686    }
687}
688
689impl AdvertisedPeripheralOnConnectedResponder {
690    /// Sends a response to the FIDL transaction.
691    ///
692    /// Sets the channel to shutdown if an error occurs.
693    pub fn send(self) -> Result<(), fidl::Error> {
694        let _result = self.send_raw();
695        if _result.is_err() {
696            self.control_handle.shutdown();
697        }
698        self.drop_without_shutdown();
699        _result
700    }
701
702    /// Similar to "send" but does not shutdown the channel if an error occurs.
703    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
704        let _result = self.send_raw();
705        self.drop_without_shutdown();
706        _result
707    }
708
709    fn send_raw(&self) -> Result<(), fidl::Error> {
710        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
711            (),
712            self.tx_id,
713            0x607b7716457eb178,
714            fidl::encoding::DynamicFlags::empty(),
715        )
716    }
717}
718
719#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
720pub struct AdvertisingHandleMarker;
721
722impl fidl::endpoints::ProtocolMarker for AdvertisingHandleMarker {
723    type Proxy = AdvertisingHandleProxy;
724    type RequestStream = AdvertisingHandleRequestStream;
725    #[cfg(target_os = "fuchsia")]
726    type SynchronousProxy = AdvertisingHandleSynchronousProxy;
727
728    const DEBUG_NAME: &'static str = "(anonymous) AdvertisingHandle";
729}
730
731pub trait AdvertisingHandleProxyInterface: Send + Sync {}
732#[derive(Debug)]
733#[cfg(target_os = "fuchsia")]
734pub struct AdvertisingHandleSynchronousProxy {
735    client: fidl::client::sync::Client,
736}
737
738#[cfg(target_os = "fuchsia")]
739impl fidl::endpoints::SynchronousProxy for AdvertisingHandleSynchronousProxy {
740    type Proxy = AdvertisingHandleProxy;
741    type Protocol = AdvertisingHandleMarker;
742
743    fn from_channel(inner: fidl::Channel) -> Self {
744        Self::new(inner)
745    }
746
747    fn into_channel(self) -> fidl::Channel {
748        self.client.into_channel()
749    }
750
751    fn as_channel(&self) -> &fidl::Channel {
752        self.client.as_channel()
753    }
754}
755
756#[cfg(target_os = "fuchsia")]
757impl AdvertisingHandleSynchronousProxy {
758    pub fn new(channel: fidl::Channel) -> Self {
759        let protocol_name =
760            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
761        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
762    }
763
764    pub fn into_channel(self) -> fidl::Channel {
765        self.client.into_channel()
766    }
767
768    /// Waits until an event arrives and returns it. It is safe for other
769    /// threads to make concurrent requests while waiting for an event.
770    pub fn wait_for_event(
771        &self,
772        deadline: zx::MonotonicInstant,
773    ) -> Result<AdvertisingHandleEvent, fidl::Error> {
774        AdvertisingHandleEvent::decode(self.client.wait_for_event(deadline)?)
775    }
776}
777
778#[cfg(target_os = "fuchsia")]
779impl From<AdvertisingHandleSynchronousProxy> for zx::Handle {
780    fn from(value: AdvertisingHandleSynchronousProxy) -> Self {
781        value.into_channel().into()
782    }
783}
784
785#[cfg(target_os = "fuchsia")]
786impl From<fidl::Channel> for AdvertisingHandleSynchronousProxy {
787    fn from(value: fidl::Channel) -> Self {
788        Self::new(value)
789    }
790}
791
792#[cfg(target_os = "fuchsia")]
793impl fidl::endpoints::FromClient for AdvertisingHandleSynchronousProxy {
794    type Protocol = AdvertisingHandleMarker;
795
796    fn from_client(value: fidl::endpoints::ClientEnd<AdvertisingHandleMarker>) -> Self {
797        Self::new(value.into_channel())
798    }
799}
800
801#[derive(Debug, Clone)]
802pub struct AdvertisingHandleProxy {
803    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
804}
805
806impl fidl::endpoints::Proxy for AdvertisingHandleProxy {
807    type Protocol = AdvertisingHandleMarker;
808
809    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
810        Self::new(inner)
811    }
812
813    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
814        self.client.into_channel().map_err(|client| Self { client })
815    }
816
817    fn as_channel(&self) -> &::fidl::AsyncChannel {
818        self.client.as_channel()
819    }
820}
821
822impl AdvertisingHandleProxy {
823    /// Create a new Proxy for fuchsia.bluetooth.le/AdvertisingHandle.
824    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
825        let protocol_name =
826            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
827        Self { client: fidl::client::Client::new(channel, protocol_name) }
828    }
829
830    /// Get a Stream of events from the remote end of the protocol.
831    ///
832    /// # Panics
833    ///
834    /// Panics if the event stream was already taken.
835    pub fn take_event_stream(&self) -> AdvertisingHandleEventStream {
836        AdvertisingHandleEventStream { event_receiver: self.client.take_event_receiver() }
837    }
838}
839
840impl AdvertisingHandleProxyInterface for AdvertisingHandleProxy {}
841
842pub struct AdvertisingHandleEventStream {
843    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
844}
845
846impl std::marker::Unpin for AdvertisingHandleEventStream {}
847
848impl futures::stream::FusedStream for AdvertisingHandleEventStream {
849    fn is_terminated(&self) -> bool {
850        self.event_receiver.is_terminated()
851    }
852}
853
854impl futures::Stream for AdvertisingHandleEventStream {
855    type Item = Result<AdvertisingHandleEvent, fidl::Error>;
856
857    fn poll_next(
858        mut self: std::pin::Pin<&mut Self>,
859        cx: &mut std::task::Context<'_>,
860    ) -> std::task::Poll<Option<Self::Item>> {
861        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
862            &mut self.event_receiver,
863            cx
864        )?) {
865            Some(buf) => std::task::Poll::Ready(Some(AdvertisingHandleEvent::decode(buf))),
866            None => std::task::Poll::Ready(None),
867        }
868    }
869}
870
871#[derive(Debug)]
872pub enum AdvertisingHandleEvent {}
873
874impl AdvertisingHandleEvent {
875    /// Decodes a message buffer as a [`AdvertisingHandleEvent`].
876    fn decode(
877        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
878    ) -> Result<AdvertisingHandleEvent, fidl::Error> {
879        let (bytes, _handles) = buf.split_mut();
880        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
881        debug_assert_eq!(tx_header.tx_id, 0);
882        match tx_header.ordinal {
883            _ => Err(fidl::Error::UnknownOrdinal {
884                ordinal: tx_header.ordinal,
885                protocol_name:
886                    <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
887            }),
888        }
889    }
890}
891
892/// A Stream of incoming requests for fuchsia.bluetooth.le/AdvertisingHandle.
893pub struct AdvertisingHandleRequestStream {
894    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
895    is_terminated: bool,
896}
897
898impl std::marker::Unpin for AdvertisingHandleRequestStream {}
899
900impl futures::stream::FusedStream for AdvertisingHandleRequestStream {
901    fn is_terminated(&self) -> bool {
902        self.is_terminated
903    }
904}
905
906impl fidl::endpoints::RequestStream for AdvertisingHandleRequestStream {
907    type Protocol = AdvertisingHandleMarker;
908    type ControlHandle = AdvertisingHandleControlHandle;
909
910    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
911        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
912    }
913
914    fn control_handle(&self) -> Self::ControlHandle {
915        AdvertisingHandleControlHandle { inner: self.inner.clone() }
916    }
917
918    fn into_inner(
919        self,
920    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
921    {
922        (self.inner, self.is_terminated)
923    }
924
925    fn from_inner(
926        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
927        is_terminated: bool,
928    ) -> Self {
929        Self { inner, is_terminated }
930    }
931}
932
933impl futures::Stream for AdvertisingHandleRequestStream {
934    type Item = Result<AdvertisingHandleRequest, fidl::Error>;
935
936    fn poll_next(
937        mut self: std::pin::Pin<&mut Self>,
938        cx: &mut std::task::Context<'_>,
939    ) -> std::task::Poll<Option<Self::Item>> {
940        let this = &mut *self;
941        if this.inner.check_shutdown(cx) {
942            this.is_terminated = true;
943            return std::task::Poll::Ready(None);
944        }
945        if this.is_terminated {
946            panic!("polled AdvertisingHandleRequestStream after completion");
947        }
948        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
949            |bytes, handles| {
950                match this.inner.channel().read_etc(cx, bytes, handles) {
951                    std::task::Poll::Ready(Ok(())) => {}
952                    std::task::Poll::Pending => return std::task::Poll::Pending,
953                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
954                        this.is_terminated = true;
955                        return std::task::Poll::Ready(None);
956                    }
957                    std::task::Poll::Ready(Err(e)) => {
958                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
959                            e.into(),
960                        ))))
961                    }
962                }
963
964                // A message has been received from the channel
965                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
966
967                std::task::Poll::Ready(Some(match header.ordinal {
968                    _ => Err(fidl::Error::UnknownOrdinal {
969                        ordinal: header.ordinal,
970                        protocol_name:
971                            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
972                    }),
973                }))
974            },
975        )
976    }
977}
978
979/// Capability that is valid for the duration of advertising. The caller can close the handle to
980/// stop advertising. If the system internally stops advertising for any reason, the handle will be
981/// closed to communicate this to the client.
982#[derive(Debug)]
983pub enum AdvertisingHandleRequest {}
984
985impl AdvertisingHandleRequest {
986    /// Name of the method defined in FIDL
987    pub fn method_name(&self) -> &'static str {
988        match *self {}
989    }
990}
991
992#[derive(Debug, Clone)]
993pub struct AdvertisingHandleControlHandle {
994    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
995}
996
997impl fidl::endpoints::ControlHandle for AdvertisingHandleControlHandle {
998    fn shutdown(&self) {
999        self.inner.shutdown()
1000    }
1001    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1002        self.inner.shutdown_with_epitaph(status)
1003    }
1004
1005    fn is_closed(&self) -> bool {
1006        self.inner.channel().is_closed()
1007    }
1008    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1009        self.inner.channel().on_closed()
1010    }
1011
1012    #[cfg(target_os = "fuchsia")]
1013    fn signal_peer(
1014        &self,
1015        clear_mask: zx::Signals,
1016        set_mask: zx::Signals,
1017    ) -> Result<(), zx_status::Status> {
1018        use fidl::Peered;
1019        self.inner.channel().signal_peer(clear_mask, set_mask)
1020    }
1021}
1022
1023impl AdvertisingHandleControlHandle {}
1024
1025#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1026pub struct CentralMarker;
1027
1028impl fidl::endpoints::ProtocolMarker for CentralMarker {
1029    type Proxy = CentralProxy;
1030    type RequestStream = CentralRequestStream;
1031    #[cfg(target_os = "fuchsia")]
1032    type SynchronousProxy = CentralSynchronousProxy;
1033
1034    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.Central";
1035}
1036impl fidl::endpoints::DiscoverableProtocolMarker for CentralMarker {}
1037pub type CentralCreateConnectedIsochronousGroupResult =
1038    Result<CentralCreateConnectedIsochronousGroupResponse, CreateCigError>;
1039
1040pub trait CentralProxyInterface: Send + Sync {
1041    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
1042        + Send;
1043    fn r#listen_l2cap(
1044        &self,
1045        payload: ChannelListenerRegistryListenL2capRequest,
1046    ) -> Self::ListenL2capResponseFut;
1047    type ScanResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1048    fn r#scan(
1049        &self,
1050        options: &ScanOptions,
1051        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1052    ) -> Self::ScanResponseFut;
1053    fn r#connect(
1054        &self,
1055        id: &fidl_fuchsia_bluetooth::PeerId,
1056        options: &ConnectionOptions,
1057        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1058    ) -> Result<(), fidl::Error>;
1059    type CreateConnectedIsochronousGroupResponseFut: std::future::Future<
1060            Output = Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error>,
1061        > + Send;
1062    fn r#create_connected_isochronous_group(
1063        &self,
1064        payload: CentralCreateConnectedIsochronousGroupRequest,
1065    ) -> Self::CreateConnectedIsochronousGroupResponseFut;
1066    type GetPeripheralsResponseFut: std::future::Future<Output = Result<Vec<RemoteDevice>, fidl::Error>>
1067        + Send;
1068    fn r#get_peripherals(
1069        &self,
1070        service_uuids: Option<&[String]>,
1071    ) -> Self::GetPeripheralsResponseFut;
1072    type GetPeripheralResponseFut: std::future::Future<Output = Result<Option<Box<RemoteDevice>>, fidl::Error>>
1073        + Send;
1074    fn r#get_peripheral(&self, identifier: &str) -> Self::GetPeripheralResponseFut;
1075    type StartScanResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1076        + Send;
1077    fn r#start_scan(&self, filter: Option<&ScanFilter>) -> Self::StartScanResponseFut;
1078    fn r#stop_scan(&self) -> Result<(), fidl::Error>;
1079    type ConnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1080        + Send;
1081    fn r#connect_peripheral(
1082        &self,
1083        identifier: &str,
1084        options: &ConnectionOptions,
1085        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1086    ) -> Self::ConnectPeripheralResponseFut;
1087    type DisconnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1088        + Send;
1089    fn r#disconnect_peripheral(&self, identifier: &str) -> Self::DisconnectPeripheralResponseFut;
1090}
1091#[derive(Debug)]
1092#[cfg(target_os = "fuchsia")]
1093pub struct CentralSynchronousProxy {
1094    client: fidl::client::sync::Client,
1095}
1096
1097#[cfg(target_os = "fuchsia")]
1098impl fidl::endpoints::SynchronousProxy for CentralSynchronousProxy {
1099    type Proxy = CentralProxy;
1100    type Protocol = CentralMarker;
1101
1102    fn from_channel(inner: fidl::Channel) -> Self {
1103        Self::new(inner)
1104    }
1105
1106    fn into_channel(self) -> fidl::Channel {
1107        self.client.into_channel()
1108    }
1109
1110    fn as_channel(&self) -> &fidl::Channel {
1111        self.client.as_channel()
1112    }
1113}
1114
1115#[cfg(target_os = "fuchsia")]
1116impl CentralSynchronousProxy {
1117    pub fn new(channel: fidl::Channel) -> Self {
1118        let protocol_name = <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1119        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1120    }
1121
1122    pub fn into_channel(self) -> fidl::Channel {
1123        self.client.into_channel()
1124    }
1125
1126    /// Waits until an event arrives and returns it. It is safe for other
1127    /// threads to make concurrent requests while waiting for an event.
1128    pub fn wait_for_event(
1129        &self,
1130        deadline: zx::MonotonicInstant,
1131    ) -> Result<CentralEvent, fidl::Error> {
1132        CentralEvent::decode(self.client.wait_for_event(deadline)?)
1133    }
1134
1135    /// Register a listener for incoming channels. The registry will assign a
1136    /// PSM value that is unique for the local device, as well as open a
1137    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
1138    /// event that all PSMs have been assigned, this call will fail with
1139    /// `ZX_ERR_NO_RESOURCES`.
1140    ///
1141    /// Note that the method of service discovery or advertising is defined by
1142    /// the service or protocol, so it is the responsibility of the caller to
1143    /// communicate the assigned PSM to any clients.
1144    pub fn r#listen_l2cap(
1145        &self,
1146        mut payload: ChannelListenerRegistryListenL2capRequest,
1147        ___deadline: zx::MonotonicInstant,
1148    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
1149        let _response = self.client.send_query::<
1150            ChannelListenerRegistryListenL2capRequest,
1151            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
1152        >(
1153            &mut payload,
1154            0x39c6e9001d102338,
1155            fidl::encoding::DynamicFlags::empty(),
1156            ___deadline,
1157        )?;
1158        Ok(_response.map(|x| x))
1159    }
1160
1161    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
1162    /// initiated, then `result_watcher` will be closed with an epitaph.
1163    ///
1164    /// A Central client is allowed to have only one active scan at a time.
1165    /// Accordingly, only one Scan request can be outstanding at a time.
1166    /// Additional calls to Scan will fail.
1167    ///
1168    /// The lifetime of the scan session is tied to the `result_watcher`
1169    /// protocol provided. The scan will be stopped if the channel is closed.
1170    ///
1171    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
1172    /// can be used to watch for scan results.
1173    ///
1174    /// + request `options` Options used to configure the scan session.
1175    /// + request `result_watcher` Protocol that remains valid for the duration
1176    ///   of this scan session.
1177    /// - response An empty response will be sent to acknowledge the scan has
1178    ///   stopped.
1179    ///
1180    /// The following epitaphs may be sent by the server on error:
1181    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
1182    ///   protocol is only allowed 1 active scan.
1183    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
1184    ///   `ScanOptions` documentation.
1185    /// * error `INTERNAL`: An internal error occurred and a scan could not be
1186    ///   started.
1187    pub fn r#scan(
1188        &self,
1189        mut options: &ScanOptions,
1190        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1191        ___deadline: zx::MonotonicInstant,
1192    ) -> Result<(), fidl::Error> {
1193        let _response =
1194            self.client.send_query::<CentralScanRequest, fidl::encoding::EmptyPayload>(
1195                (options, result_watcher),
1196                0x41f7121798dfe15f,
1197                fidl::encoding::DynamicFlags::empty(),
1198                ___deadline,
1199            )?;
1200        Ok(_response)
1201    }
1202
1203    /// Connect to the peer with the given identifier.
1204    ///
1205    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
1206    /// client's interest on the LE connection to the peer. Closing the channel
1207    /// removes interest, but may not result in disconnection if another client
1208    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
1209    ///
1210    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
1211    /// system if the connection to the peer is lost or an error occurs.
1212    ///
1213    /// The following epitaphs may be sent by the server on error:
1214    /// + `INVALID_ARGS`: Some of the parameters are invalid.
1215    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
1216    ///                    Connection should be used.
1217    /// + `NOT_CONNECTED`: A connection could not be established.
1218    /// + `CONNECTION_RESET`: The peer disconnected.
1219    ///
1220    /// + request `id` Identifier of the peer to initiate a connection to.
1221    /// + request `options` Options used to configure the connection.
1222    /// + request `handle` Handle that remains valid for the duration of this
1223    ///   connection.
1224    pub fn r#connect(
1225        &self,
1226        mut id: &fidl_fuchsia_bluetooth::PeerId,
1227        mut options: &ConnectionOptions,
1228        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1229    ) -> Result<(), fidl::Error> {
1230        self.client.send::<CentralConnectRequest>(
1231            (id, options, handle),
1232            0x31a3065f2a6913c4,
1233            fidl::encoding::DynamicFlags::empty(),
1234        )
1235    }
1236
1237    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
1238    /// operation is only valid when operating in the Central role for a connection.
1239    ///
1240    /// If the Central channel is closed before the CIG is explicitly removed, the group will
1241    /// be removed and disconnected.
1242    ///
1243    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
1244    /// id allocated by the host.
1245    pub fn r#create_connected_isochronous_group(
1246        &self,
1247        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1248        ___deadline: zx::MonotonicInstant,
1249    ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
1250        let _response = self
1251            .client
1252            .send_query::<CentralCreateConnectedIsochronousGroupRequest, fidl::encoding::ResultType<
1253                CentralCreateConnectedIsochronousGroupResponse,
1254                CreateCigError,
1255            >>(
1256                &mut payload,
1257                0x60323e70ae22e13,
1258                fidl::encoding::DynamicFlags::empty(),
1259                ___deadline,
1260            )?;
1261        Ok(_response.map(|x| x))
1262    }
1263
1264    /// Returns the list of peripherals that are known to the system from previous scan, connection,
1265    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
1266    /// be present on the peripheral.
1267    ///
1268    /// This method only returns peripherals (i.e. connectable devices).
1269    pub fn r#get_peripherals(
1270        &self,
1271        mut service_uuids: Option<&[String]>,
1272        ___deadline: zx::MonotonicInstant,
1273    ) -> Result<Vec<RemoteDevice>, fidl::Error> {
1274        let _response =
1275            self.client.send_query::<CentralGetPeripheralsRequest, CentralGetPeripheralsResponse>(
1276                (service_uuids,),
1277                0x37ba777499c683a8,
1278                fidl::encoding::DynamicFlags::empty(),
1279                ___deadline,
1280            )?;
1281        Ok(_response.peripherals)
1282    }
1283
1284    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
1285    ///
1286    /// Returns information about a single peripheral that is known to the system from previous scan,
1287    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
1288    /// `identifier` is not recognized.
1289    pub fn r#get_peripheral(
1290        &self,
1291        mut identifier: &str,
1292        ___deadline: zx::MonotonicInstant,
1293    ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
1294        let _response =
1295            self.client.send_query::<CentralGetPeripheralRequest, CentralGetPeripheralResponse>(
1296                (identifier,),
1297                0x97f5a2f2d9c13da,
1298                fidl::encoding::DynamicFlags::empty(),
1299                ___deadline,
1300            )?;
1301        Ok(_response.peripheral)
1302    }
1303
1304    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
1305    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
1306    /// `filter` will replace the existing session's filter.
1307    ///
1308    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
1309    /// will be notified for all discoverable devices that are found. This is not recommended; clients
1310    /// should generally filter results by at least one of `filter.service_uuids`,
1311    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
1312    pub fn r#start_scan(
1313        &self,
1314        mut filter: Option<&ScanFilter>,
1315        ___deadline: zx::MonotonicInstant,
1316    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1317        let _response =
1318            self.client.send_query::<CentralStartScanRequest, CentralStartScanResponse>(
1319                (filter,),
1320                0xeb4cf0cd0e1132b,
1321                fidl::encoding::DynamicFlags::empty(),
1322                ___deadline,
1323            )?;
1324        Ok(_response.status)
1325    }
1326
1327    /// Terminate a previously started scan session.
1328    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1329        self.client.send::<fidl::encoding::EmptyPayload>(
1330            (),
1331            0x5f79ee6a0bb037a0,
1332            fidl::encoding::DynamicFlags::empty(),
1333        )
1334    }
1335
1336    /// Creates a connection to the peripheral device with the given identifier.
1337    /// Returns the status of the operation in `status`.
1338    ///
1339    /// On success, `gatt_client` will be bound and can be used for GATT client
1340    /// role procedures. On failure, `gatt_client` will be closed and `status` will
1341    /// indicate an error.
1342    pub fn r#connect_peripheral(
1343        &self,
1344        mut identifier: &str,
1345        mut options: &ConnectionOptions,
1346        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1347        ___deadline: zx::MonotonicInstant,
1348    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1349        let _response = self
1350            .client
1351            .send_query::<CentralConnectPeripheralRequest, CentralConnectPeripheralResponse>(
1352                (identifier, options, gatt_client),
1353                0x714d6c32d066d75a,
1354                fidl::encoding::DynamicFlags::empty(),
1355                ___deadline,
1356            )?;
1357        Ok(_response.status)
1358    }
1359
1360    /// Disconnects this Central's connection to the peripheral with the given identifier.
1361    pub fn r#disconnect_peripheral(
1362        &self,
1363        mut identifier: &str,
1364        ___deadline: zx::MonotonicInstant,
1365    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1366        let _response = self
1367            .client
1368            .send_query::<CentralDisconnectPeripheralRequest, CentralDisconnectPeripheralResponse>(
1369                (identifier,),
1370                0xa9430da197362fd,
1371                fidl::encoding::DynamicFlags::empty(),
1372                ___deadline,
1373            )?;
1374        Ok(_response.status)
1375    }
1376}
1377
1378#[cfg(target_os = "fuchsia")]
1379impl From<CentralSynchronousProxy> for zx::Handle {
1380    fn from(value: CentralSynchronousProxy) -> Self {
1381        value.into_channel().into()
1382    }
1383}
1384
1385#[cfg(target_os = "fuchsia")]
1386impl From<fidl::Channel> for CentralSynchronousProxy {
1387    fn from(value: fidl::Channel) -> Self {
1388        Self::new(value)
1389    }
1390}
1391
1392#[cfg(target_os = "fuchsia")]
1393impl fidl::endpoints::FromClient for CentralSynchronousProxy {
1394    type Protocol = CentralMarker;
1395
1396    fn from_client(value: fidl::endpoints::ClientEnd<CentralMarker>) -> Self {
1397        Self::new(value.into_channel())
1398    }
1399}
1400
1401#[derive(Debug, Clone)]
1402pub struct CentralProxy {
1403    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1404}
1405
1406impl fidl::endpoints::Proxy for CentralProxy {
1407    type Protocol = CentralMarker;
1408
1409    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1410        Self::new(inner)
1411    }
1412
1413    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1414        self.client.into_channel().map_err(|client| Self { client })
1415    }
1416
1417    fn as_channel(&self) -> &::fidl::AsyncChannel {
1418        self.client.as_channel()
1419    }
1420}
1421
1422impl CentralProxy {
1423    /// Create a new Proxy for fuchsia.bluetooth.le/Central.
1424    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1425        let protocol_name = <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1426        Self { client: fidl::client::Client::new(channel, protocol_name) }
1427    }
1428
1429    /// Get a Stream of events from the remote end of the protocol.
1430    ///
1431    /// # Panics
1432    ///
1433    /// Panics if the event stream was already taken.
1434    pub fn take_event_stream(&self) -> CentralEventStream {
1435        CentralEventStream { event_receiver: self.client.take_event_receiver() }
1436    }
1437
1438    /// Register a listener for incoming channels. The registry will assign a
1439    /// PSM value that is unique for the local device, as well as open a
1440    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
1441    /// event that all PSMs have been assigned, this call will fail with
1442    /// `ZX_ERR_NO_RESOURCES`.
1443    ///
1444    /// Note that the method of service discovery or advertising is defined by
1445    /// the service or protocol, so it is the responsibility of the caller to
1446    /// communicate the assigned PSM to any clients.
1447    pub fn r#listen_l2cap(
1448        &self,
1449        mut payload: ChannelListenerRegistryListenL2capRequest,
1450    ) -> fidl::client::QueryResponseFut<
1451        ChannelListenerRegistryListenL2capResult,
1452        fidl::encoding::DefaultFuchsiaResourceDialect,
1453    > {
1454        CentralProxyInterface::r#listen_l2cap(self, payload)
1455    }
1456
1457    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
1458    /// initiated, then `result_watcher` will be closed with an epitaph.
1459    ///
1460    /// A Central client is allowed to have only one active scan at a time.
1461    /// Accordingly, only one Scan request can be outstanding at a time.
1462    /// Additional calls to Scan will fail.
1463    ///
1464    /// The lifetime of the scan session is tied to the `result_watcher`
1465    /// protocol provided. The scan will be stopped if the channel is closed.
1466    ///
1467    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
1468    /// can be used to watch for scan results.
1469    ///
1470    /// + request `options` Options used to configure the scan session.
1471    /// + request `result_watcher` Protocol that remains valid for the duration
1472    ///   of this scan session.
1473    /// - response An empty response will be sent to acknowledge the scan has
1474    ///   stopped.
1475    ///
1476    /// The following epitaphs may be sent by the server on error:
1477    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
1478    ///   protocol is only allowed 1 active scan.
1479    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
1480    ///   `ScanOptions` documentation.
1481    /// * error `INTERNAL`: An internal error occurred and a scan could not be
1482    ///   started.
1483    pub fn r#scan(
1484        &self,
1485        mut options: &ScanOptions,
1486        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1487    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1488        CentralProxyInterface::r#scan(self, options, result_watcher)
1489    }
1490
1491    /// Connect to the peer with the given identifier.
1492    ///
1493    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
1494    /// client's interest on the LE connection to the peer. Closing the channel
1495    /// removes interest, but may not result in disconnection if another client
1496    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
1497    ///
1498    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
1499    /// system if the connection to the peer is lost or an error occurs.
1500    ///
1501    /// The following epitaphs may be sent by the server on error:
1502    /// + `INVALID_ARGS`: Some of the parameters are invalid.
1503    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
1504    ///                    Connection should be used.
1505    /// + `NOT_CONNECTED`: A connection could not be established.
1506    /// + `CONNECTION_RESET`: The peer disconnected.
1507    ///
1508    /// + request `id` Identifier of the peer to initiate a connection to.
1509    /// + request `options` Options used to configure the connection.
1510    /// + request `handle` Handle that remains valid for the duration of this
1511    ///   connection.
1512    pub fn r#connect(
1513        &self,
1514        mut id: &fidl_fuchsia_bluetooth::PeerId,
1515        mut options: &ConnectionOptions,
1516        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1517    ) -> Result<(), fidl::Error> {
1518        CentralProxyInterface::r#connect(self, id, options, handle)
1519    }
1520
1521    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
1522    /// operation is only valid when operating in the Central role for a connection.
1523    ///
1524    /// If the Central channel is closed before the CIG is explicitly removed, the group will
1525    /// be removed and disconnected.
1526    ///
1527    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
1528    /// id allocated by the host.
1529    pub fn r#create_connected_isochronous_group(
1530        &self,
1531        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1532    ) -> fidl::client::QueryResponseFut<
1533        CentralCreateConnectedIsochronousGroupResult,
1534        fidl::encoding::DefaultFuchsiaResourceDialect,
1535    > {
1536        CentralProxyInterface::r#create_connected_isochronous_group(self, payload)
1537    }
1538
1539    /// Returns the list of peripherals that are known to the system from previous scan, connection,
1540    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
1541    /// be present on the peripheral.
1542    ///
1543    /// This method only returns peripherals (i.e. connectable devices).
1544    pub fn r#get_peripherals(
1545        &self,
1546        mut service_uuids: Option<&[String]>,
1547    ) -> fidl::client::QueryResponseFut<
1548        Vec<RemoteDevice>,
1549        fidl::encoding::DefaultFuchsiaResourceDialect,
1550    > {
1551        CentralProxyInterface::r#get_peripherals(self, service_uuids)
1552    }
1553
1554    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
1555    ///
1556    /// Returns information about a single peripheral that is known to the system from previous scan,
1557    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
1558    /// `identifier` is not recognized.
1559    pub fn r#get_peripheral(
1560        &self,
1561        mut identifier: &str,
1562    ) -> fidl::client::QueryResponseFut<
1563        Option<Box<RemoteDevice>>,
1564        fidl::encoding::DefaultFuchsiaResourceDialect,
1565    > {
1566        CentralProxyInterface::r#get_peripheral(self, identifier)
1567    }
1568
1569    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
1570    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
1571    /// `filter` will replace the existing session's filter.
1572    ///
1573    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
1574    /// will be notified for all discoverable devices that are found. This is not recommended; clients
1575    /// should generally filter results by at least one of `filter.service_uuids`,
1576    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
1577    pub fn r#start_scan(
1578        &self,
1579        mut filter: Option<&ScanFilter>,
1580    ) -> fidl::client::QueryResponseFut<
1581        fidl_fuchsia_bluetooth::Status,
1582        fidl::encoding::DefaultFuchsiaResourceDialect,
1583    > {
1584        CentralProxyInterface::r#start_scan(self, filter)
1585    }
1586
1587    /// Terminate a previously started scan session.
1588    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1589        CentralProxyInterface::r#stop_scan(self)
1590    }
1591
1592    /// Creates a connection to the peripheral device with the given identifier.
1593    /// Returns the status of the operation in `status`.
1594    ///
1595    /// On success, `gatt_client` will be bound and can be used for GATT client
1596    /// role procedures. On failure, `gatt_client` will be closed and `status` will
1597    /// indicate an error.
1598    pub fn r#connect_peripheral(
1599        &self,
1600        mut identifier: &str,
1601        mut options: &ConnectionOptions,
1602        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1603    ) -> fidl::client::QueryResponseFut<
1604        fidl_fuchsia_bluetooth::Status,
1605        fidl::encoding::DefaultFuchsiaResourceDialect,
1606    > {
1607        CentralProxyInterface::r#connect_peripheral(self, identifier, options, gatt_client)
1608    }
1609
1610    /// Disconnects this Central's connection to the peripheral with the given identifier.
1611    pub fn r#disconnect_peripheral(
1612        &self,
1613        mut identifier: &str,
1614    ) -> fidl::client::QueryResponseFut<
1615        fidl_fuchsia_bluetooth::Status,
1616        fidl::encoding::DefaultFuchsiaResourceDialect,
1617    > {
1618        CentralProxyInterface::r#disconnect_peripheral(self, identifier)
1619    }
1620}
1621
1622impl CentralProxyInterface for CentralProxy {
1623    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
1624        ChannelListenerRegistryListenL2capResult,
1625        fidl::encoding::DefaultFuchsiaResourceDialect,
1626    >;
1627    fn r#listen_l2cap(
1628        &self,
1629        mut payload: ChannelListenerRegistryListenL2capRequest,
1630    ) -> Self::ListenL2capResponseFut {
1631        fn _decode(
1632            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1633        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
1634            let _response = fidl::client::decode_transaction_body::<
1635                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
1636                fidl::encoding::DefaultFuchsiaResourceDialect,
1637                0x39c6e9001d102338,
1638            >(_buf?)?;
1639            Ok(_response.map(|x| x))
1640        }
1641        self.client.send_query_and_decode::<
1642            ChannelListenerRegistryListenL2capRequest,
1643            ChannelListenerRegistryListenL2capResult,
1644        >(
1645            &mut payload,
1646            0x39c6e9001d102338,
1647            fidl::encoding::DynamicFlags::empty(),
1648            _decode,
1649        )
1650    }
1651
1652    type ScanResponseFut =
1653        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1654    fn r#scan(
1655        &self,
1656        mut options: &ScanOptions,
1657        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1658    ) -> Self::ScanResponseFut {
1659        fn _decode(
1660            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1661        ) -> Result<(), fidl::Error> {
1662            let _response = fidl::client::decode_transaction_body::<
1663                fidl::encoding::EmptyPayload,
1664                fidl::encoding::DefaultFuchsiaResourceDialect,
1665                0x41f7121798dfe15f,
1666            >(_buf?)?;
1667            Ok(_response)
1668        }
1669        self.client.send_query_and_decode::<CentralScanRequest, ()>(
1670            (options, result_watcher),
1671            0x41f7121798dfe15f,
1672            fidl::encoding::DynamicFlags::empty(),
1673            _decode,
1674        )
1675    }
1676
1677    fn r#connect(
1678        &self,
1679        mut id: &fidl_fuchsia_bluetooth::PeerId,
1680        mut options: &ConnectionOptions,
1681        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1682    ) -> Result<(), fidl::Error> {
1683        self.client.send::<CentralConnectRequest>(
1684            (id, options, handle),
1685            0x31a3065f2a6913c4,
1686            fidl::encoding::DynamicFlags::empty(),
1687        )
1688    }
1689
1690    type CreateConnectedIsochronousGroupResponseFut = fidl::client::QueryResponseFut<
1691        CentralCreateConnectedIsochronousGroupResult,
1692        fidl::encoding::DefaultFuchsiaResourceDialect,
1693    >;
1694    fn r#create_connected_isochronous_group(
1695        &self,
1696        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1697    ) -> Self::CreateConnectedIsochronousGroupResponseFut {
1698        fn _decode(
1699            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1700        ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
1701            let _response = fidl::client::decode_transaction_body::<
1702                fidl::encoding::ResultType<
1703                    CentralCreateConnectedIsochronousGroupResponse,
1704                    CreateCigError,
1705                >,
1706                fidl::encoding::DefaultFuchsiaResourceDialect,
1707                0x60323e70ae22e13,
1708            >(_buf?)?;
1709            Ok(_response.map(|x| x))
1710        }
1711        self.client.send_query_and_decode::<
1712            CentralCreateConnectedIsochronousGroupRequest,
1713            CentralCreateConnectedIsochronousGroupResult,
1714        >(
1715            &mut payload,
1716            0x60323e70ae22e13,
1717            fidl::encoding::DynamicFlags::empty(),
1718            _decode,
1719        )
1720    }
1721
1722    type GetPeripheralsResponseFut = fidl::client::QueryResponseFut<
1723        Vec<RemoteDevice>,
1724        fidl::encoding::DefaultFuchsiaResourceDialect,
1725    >;
1726    fn r#get_peripherals(
1727        &self,
1728        mut service_uuids: Option<&[String]>,
1729    ) -> Self::GetPeripheralsResponseFut {
1730        fn _decode(
1731            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1732        ) -> Result<Vec<RemoteDevice>, fidl::Error> {
1733            let _response = fidl::client::decode_transaction_body::<
1734                CentralGetPeripheralsResponse,
1735                fidl::encoding::DefaultFuchsiaResourceDialect,
1736                0x37ba777499c683a8,
1737            >(_buf?)?;
1738            Ok(_response.peripherals)
1739        }
1740        self.client.send_query_and_decode::<CentralGetPeripheralsRequest, Vec<RemoteDevice>>(
1741            (service_uuids,),
1742            0x37ba777499c683a8,
1743            fidl::encoding::DynamicFlags::empty(),
1744            _decode,
1745        )
1746    }
1747
1748    type GetPeripheralResponseFut = fidl::client::QueryResponseFut<
1749        Option<Box<RemoteDevice>>,
1750        fidl::encoding::DefaultFuchsiaResourceDialect,
1751    >;
1752    fn r#get_peripheral(&self, mut identifier: &str) -> Self::GetPeripheralResponseFut {
1753        fn _decode(
1754            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1755        ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
1756            let _response = fidl::client::decode_transaction_body::<
1757                CentralGetPeripheralResponse,
1758                fidl::encoding::DefaultFuchsiaResourceDialect,
1759                0x97f5a2f2d9c13da,
1760            >(_buf?)?;
1761            Ok(_response.peripheral)
1762        }
1763        self.client.send_query_and_decode::<CentralGetPeripheralRequest, Option<Box<RemoteDevice>>>(
1764            (identifier,),
1765            0x97f5a2f2d9c13da,
1766            fidl::encoding::DynamicFlags::empty(),
1767            _decode,
1768        )
1769    }
1770
1771    type StartScanResponseFut = fidl::client::QueryResponseFut<
1772        fidl_fuchsia_bluetooth::Status,
1773        fidl::encoding::DefaultFuchsiaResourceDialect,
1774    >;
1775    fn r#start_scan(&self, mut filter: Option<&ScanFilter>) -> Self::StartScanResponseFut {
1776        fn _decode(
1777            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1778        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1779            let _response = fidl::client::decode_transaction_body::<
1780                CentralStartScanResponse,
1781                fidl::encoding::DefaultFuchsiaResourceDialect,
1782                0xeb4cf0cd0e1132b,
1783            >(_buf?)?;
1784            Ok(_response.status)
1785        }
1786        self.client
1787            .send_query_and_decode::<CentralStartScanRequest, fidl_fuchsia_bluetooth::Status>(
1788                (filter,),
1789                0xeb4cf0cd0e1132b,
1790                fidl::encoding::DynamicFlags::empty(),
1791                _decode,
1792            )
1793    }
1794
1795    fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1796        self.client.send::<fidl::encoding::EmptyPayload>(
1797            (),
1798            0x5f79ee6a0bb037a0,
1799            fidl::encoding::DynamicFlags::empty(),
1800        )
1801    }
1802
1803    type ConnectPeripheralResponseFut = fidl::client::QueryResponseFut<
1804        fidl_fuchsia_bluetooth::Status,
1805        fidl::encoding::DefaultFuchsiaResourceDialect,
1806    >;
1807    fn r#connect_peripheral(
1808        &self,
1809        mut identifier: &str,
1810        mut options: &ConnectionOptions,
1811        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1812    ) -> Self::ConnectPeripheralResponseFut {
1813        fn _decode(
1814            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1815        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1816            let _response = fidl::client::decode_transaction_body::<
1817                CentralConnectPeripheralResponse,
1818                fidl::encoding::DefaultFuchsiaResourceDialect,
1819                0x714d6c32d066d75a,
1820            >(_buf?)?;
1821            Ok(_response.status)
1822        }
1823        self.client.send_query_and_decode::<
1824            CentralConnectPeripheralRequest,
1825            fidl_fuchsia_bluetooth::Status,
1826        >(
1827            (identifier, options, gatt_client,),
1828            0x714d6c32d066d75a,
1829            fidl::encoding::DynamicFlags::empty(),
1830            _decode,
1831        )
1832    }
1833
1834    type DisconnectPeripheralResponseFut = fidl::client::QueryResponseFut<
1835        fidl_fuchsia_bluetooth::Status,
1836        fidl::encoding::DefaultFuchsiaResourceDialect,
1837    >;
1838    fn r#disconnect_peripheral(
1839        &self,
1840        mut identifier: &str,
1841    ) -> Self::DisconnectPeripheralResponseFut {
1842        fn _decode(
1843            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1844        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1845            let _response = fidl::client::decode_transaction_body::<
1846                CentralDisconnectPeripheralResponse,
1847                fidl::encoding::DefaultFuchsiaResourceDialect,
1848                0xa9430da197362fd,
1849            >(_buf?)?;
1850            Ok(_response.status)
1851        }
1852        self.client.send_query_and_decode::<
1853            CentralDisconnectPeripheralRequest,
1854            fidl_fuchsia_bluetooth::Status,
1855        >(
1856            (identifier,),
1857            0xa9430da197362fd,
1858            fidl::encoding::DynamicFlags::empty(),
1859            _decode,
1860        )
1861    }
1862}
1863
1864pub struct CentralEventStream {
1865    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1866}
1867
1868impl std::marker::Unpin for CentralEventStream {}
1869
1870impl futures::stream::FusedStream for CentralEventStream {
1871    fn is_terminated(&self) -> bool {
1872        self.event_receiver.is_terminated()
1873    }
1874}
1875
1876impl futures::Stream for CentralEventStream {
1877    type Item = Result<CentralEvent, fidl::Error>;
1878
1879    fn poll_next(
1880        mut self: std::pin::Pin<&mut Self>,
1881        cx: &mut std::task::Context<'_>,
1882    ) -> std::task::Poll<Option<Self::Item>> {
1883        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1884            &mut self.event_receiver,
1885            cx
1886        )?) {
1887            Some(buf) => std::task::Poll::Ready(Some(CentralEvent::decode(buf))),
1888            None => std::task::Poll::Ready(None),
1889        }
1890    }
1891}
1892
1893#[derive(Debug)]
1894pub enum CentralEvent {
1895    OnScanStateChanged { scanning: bool },
1896    OnDeviceDiscovered { device: RemoteDevice },
1897    OnPeripheralDisconnected { identifier: String },
1898}
1899
1900impl CentralEvent {
1901    #[allow(irrefutable_let_patterns)]
1902    pub fn into_on_scan_state_changed(self) -> Option<bool> {
1903        if let CentralEvent::OnScanStateChanged { scanning } = self {
1904            Some((scanning))
1905        } else {
1906            None
1907        }
1908    }
1909    #[allow(irrefutable_let_patterns)]
1910    pub fn into_on_device_discovered(self) -> Option<RemoteDevice> {
1911        if let CentralEvent::OnDeviceDiscovered { device } = self {
1912            Some((device))
1913        } else {
1914            None
1915        }
1916    }
1917    #[allow(irrefutable_let_patterns)]
1918    pub fn into_on_peripheral_disconnected(self) -> Option<String> {
1919        if let CentralEvent::OnPeripheralDisconnected { identifier } = self {
1920            Some((identifier))
1921        } else {
1922            None
1923        }
1924    }
1925
1926    /// Decodes a message buffer as a [`CentralEvent`].
1927    fn decode(
1928        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1929    ) -> Result<CentralEvent, fidl::Error> {
1930        let (bytes, _handles) = buf.split_mut();
1931        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1932        debug_assert_eq!(tx_header.tx_id, 0);
1933        match tx_header.ordinal {
1934            0x5f8edc23cad04d3f => {
1935                let mut out = fidl::new_empty!(
1936                    CentralOnScanStateChangedRequest,
1937                    fidl::encoding::DefaultFuchsiaResourceDialect
1938                );
1939                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnScanStateChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1940                Ok((CentralEvent::OnScanStateChanged { scanning: out.scanning }))
1941            }
1942            0x708dadf20d66db6 => {
1943                let mut out = fidl::new_empty!(
1944                    CentralOnDeviceDiscoveredRequest,
1945                    fidl::encoding::DefaultFuchsiaResourceDialect
1946                );
1947                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnDeviceDiscoveredRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1948                Ok((CentralEvent::OnDeviceDiscovered { device: out.device }))
1949            }
1950            0x4e4c6b979b2126df => {
1951                let mut out = fidl::new_empty!(
1952                    CentralOnPeripheralDisconnectedRequest,
1953                    fidl::encoding::DefaultFuchsiaResourceDialect
1954                );
1955                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnPeripheralDisconnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1956                Ok((CentralEvent::OnPeripheralDisconnected { identifier: out.identifier }))
1957            }
1958            _ => Err(fidl::Error::UnknownOrdinal {
1959                ordinal: tx_header.ordinal,
1960                protocol_name: <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1961            }),
1962        }
1963    }
1964}
1965
1966/// A Stream of incoming requests for fuchsia.bluetooth.le/Central.
1967pub struct CentralRequestStream {
1968    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1969    is_terminated: bool,
1970}
1971
1972impl std::marker::Unpin for CentralRequestStream {}
1973
1974impl futures::stream::FusedStream for CentralRequestStream {
1975    fn is_terminated(&self) -> bool {
1976        self.is_terminated
1977    }
1978}
1979
1980impl fidl::endpoints::RequestStream for CentralRequestStream {
1981    type Protocol = CentralMarker;
1982    type ControlHandle = CentralControlHandle;
1983
1984    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1985        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1986    }
1987
1988    fn control_handle(&self) -> Self::ControlHandle {
1989        CentralControlHandle { inner: self.inner.clone() }
1990    }
1991
1992    fn into_inner(
1993        self,
1994    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1995    {
1996        (self.inner, self.is_terminated)
1997    }
1998
1999    fn from_inner(
2000        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2001        is_terminated: bool,
2002    ) -> Self {
2003        Self { inner, is_terminated }
2004    }
2005}
2006
2007impl futures::Stream for CentralRequestStream {
2008    type Item = Result<CentralRequest, fidl::Error>;
2009
2010    fn poll_next(
2011        mut self: std::pin::Pin<&mut Self>,
2012        cx: &mut std::task::Context<'_>,
2013    ) -> std::task::Poll<Option<Self::Item>> {
2014        let this = &mut *self;
2015        if this.inner.check_shutdown(cx) {
2016            this.is_terminated = true;
2017            return std::task::Poll::Ready(None);
2018        }
2019        if this.is_terminated {
2020            panic!("polled CentralRequestStream after completion");
2021        }
2022        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2023            |bytes, handles| {
2024                match this.inner.channel().read_etc(cx, bytes, handles) {
2025                    std::task::Poll::Ready(Ok(())) => {}
2026                    std::task::Poll::Pending => return std::task::Poll::Pending,
2027                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2028                        this.is_terminated = true;
2029                        return std::task::Poll::Ready(None);
2030                    }
2031                    std::task::Poll::Ready(Err(e)) => {
2032                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2033                            e.into(),
2034                        ))))
2035                    }
2036                }
2037
2038                // A message has been received from the channel
2039                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2040
2041                std::task::Poll::Ready(Some(match header.ordinal {
2042                    0x39c6e9001d102338 => {
2043                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2044                        let mut req = fidl::new_empty!(
2045                            ChannelListenerRegistryListenL2capRequest,
2046                            fidl::encoding::DefaultFuchsiaResourceDialect
2047                        );
2048                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
2049                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2050                        Ok(CentralRequest::ListenL2cap {
2051                            payload: req,
2052                            responder: CentralListenL2capResponder {
2053                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2054                                tx_id: header.tx_id,
2055                            },
2056                        })
2057                    }
2058                    0x41f7121798dfe15f => {
2059                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2060                        let mut req = fidl::new_empty!(
2061                            CentralScanRequest,
2062                            fidl::encoding::DefaultFuchsiaResourceDialect
2063                        );
2064                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralScanRequest>(&header, _body_bytes, handles, &mut req)?;
2065                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2066                        Ok(CentralRequest::Scan {
2067                            options: req.options,
2068                            result_watcher: req.result_watcher,
2069
2070                            responder: CentralScanResponder {
2071                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2072                                tx_id: header.tx_id,
2073                            },
2074                        })
2075                    }
2076                    0x31a3065f2a6913c4 => {
2077                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2078                        let mut req = fidl::new_empty!(
2079                            CentralConnectRequest,
2080                            fidl::encoding::DefaultFuchsiaResourceDialect
2081                        );
2082                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectRequest>(&header, _body_bytes, handles, &mut req)?;
2083                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2084                        Ok(CentralRequest::Connect {
2085                            id: req.id,
2086                            options: req.options,
2087                            handle: req.handle,
2088
2089                            control_handle,
2090                        })
2091                    }
2092                    0x60323e70ae22e13 => {
2093                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2094                        let mut req = fidl::new_empty!(
2095                            CentralCreateConnectedIsochronousGroupRequest,
2096                            fidl::encoding::DefaultFuchsiaResourceDialect
2097                        );
2098                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralCreateConnectedIsochronousGroupRequest>(&header, _body_bytes, handles, &mut req)?;
2099                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2100                        Ok(CentralRequest::CreateConnectedIsochronousGroup {
2101                            payload: req,
2102                            responder: CentralCreateConnectedIsochronousGroupResponder {
2103                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2104                                tx_id: header.tx_id,
2105                            },
2106                        })
2107                    }
2108                    0x37ba777499c683a8 => {
2109                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2110                        let mut req = fidl::new_empty!(
2111                            CentralGetPeripheralsRequest,
2112                            fidl::encoding::DefaultFuchsiaResourceDialect
2113                        );
2114                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralsRequest>(&header, _body_bytes, handles, &mut req)?;
2115                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2116                        Ok(CentralRequest::GetPeripherals {
2117                            service_uuids: req.service_uuids,
2118
2119                            responder: CentralGetPeripheralsResponder {
2120                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2121                                tx_id: header.tx_id,
2122                            },
2123                        })
2124                    }
2125                    0x97f5a2f2d9c13da => {
2126                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2127                        let mut req = fidl::new_empty!(
2128                            CentralGetPeripheralRequest,
2129                            fidl::encoding::DefaultFuchsiaResourceDialect
2130                        );
2131                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2132                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2133                        Ok(CentralRequest::GetPeripheral {
2134                            identifier: req.identifier,
2135
2136                            responder: CentralGetPeripheralResponder {
2137                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2138                                tx_id: header.tx_id,
2139                            },
2140                        })
2141                    }
2142                    0xeb4cf0cd0e1132b => {
2143                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2144                        let mut req = fidl::new_empty!(
2145                            CentralStartScanRequest,
2146                            fidl::encoding::DefaultFuchsiaResourceDialect
2147                        );
2148                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralStartScanRequest>(&header, _body_bytes, handles, &mut req)?;
2149                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2150                        Ok(CentralRequest::StartScan {
2151                            filter: req.filter,
2152
2153                            responder: CentralStartScanResponder {
2154                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2155                                tx_id: header.tx_id,
2156                            },
2157                        })
2158                    }
2159                    0x5f79ee6a0bb037a0 => {
2160                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2161                        let mut req = fidl::new_empty!(
2162                            fidl::encoding::EmptyPayload,
2163                            fidl::encoding::DefaultFuchsiaResourceDialect
2164                        );
2165                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2166                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2167                        Ok(CentralRequest::StopScan { control_handle })
2168                    }
2169                    0x714d6c32d066d75a => {
2170                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2171                        let mut req = fidl::new_empty!(
2172                            CentralConnectPeripheralRequest,
2173                            fidl::encoding::DefaultFuchsiaResourceDialect
2174                        );
2175                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2176                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2177                        Ok(CentralRequest::ConnectPeripheral {
2178                            identifier: req.identifier,
2179                            options: req.options,
2180                            gatt_client: req.gatt_client,
2181
2182                            responder: CentralConnectPeripheralResponder {
2183                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2184                                tx_id: header.tx_id,
2185                            },
2186                        })
2187                    }
2188                    0xa9430da197362fd => {
2189                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2190                        let mut req = fidl::new_empty!(
2191                            CentralDisconnectPeripheralRequest,
2192                            fidl::encoding::DefaultFuchsiaResourceDialect
2193                        );
2194                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralDisconnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2195                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2196                        Ok(CentralRequest::DisconnectPeripheral {
2197                            identifier: req.identifier,
2198
2199                            responder: CentralDisconnectPeripheralResponder {
2200                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2201                                tx_id: header.tx_id,
2202                            },
2203                        })
2204                    }
2205                    _ => Err(fidl::Error::UnknownOrdinal {
2206                        ordinal: header.ordinal,
2207                        protocol_name:
2208                            <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2209                    }),
2210                }))
2211            },
2212        )
2213    }
2214}
2215
2216#[derive(Debug)]
2217pub enum CentralRequest {
2218    /// Register a listener for incoming channels. The registry will assign a
2219    /// PSM value that is unique for the local device, as well as open a
2220    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
2221    /// event that all PSMs have been assigned, this call will fail with
2222    /// `ZX_ERR_NO_RESOURCES`.
2223    ///
2224    /// Note that the method of service discovery or advertising is defined by
2225    /// the service or protocol, so it is the responsibility of the caller to
2226    /// communicate the assigned PSM to any clients.
2227    ListenL2cap {
2228        payload: ChannelListenerRegistryListenL2capRequest,
2229        responder: CentralListenL2capResponder,
2230    },
2231    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
2232    /// initiated, then `result_watcher` will be closed with an epitaph.
2233    ///
2234    /// A Central client is allowed to have only one active scan at a time.
2235    /// Accordingly, only one Scan request can be outstanding at a time.
2236    /// Additional calls to Scan will fail.
2237    ///
2238    /// The lifetime of the scan session is tied to the `result_watcher`
2239    /// protocol provided. The scan will be stopped if the channel is closed.
2240    ///
2241    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
2242    /// can be used to watch for scan results.
2243    ///
2244    /// + request `options` Options used to configure the scan session.
2245    /// + request `result_watcher` Protocol that remains valid for the duration
2246    ///   of this scan session.
2247    /// - response An empty response will be sent to acknowledge the scan has
2248    ///   stopped.
2249    ///
2250    /// The following epitaphs may be sent by the server on error:
2251    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
2252    ///   protocol is only allowed 1 active scan.
2253    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
2254    ///   `ScanOptions` documentation.
2255    /// * error `INTERNAL`: An internal error occurred and a scan could not be
2256    ///   started.
2257    Scan {
2258        options: ScanOptions,
2259        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
2260        responder: CentralScanResponder,
2261    },
2262    /// Connect to the peer with the given identifier.
2263    ///
2264    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
2265    /// client's interest on the LE connection to the peer. Closing the channel
2266    /// removes interest, but may not result in disconnection if another client
2267    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
2268    ///
2269    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
2270    /// system if the connection to the peer is lost or an error occurs.
2271    ///
2272    /// The following epitaphs may be sent by the server on error:
2273    /// + `INVALID_ARGS`: Some of the parameters are invalid.
2274    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
2275    ///                    Connection should be used.
2276    /// + `NOT_CONNECTED`: A connection could not be established.
2277    /// + `CONNECTION_RESET`: The peer disconnected.
2278    ///
2279    /// + request `id` Identifier of the peer to initiate a connection to.
2280    /// + request `options` Options used to configure the connection.
2281    /// + request `handle` Handle that remains valid for the duration of this
2282    ///   connection.
2283    Connect {
2284        id: fidl_fuchsia_bluetooth::PeerId,
2285        options: ConnectionOptions,
2286        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
2287        control_handle: CentralControlHandle,
2288    },
2289    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
2290    /// operation is only valid when operating in the Central role for a connection.
2291    ///
2292    /// If the Central channel is closed before the CIG is explicitly removed, the group will
2293    /// be removed and disconnected.
2294    ///
2295    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
2296    /// id allocated by the host.
2297    CreateConnectedIsochronousGroup {
2298        payload: CentralCreateConnectedIsochronousGroupRequest,
2299        responder: CentralCreateConnectedIsochronousGroupResponder,
2300    },
2301    /// Returns the list of peripherals that are known to the system from previous scan, connection,
2302    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
2303    /// be present on the peripheral.
2304    ///
2305    /// This method only returns peripherals (i.e. connectable devices).
2306    GetPeripherals { service_uuids: Option<Vec<String>>, responder: CentralGetPeripheralsResponder },
2307    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
2308    ///
2309    /// Returns information about a single peripheral that is known to the system from previous scan,
2310    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
2311    /// `identifier` is not recognized.
2312    GetPeripheral { identifier: String, responder: CentralGetPeripheralResponder },
2313    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
2314    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
2315    /// `filter` will replace the existing session's filter.
2316    ///
2317    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
2318    /// will be notified for all discoverable devices that are found. This is not recommended; clients
2319    /// should generally filter results by at least one of `filter.service_uuids`,
2320    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
2321    StartScan { filter: Option<Box<ScanFilter>>, responder: CentralStartScanResponder },
2322    /// Terminate a previously started scan session.
2323    StopScan { control_handle: CentralControlHandle },
2324    /// Creates a connection to the peripheral device with the given identifier.
2325    /// Returns the status of the operation in `status`.
2326    ///
2327    /// On success, `gatt_client` will be bound and can be used for GATT client
2328    /// role procedures. On failure, `gatt_client` will be closed and `status` will
2329    /// indicate an error.
2330    ConnectPeripheral {
2331        identifier: String,
2332        options: ConnectionOptions,
2333        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
2334        responder: CentralConnectPeripheralResponder,
2335    },
2336    /// Disconnects this Central's connection to the peripheral with the given identifier.
2337    DisconnectPeripheral { identifier: String, responder: CentralDisconnectPeripheralResponder },
2338}
2339
2340impl CentralRequest {
2341    #[allow(irrefutable_let_patterns)]
2342    pub fn into_listen_l2cap(
2343        self,
2344    ) -> Option<(ChannelListenerRegistryListenL2capRequest, CentralListenL2capResponder)> {
2345        if let CentralRequest::ListenL2cap { payload, responder } = self {
2346            Some((payload, responder))
2347        } else {
2348            None
2349        }
2350    }
2351
2352    #[allow(irrefutable_let_patterns)]
2353    pub fn into_scan(
2354        self,
2355    ) -> Option<(
2356        ScanOptions,
2357        fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
2358        CentralScanResponder,
2359    )> {
2360        if let CentralRequest::Scan { options, result_watcher, responder } = self {
2361            Some((options, result_watcher, responder))
2362        } else {
2363            None
2364        }
2365    }
2366
2367    #[allow(irrefutable_let_patterns)]
2368    pub fn into_connect(
2369        self,
2370    ) -> Option<(
2371        fidl_fuchsia_bluetooth::PeerId,
2372        ConnectionOptions,
2373        fidl::endpoints::ServerEnd<ConnectionMarker>,
2374        CentralControlHandle,
2375    )> {
2376        if let CentralRequest::Connect { id, options, handle, control_handle } = self {
2377            Some((id, options, handle, control_handle))
2378        } else {
2379            None
2380        }
2381    }
2382
2383    #[allow(irrefutable_let_patterns)]
2384    pub fn into_create_connected_isochronous_group(
2385        self,
2386    ) -> Option<(
2387        CentralCreateConnectedIsochronousGroupRequest,
2388        CentralCreateConnectedIsochronousGroupResponder,
2389    )> {
2390        if let CentralRequest::CreateConnectedIsochronousGroup { payload, responder } = self {
2391            Some((payload, responder))
2392        } else {
2393            None
2394        }
2395    }
2396
2397    #[allow(irrefutable_let_patterns)]
2398    pub fn into_get_peripherals(
2399        self,
2400    ) -> Option<(Option<Vec<String>>, CentralGetPeripheralsResponder)> {
2401        if let CentralRequest::GetPeripherals { service_uuids, responder } = self {
2402            Some((service_uuids, responder))
2403        } else {
2404            None
2405        }
2406    }
2407
2408    #[allow(irrefutable_let_patterns)]
2409    pub fn into_get_peripheral(self) -> Option<(String, CentralGetPeripheralResponder)> {
2410        if let CentralRequest::GetPeripheral { identifier, responder } = self {
2411            Some((identifier, responder))
2412        } else {
2413            None
2414        }
2415    }
2416
2417    #[allow(irrefutable_let_patterns)]
2418    pub fn into_start_scan(self) -> Option<(Option<Box<ScanFilter>>, CentralStartScanResponder)> {
2419        if let CentralRequest::StartScan { filter, responder } = self {
2420            Some((filter, responder))
2421        } else {
2422            None
2423        }
2424    }
2425
2426    #[allow(irrefutable_let_patterns)]
2427    pub fn into_stop_scan(self) -> Option<(CentralControlHandle)> {
2428        if let CentralRequest::StopScan { control_handle } = self {
2429            Some((control_handle))
2430        } else {
2431            None
2432        }
2433    }
2434
2435    #[allow(irrefutable_let_patterns)]
2436    pub fn into_connect_peripheral(
2437        self,
2438    ) -> Option<(
2439        String,
2440        ConnectionOptions,
2441        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
2442        CentralConnectPeripheralResponder,
2443    )> {
2444        if let CentralRequest::ConnectPeripheral { identifier, options, gatt_client, responder } =
2445            self
2446        {
2447            Some((identifier, options, gatt_client, responder))
2448        } else {
2449            None
2450        }
2451    }
2452
2453    #[allow(irrefutable_let_patterns)]
2454    pub fn into_disconnect_peripheral(
2455        self,
2456    ) -> Option<(String, CentralDisconnectPeripheralResponder)> {
2457        if let CentralRequest::DisconnectPeripheral { identifier, responder } = self {
2458            Some((identifier, responder))
2459        } else {
2460            None
2461        }
2462    }
2463
2464    /// Name of the method defined in FIDL
2465    pub fn method_name(&self) -> &'static str {
2466        match *self {
2467            CentralRequest::ListenL2cap { .. } => "listen_l2cap",
2468            CentralRequest::Scan { .. } => "scan",
2469            CentralRequest::Connect { .. } => "connect",
2470            CentralRequest::CreateConnectedIsochronousGroup { .. } => {
2471                "create_connected_isochronous_group"
2472            }
2473            CentralRequest::GetPeripherals { .. } => "get_peripherals",
2474            CentralRequest::GetPeripheral { .. } => "get_peripheral",
2475            CentralRequest::StartScan { .. } => "start_scan",
2476            CentralRequest::StopScan { .. } => "stop_scan",
2477            CentralRequest::ConnectPeripheral { .. } => "connect_peripheral",
2478            CentralRequest::DisconnectPeripheral { .. } => "disconnect_peripheral",
2479        }
2480    }
2481}
2482
2483#[derive(Debug, Clone)]
2484pub struct CentralControlHandle {
2485    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2486}
2487
2488impl fidl::endpoints::ControlHandle for CentralControlHandle {
2489    fn shutdown(&self) {
2490        self.inner.shutdown()
2491    }
2492    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2493        self.inner.shutdown_with_epitaph(status)
2494    }
2495
2496    fn is_closed(&self) -> bool {
2497        self.inner.channel().is_closed()
2498    }
2499    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2500        self.inner.channel().on_closed()
2501    }
2502
2503    #[cfg(target_os = "fuchsia")]
2504    fn signal_peer(
2505        &self,
2506        clear_mask: zx::Signals,
2507        set_mask: zx::Signals,
2508    ) -> Result<(), zx_status::Status> {
2509        use fidl::Peered;
2510        self.inner.channel().signal_peer(clear_mask, set_mask)
2511    }
2512}
2513
2514impl CentralControlHandle {
2515    pub fn send_on_scan_state_changed(&self, mut scanning: bool) -> Result<(), fidl::Error> {
2516        self.inner.send::<CentralOnScanStateChangedRequest>(
2517            (scanning,),
2518            0,
2519            0x5f8edc23cad04d3f,
2520            fidl::encoding::DynamicFlags::empty(),
2521        )
2522    }
2523
2524    pub fn send_on_device_discovered(&self, mut device: &RemoteDevice) -> Result<(), fidl::Error> {
2525        self.inner.send::<CentralOnDeviceDiscoveredRequest>(
2526            (device,),
2527            0,
2528            0x708dadf20d66db6,
2529            fidl::encoding::DynamicFlags::empty(),
2530        )
2531    }
2532
2533    pub fn send_on_peripheral_disconnected(&self, mut identifier: &str) -> Result<(), fidl::Error> {
2534        self.inner.send::<CentralOnPeripheralDisconnectedRequest>(
2535            (identifier,),
2536            0,
2537            0x4e4c6b979b2126df,
2538            fidl::encoding::DynamicFlags::empty(),
2539        )
2540    }
2541}
2542
2543#[must_use = "FIDL methods require a response to be sent"]
2544#[derive(Debug)]
2545pub struct CentralListenL2capResponder {
2546    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2547    tx_id: u32,
2548}
2549
2550/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2551/// if the responder is dropped without sending a response, so that the client
2552/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2553impl std::ops::Drop for CentralListenL2capResponder {
2554    fn drop(&mut self) {
2555        self.control_handle.shutdown();
2556        // Safety: drops once, never accessed again
2557        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2558    }
2559}
2560
2561impl fidl::endpoints::Responder for CentralListenL2capResponder {
2562    type ControlHandle = CentralControlHandle;
2563
2564    fn control_handle(&self) -> &CentralControlHandle {
2565        &self.control_handle
2566    }
2567
2568    fn drop_without_shutdown(mut self) {
2569        // Safety: drops once, never accessed again due to mem::forget
2570        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2571        // Prevent Drop from running (which would shut down the channel)
2572        std::mem::forget(self);
2573    }
2574}
2575
2576impl CentralListenL2capResponder {
2577    /// Sends a response to the FIDL transaction.
2578    ///
2579    /// Sets the channel to shutdown if an error occurs.
2580    pub fn send(
2581        self,
2582        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2583    ) -> Result<(), fidl::Error> {
2584        let _result = self.send_raw(result);
2585        if _result.is_err() {
2586            self.control_handle.shutdown();
2587        }
2588        self.drop_without_shutdown();
2589        _result
2590    }
2591
2592    /// Similar to "send" but does not shutdown the channel if an error occurs.
2593    pub fn send_no_shutdown_on_err(
2594        self,
2595        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2596    ) -> Result<(), fidl::Error> {
2597        let _result = self.send_raw(result);
2598        self.drop_without_shutdown();
2599        _result
2600    }
2601
2602    fn send_raw(
2603        &self,
2604        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2605    ) -> Result<(), fidl::Error> {
2606        self.control_handle.inner.send::<fidl::encoding::ResultType<
2607            ChannelListenerRegistryListenL2capResponse,
2608            i32,
2609        >>(
2610            result,
2611            self.tx_id,
2612            0x39c6e9001d102338,
2613            fidl::encoding::DynamicFlags::empty(),
2614        )
2615    }
2616}
2617
2618#[must_use = "FIDL methods require a response to be sent"]
2619#[derive(Debug)]
2620pub struct CentralScanResponder {
2621    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2622    tx_id: u32,
2623}
2624
2625/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2626/// if the responder is dropped without sending a response, so that the client
2627/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2628impl std::ops::Drop for CentralScanResponder {
2629    fn drop(&mut self) {
2630        self.control_handle.shutdown();
2631        // Safety: drops once, never accessed again
2632        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2633    }
2634}
2635
2636impl fidl::endpoints::Responder for CentralScanResponder {
2637    type ControlHandle = CentralControlHandle;
2638
2639    fn control_handle(&self) -> &CentralControlHandle {
2640        &self.control_handle
2641    }
2642
2643    fn drop_without_shutdown(mut self) {
2644        // Safety: drops once, never accessed again due to mem::forget
2645        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2646        // Prevent Drop from running (which would shut down the channel)
2647        std::mem::forget(self);
2648    }
2649}
2650
2651impl CentralScanResponder {
2652    /// Sends a response to the FIDL transaction.
2653    ///
2654    /// Sets the channel to shutdown if an error occurs.
2655    pub fn send(self) -> Result<(), fidl::Error> {
2656        let _result = self.send_raw();
2657        if _result.is_err() {
2658            self.control_handle.shutdown();
2659        }
2660        self.drop_without_shutdown();
2661        _result
2662    }
2663
2664    /// Similar to "send" but does not shutdown the channel if an error occurs.
2665    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2666        let _result = self.send_raw();
2667        self.drop_without_shutdown();
2668        _result
2669    }
2670
2671    fn send_raw(&self) -> Result<(), fidl::Error> {
2672        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2673            (),
2674            self.tx_id,
2675            0x41f7121798dfe15f,
2676            fidl::encoding::DynamicFlags::empty(),
2677        )
2678    }
2679}
2680
2681#[must_use = "FIDL methods require a response to be sent"]
2682#[derive(Debug)]
2683pub struct CentralCreateConnectedIsochronousGroupResponder {
2684    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2685    tx_id: u32,
2686}
2687
2688/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2689/// if the responder is dropped without sending a response, so that the client
2690/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2691impl std::ops::Drop for CentralCreateConnectedIsochronousGroupResponder {
2692    fn drop(&mut self) {
2693        self.control_handle.shutdown();
2694        // Safety: drops once, never accessed again
2695        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2696    }
2697}
2698
2699impl fidl::endpoints::Responder for CentralCreateConnectedIsochronousGroupResponder {
2700    type ControlHandle = CentralControlHandle;
2701
2702    fn control_handle(&self) -> &CentralControlHandle {
2703        &self.control_handle
2704    }
2705
2706    fn drop_without_shutdown(mut self) {
2707        // Safety: drops once, never accessed again due to mem::forget
2708        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2709        // Prevent Drop from running (which would shut down the channel)
2710        std::mem::forget(self);
2711    }
2712}
2713
2714impl CentralCreateConnectedIsochronousGroupResponder {
2715    /// Sends a response to the FIDL transaction.
2716    ///
2717    /// Sets the channel to shutdown if an error occurs.
2718    pub fn send(
2719        self,
2720        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2721    ) -> Result<(), fidl::Error> {
2722        let _result = self.send_raw(result);
2723        if _result.is_err() {
2724            self.control_handle.shutdown();
2725        }
2726        self.drop_without_shutdown();
2727        _result
2728    }
2729
2730    /// Similar to "send" but does not shutdown the channel if an error occurs.
2731    pub fn send_no_shutdown_on_err(
2732        self,
2733        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2734    ) -> Result<(), fidl::Error> {
2735        let _result = self.send_raw(result);
2736        self.drop_without_shutdown();
2737        _result
2738    }
2739
2740    fn send_raw(
2741        &self,
2742        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2743    ) -> Result<(), fidl::Error> {
2744        self.control_handle.inner.send::<fidl::encoding::ResultType<
2745            CentralCreateConnectedIsochronousGroupResponse,
2746            CreateCigError,
2747        >>(
2748            result,
2749            self.tx_id,
2750            0x60323e70ae22e13,
2751            fidl::encoding::DynamicFlags::empty(),
2752        )
2753    }
2754}
2755
2756#[must_use = "FIDL methods require a response to be sent"]
2757#[derive(Debug)]
2758pub struct CentralGetPeripheralsResponder {
2759    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2760    tx_id: u32,
2761}
2762
2763/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2764/// if the responder is dropped without sending a response, so that the client
2765/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2766impl std::ops::Drop for CentralGetPeripheralsResponder {
2767    fn drop(&mut self) {
2768        self.control_handle.shutdown();
2769        // Safety: drops once, never accessed again
2770        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2771    }
2772}
2773
2774impl fidl::endpoints::Responder for CentralGetPeripheralsResponder {
2775    type ControlHandle = CentralControlHandle;
2776
2777    fn control_handle(&self) -> &CentralControlHandle {
2778        &self.control_handle
2779    }
2780
2781    fn drop_without_shutdown(mut self) {
2782        // Safety: drops once, never accessed again due to mem::forget
2783        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2784        // Prevent Drop from running (which would shut down the channel)
2785        std::mem::forget(self);
2786    }
2787}
2788
2789impl CentralGetPeripheralsResponder {
2790    /// Sends a response to the FIDL transaction.
2791    ///
2792    /// Sets the channel to shutdown if an error occurs.
2793    pub fn send(self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
2794        let _result = self.send_raw(peripherals);
2795        if _result.is_err() {
2796            self.control_handle.shutdown();
2797        }
2798        self.drop_without_shutdown();
2799        _result
2800    }
2801
2802    /// Similar to "send" but does not shutdown the channel if an error occurs.
2803    pub fn send_no_shutdown_on_err(
2804        self,
2805        mut peripherals: &[RemoteDevice],
2806    ) -> Result<(), fidl::Error> {
2807        let _result = self.send_raw(peripherals);
2808        self.drop_without_shutdown();
2809        _result
2810    }
2811
2812    fn send_raw(&self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
2813        self.control_handle.inner.send::<CentralGetPeripheralsResponse>(
2814            (peripherals,),
2815            self.tx_id,
2816            0x37ba777499c683a8,
2817            fidl::encoding::DynamicFlags::empty(),
2818        )
2819    }
2820}
2821
2822#[must_use = "FIDL methods require a response to be sent"]
2823#[derive(Debug)]
2824pub struct CentralGetPeripheralResponder {
2825    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2826    tx_id: u32,
2827}
2828
2829/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2830/// if the responder is dropped without sending a response, so that the client
2831/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2832impl std::ops::Drop for CentralGetPeripheralResponder {
2833    fn drop(&mut self) {
2834        self.control_handle.shutdown();
2835        // Safety: drops once, never accessed again
2836        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2837    }
2838}
2839
2840impl fidl::endpoints::Responder for CentralGetPeripheralResponder {
2841    type ControlHandle = CentralControlHandle;
2842
2843    fn control_handle(&self) -> &CentralControlHandle {
2844        &self.control_handle
2845    }
2846
2847    fn drop_without_shutdown(mut self) {
2848        // Safety: drops once, never accessed again due to mem::forget
2849        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2850        // Prevent Drop from running (which would shut down the channel)
2851        std::mem::forget(self);
2852    }
2853}
2854
2855impl CentralGetPeripheralResponder {
2856    /// Sends a response to the FIDL transaction.
2857    ///
2858    /// Sets the channel to shutdown if an error occurs.
2859    pub fn send(self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
2860        let _result = self.send_raw(peripheral);
2861        if _result.is_err() {
2862            self.control_handle.shutdown();
2863        }
2864        self.drop_without_shutdown();
2865        _result
2866    }
2867
2868    /// Similar to "send" but does not shutdown the channel if an error occurs.
2869    pub fn send_no_shutdown_on_err(
2870        self,
2871        mut peripheral: Option<&RemoteDevice>,
2872    ) -> Result<(), fidl::Error> {
2873        let _result = self.send_raw(peripheral);
2874        self.drop_without_shutdown();
2875        _result
2876    }
2877
2878    fn send_raw(&self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
2879        self.control_handle.inner.send::<CentralGetPeripheralResponse>(
2880            (peripheral,),
2881            self.tx_id,
2882            0x97f5a2f2d9c13da,
2883            fidl::encoding::DynamicFlags::empty(),
2884        )
2885    }
2886}
2887
2888#[must_use = "FIDL methods require a response to be sent"]
2889#[derive(Debug)]
2890pub struct CentralStartScanResponder {
2891    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2892    tx_id: u32,
2893}
2894
2895/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2896/// if the responder is dropped without sending a response, so that the client
2897/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2898impl std::ops::Drop for CentralStartScanResponder {
2899    fn drop(&mut self) {
2900        self.control_handle.shutdown();
2901        // Safety: drops once, never accessed again
2902        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2903    }
2904}
2905
2906impl fidl::endpoints::Responder for CentralStartScanResponder {
2907    type ControlHandle = CentralControlHandle;
2908
2909    fn control_handle(&self) -> &CentralControlHandle {
2910        &self.control_handle
2911    }
2912
2913    fn drop_without_shutdown(mut self) {
2914        // Safety: drops once, never accessed again due to mem::forget
2915        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2916        // Prevent Drop from running (which would shut down the channel)
2917        std::mem::forget(self);
2918    }
2919}
2920
2921impl CentralStartScanResponder {
2922    /// Sends a response to the FIDL transaction.
2923    ///
2924    /// Sets the channel to shutdown if an error occurs.
2925    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
2926        let _result = self.send_raw(status);
2927        if _result.is_err() {
2928            self.control_handle.shutdown();
2929        }
2930        self.drop_without_shutdown();
2931        _result
2932    }
2933
2934    /// Similar to "send" but does not shutdown the channel if an error occurs.
2935    pub fn send_no_shutdown_on_err(
2936        self,
2937        mut status: &fidl_fuchsia_bluetooth::Status,
2938    ) -> Result<(), fidl::Error> {
2939        let _result = self.send_raw(status);
2940        self.drop_without_shutdown();
2941        _result
2942    }
2943
2944    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
2945        self.control_handle.inner.send::<CentralStartScanResponse>(
2946            (status,),
2947            self.tx_id,
2948            0xeb4cf0cd0e1132b,
2949            fidl::encoding::DynamicFlags::empty(),
2950        )
2951    }
2952}
2953
2954#[must_use = "FIDL methods require a response to be sent"]
2955#[derive(Debug)]
2956pub struct CentralConnectPeripheralResponder {
2957    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2958    tx_id: u32,
2959}
2960
2961/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2962/// if the responder is dropped without sending a response, so that the client
2963/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2964impl std::ops::Drop for CentralConnectPeripheralResponder {
2965    fn drop(&mut self) {
2966        self.control_handle.shutdown();
2967        // Safety: drops once, never accessed again
2968        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2969    }
2970}
2971
2972impl fidl::endpoints::Responder for CentralConnectPeripheralResponder {
2973    type ControlHandle = CentralControlHandle;
2974
2975    fn control_handle(&self) -> &CentralControlHandle {
2976        &self.control_handle
2977    }
2978
2979    fn drop_without_shutdown(mut self) {
2980        // Safety: drops once, never accessed again due to mem::forget
2981        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2982        // Prevent Drop from running (which would shut down the channel)
2983        std::mem::forget(self);
2984    }
2985}
2986
2987impl CentralConnectPeripheralResponder {
2988    /// Sends a response to the FIDL transaction.
2989    ///
2990    /// Sets the channel to shutdown if an error occurs.
2991    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
2992        let _result = self.send_raw(status);
2993        if _result.is_err() {
2994            self.control_handle.shutdown();
2995        }
2996        self.drop_without_shutdown();
2997        _result
2998    }
2999
3000    /// Similar to "send" but does not shutdown the channel if an error occurs.
3001    pub fn send_no_shutdown_on_err(
3002        self,
3003        mut status: &fidl_fuchsia_bluetooth::Status,
3004    ) -> Result<(), fidl::Error> {
3005        let _result = self.send_raw(status);
3006        self.drop_without_shutdown();
3007        _result
3008    }
3009
3010    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3011        self.control_handle.inner.send::<CentralConnectPeripheralResponse>(
3012            (status,),
3013            self.tx_id,
3014            0x714d6c32d066d75a,
3015            fidl::encoding::DynamicFlags::empty(),
3016        )
3017    }
3018}
3019
3020#[must_use = "FIDL methods require a response to be sent"]
3021#[derive(Debug)]
3022pub struct CentralDisconnectPeripheralResponder {
3023    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
3024    tx_id: u32,
3025}
3026
3027/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3028/// if the responder is dropped without sending a response, so that the client
3029/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3030impl std::ops::Drop for CentralDisconnectPeripheralResponder {
3031    fn drop(&mut self) {
3032        self.control_handle.shutdown();
3033        // Safety: drops once, never accessed again
3034        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3035    }
3036}
3037
3038impl fidl::endpoints::Responder for CentralDisconnectPeripheralResponder {
3039    type ControlHandle = CentralControlHandle;
3040
3041    fn control_handle(&self) -> &CentralControlHandle {
3042        &self.control_handle
3043    }
3044
3045    fn drop_without_shutdown(mut self) {
3046        // Safety: drops once, never accessed again due to mem::forget
3047        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3048        // Prevent Drop from running (which would shut down the channel)
3049        std::mem::forget(self);
3050    }
3051}
3052
3053impl CentralDisconnectPeripheralResponder {
3054    /// Sends a response to the FIDL transaction.
3055    ///
3056    /// Sets the channel to shutdown if an error occurs.
3057    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3058        let _result = self.send_raw(status);
3059        if _result.is_err() {
3060            self.control_handle.shutdown();
3061        }
3062        self.drop_without_shutdown();
3063        _result
3064    }
3065
3066    /// Similar to "send" but does not shutdown the channel if an error occurs.
3067    pub fn send_no_shutdown_on_err(
3068        self,
3069        mut status: &fidl_fuchsia_bluetooth::Status,
3070    ) -> Result<(), fidl::Error> {
3071        let _result = self.send_raw(status);
3072        self.drop_without_shutdown();
3073        _result
3074    }
3075
3076    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3077        self.control_handle.inner.send::<CentralDisconnectPeripheralResponse>(
3078            (status,),
3079            self.tx_id,
3080            0xa9430da197362fd,
3081            fidl::encoding::DynamicFlags::empty(),
3082        )
3083    }
3084}
3085
3086#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3087pub struct ChannelListenerMarker;
3088
3089impl fidl::endpoints::ProtocolMarker for ChannelListenerMarker {
3090    type Proxy = ChannelListenerProxy;
3091    type RequestStream = ChannelListenerRequestStream;
3092    #[cfg(target_os = "fuchsia")]
3093    type SynchronousProxy = ChannelListenerSynchronousProxy;
3094
3095    const DEBUG_NAME: &'static str = "(anonymous) ChannelListener";
3096}
3097
3098pub trait ChannelListenerProxyInterface: Send + Sync {
3099    type AcceptResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3100    fn r#accept(
3101        &self,
3102        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3103    ) -> Self::AcceptResponseFut;
3104}
3105#[derive(Debug)]
3106#[cfg(target_os = "fuchsia")]
3107pub struct ChannelListenerSynchronousProxy {
3108    client: fidl::client::sync::Client,
3109}
3110
3111#[cfg(target_os = "fuchsia")]
3112impl fidl::endpoints::SynchronousProxy for ChannelListenerSynchronousProxy {
3113    type Proxy = ChannelListenerProxy;
3114    type Protocol = ChannelListenerMarker;
3115
3116    fn from_channel(inner: fidl::Channel) -> Self {
3117        Self::new(inner)
3118    }
3119
3120    fn into_channel(self) -> fidl::Channel {
3121        self.client.into_channel()
3122    }
3123
3124    fn as_channel(&self) -> &fidl::Channel {
3125        self.client.as_channel()
3126    }
3127}
3128
3129#[cfg(target_os = "fuchsia")]
3130impl ChannelListenerSynchronousProxy {
3131    pub fn new(channel: fidl::Channel) -> Self {
3132        let protocol_name = <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3133        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3134    }
3135
3136    pub fn into_channel(self) -> fidl::Channel {
3137        self.client.into_channel()
3138    }
3139
3140    /// Waits until an event arrives and returns it. It is safe for other
3141    /// threads to make concurrent requests while waiting for an event.
3142    pub fn wait_for_event(
3143        &self,
3144        deadline: zx::MonotonicInstant,
3145    ) -> Result<ChannelListenerEvent, fidl::Error> {
3146        ChannelListenerEvent::decode(self.client.wait_for_event(deadline)?)
3147    }
3148
3149    pub fn r#accept(
3150        &self,
3151        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3152        ___deadline: zx::MonotonicInstant,
3153    ) -> Result<(), fidl::Error> {
3154        let _response = self.client.send_query::<
3155            ChannelListenerAcceptRequest,
3156            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3157        >(
3158            (channel,),
3159            0x6f535bd36b20fc7b,
3160            fidl::encoding::DynamicFlags::FLEXIBLE,
3161            ___deadline,
3162        )?
3163        .into_result::<ChannelListenerMarker>("accept")?;
3164        Ok(_response)
3165    }
3166}
3167
3168#[cfg(target_os = "fuchsia")]
3169impl From<ChannelListenerSynchronousProxy> for zx::Handle {
3170    fn from(value: ChannelListenerSynchronousProxy) -> Self {
3171        value.into_channel().into()
3172    }
3173}
3174
3175#[cfg(target_os = "fuchsia")]
3176impl From<fidl::Channel> for ChannelListenerSynchronousProxy {
3177    fn from(value: fidl::Channel) -> Self {
3178        Self::new(value)
3179    }
3180}
3181
3182#[cfg(target_os = "fuchsia")]
3183impl fidl::endpoints::FromClient for ChannelListenerSynchronousProxy {
3184    type Protocol = ChannelListenerMarker;
3185
3186    fn from_client(value: fidl::endpoints::ClientEnd<ChannelListenerMarker>) -> Self {
3187        Self::new(value.into_channel())
3188    }
3189}
3190
3191#[derive(Debug, Clone)]
3192pub struct ChannelListenerProxy {
3193    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3194}
3195
3196impl fidl::endpoints::Proxy for ChannelListenerProxy {
3197    type Protocol = ChannelListenerMarker;
3198
3199    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3200        Self::new(inner)
3201    }
3202
3203    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3204        self.client.into_channel().map_err(|client| Self { client })
3205    }
3206
3207    fn as_channel(&self) -> &::fidl::AsyncChannel {
3208        self.client.as_channel()
3209    }
3210}
3211
3212impl ChannelListenerProxy {
3213    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelListener.
3214    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3215        let protocol_name = <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3216        Self { client: fidl::client::Client::new(channel, protocol_name) }
3217    }
3218
3219    /// Get a Stream of events from the remote end of the protocol.
3220    ///
3221    /// # Panics
3222    ///
3223    /// Panics if the event stream was already taken.
3224    pub fn take_event_stream(&self) -> ChannelListenerEventStream {
3225        ChannelListenerEventStream { event_receiver: self.client.take_event_receiver() }
3226    }
3227
3228    pub fn r#accept(
3229        &self,
3230        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3231    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3232        ChannelListenerProxyInterface::r#accept(self, channel)
3233    }
3234}
3235
3236impl ChannelListenerProxyInterface for ChannelListenerProxy {
3237    type AcceptResponseFut =
3238        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3239    fn r#accept(
3240        &self,
3241        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3242    ) -> Self::AcceptResponseFut {
3243        fn _decode(
3244            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3245        ) -> Result<(), fidl::Error> {
3246            let _response = fidl::client::decode_transaction_body::<
3247                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3248                fidl::encoding::DefaultFuchsiaResourceDialect,
3249                0x6f535bd36b20fc7b,
3250            >(_buf?)?
3251            .into_result::<ChannelListenerMarker>("accept")?;
3252            Ok(_response)
3253        }
3254        self.client.send_query_and_decode::<ChannelListenerAcceptRequest, ()>(
3255            (channel,),
3256            0x6f535bd36b20fc7b,
3257            fidl::encoding::DynamicFlags::FLEXIBLE,
3258            _decode,
3259        )
3260    }
3261}
3262
3263pub struct ChannelListenerEventStream {
3264    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3265}
3266
3267impl std::marker::Unpin for ChannelListenerEventStream {}
3268
3269impl futures::stream::FusedStream for ChannelListenerEventStream {
3270    fn is_terminated(&self) -> bool {
3271        self.event_receiver.is_terminated()
3272    }
3273}
3274
3275impl futures::Stream for ChannelListenerEventStream {
3276    type Item = Result<ChannelListenerEvent, fidl::Error>;
3277
3278    fn poll_next(
3279        mut self: std::pin::Pin<&mut Self>,
3280        cx: &mut std::task::Context<'_>,
3281    ) -> std::task::Poll<Option<Self::Item>> {
3282        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3283            &mut self.event_receiver,
3284            cx
3285        )?) {
3286            Some(buf) => std::task::Poll::Ready(Some(ChannelListenerEvent::decode(buf))),
3287            None => std::task::Poll::Ready(None),
3288        }
3289    }
3290}
3291
3292#[derive(Debug)]
3293pub enum ChannelListenerEvent {
3294    #[non_exhaustive]
3295    _UnknownEvent {
3296        /// Ordinal of the event that was sent.
3297        ordinal: u64,
3298    },
3299}
3300
3301impl ChannelListenerEvent {
3302    /// Decodes a message buffer as a [`ChannelListenerEvent`].
3303    fn decode(
3304        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3305    ) -> Result<ChannelListenerEvent, fidl::Error> {
3306        let (bytes, _handles) = buf.split_mut();
3307        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3308        debug_assert_eq!(tx_header.tx_id, 0);
3309        match tx_header.ordinal {
3310            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3311                Ok(ChannelListenerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3312            }
3313            _ => Err(fidl::Error::UnknownOrdinal {
3314                ordinal: tx_header.ordinal,
3315                protocol_name:
3316                    <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3317            }),
3318        }
3319    }
3320}
3321
3322/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelListener.
3323pub struct ChannelListenerRequestStream {
3324    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3325    is_terminated: bool,
3326}
3327
3328impl std::marker::Unpin for ChannelListenerRequestStream {}
3329
3330impl futures::stream::FusedStream for ChannelListenerRequestStream {
3331    fn is_terminated(&self) -> bool {
3332        self.is_terminated
3333    }
3334}
3335
3336impl fidl::endpoints::RequestStream for ChannelListenerRequestStream {
3337    type Protocol = ChannelListenerMarker;
3338    type ControlHandle = ChannelListenerControlHandle;
3339
3340    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3341        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3342    }
3343
3344    fn control_handle(&self) -> Self::ControlHandle {
3345        ChannelListenerControlHandle { inner: self.inner.clone() }
3346    }
3347
3348    fn into_inner(
3349        self,
3350    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3351    {
3352        (self.inner, self.is_terminated)
3353    }
3354
3355    fn from_inner(
3356        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3357        is_terminated: bool,
3358    ) -> Self {
3359        Self { inner, is_terminated }
3360    }
3361}
3362
3363impl futures::Stream for ChannelListenerRequestStream {
3364    type Item = Result<ChannelListenerRequest, fidl::Error>;
3365
3366    fn poll_next(
3367        mut self: std::pin::Pin<&mut Self>,
3368        cx: &mut std::task::Context<'_>,
3369    ) -> std::task::Poll<Option<Self::Item>> {
3370        let this = &mut *self;
3371        if this.inner.check_shutdown(cx) {
3372            this.is_terminated = true;
3373            return std::task::Poll::Ready(None);
3374        }
3375        if this.is_terminated {
3376            panic!("polled ChannelListenerRequestStream after completion");
3377        }
3378        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3379            |bytes, handles| {
3380                match this.inner.channel().read_etc(cx, bytes, handles) {
3381                    std::task::Poll::Ready(Ok(())) => {}
3382                    std::task::Poll::Pending => return std::task::Poll::Pending,
3383                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3384                        this.is_terminated = true;
3385                        return std::task::Poll::Ready(None);
3386                    }
3387                    std::task::Poll::Ready(Err(e)) => {
3388                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3389                            e.into(),
3390                        ))))
3391                    }
3392                }
3393
3394                // A message has been received from the channel
3395                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3396
3397                std::task::Poll::Ready(Some(match header.ordinal {
3398                    0x6f535bd36b20fc7b => {
3399                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3400                        let mut req = fidl::new_empty!(
3401                            ChannelListenerAcceptRequest,
3402                            fidl::encoding::DefaultFuchsiaResourceDialect
3403                        );
3404                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
3405                        let control_handle =
3406                            ChannelListenerControlHandle { inner: this.inner.clone() };
3407                        Ok(ChannelListenerRequest::Accept {
3408                            channel: req.channel,
3409
3410                            responder: ChannelListenerAcceptResponder {
3411                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3412                                tx_id: header.tx_id,
3413                            },
3414                        })
3415                    }
3416                    _ if header.tx_id == 0
3417                        && header
3418                            .dynamic_flags()
3419                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3420                    {
3421                        Ok(ChannelListenerRequest::_UnknownMethod {
3422                            ordinal: header.ordinal,
3423                            control_handle: ChannelListenerControlHandle {
3424                                inner: this.inner.clone(),
3425                            },
3426                            method_type: fidl::MethodType::OneWay,
3427                        })
3428                    }
3429                    _ if header
3430                        .dynamic_flags()
3431                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3432                    {
3433                        this.inner.send_framework_err(
3434                            fidl::encoding::FrameworkErr::UnknownMethod,
3435                            header.tx_id,
3436                            header.ordinal,
3437                            header.dynamic_flags(),
3438                            (bytes, handles),
3439                        )?;
3440                        Ok(ChannelListenerRequest::_UnknownMethod {
3441                            ordinal: header.ordinal,
3442                            control_handle: ChannelListenerControlHandle {
3443                                inner: this.inner.clone(),
3444                            },
3445                            method_type: fidl::MethodType::TwoWay,
3446                        })
3447                    }
3448                    _ => Err(fidl::Error::UnknownOrdinal {
3449                        ordinal: header.ordinal,
3450                        protocol_name:
3451                            <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3452                    }),
3453                }))
3454            },
3455        )
3456    }
3457}
3458
3459/// Represents a service or protocol that accepts incoming channel requests.
3460/// Incoming channel requests for the associated PSM will be connected via this
3461/// protocol. Closing this protocol will also cease accepting any incoming
3462/// channel requests, but existing established channels will not be affected.
3463/// Additionally, once this protocol is closed the implementation is free to
3464/// reuse the PSM that was previously assigned for this instance.
3465#[derive(Debug)]
3466pub enum ChannelListenerRequest {
3467    Accept {
3468        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3469        responder: ChannelListenerAcceptResponder,
3470    },
3471    /// An interaction was received which does not match any known method.
3472    #[non_exhaustive]
3473    _UnknownMethod {
3474        /// Ordinal of the method that was called.
3475        ordinal: u64,
3476        control_handle: ChannelListenerControlHandle,
3477        method_type: fidl::MethodType,
3478    },
3479}
3480
3481impl ChannelListenerRequest {
3482    #[allow(irrefutable_let_patterns)]
3483    pub fn into_accept(
3484        self,
3485    ) -> Option<(
3486        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3487        ChannelListenerAcceptResponder,
3488    )> {
3489        if let ChannelListenerRequest::Accept { channel, responder } = self {
3490            Some((channel, responder))
3491        } else {
3492            None
3493        }
3494    }
3495
3496    /// Name of the method defined in FIDL
3497    pub fn method_name(&self) -> &'static str {
3498        match *self {
3499            ChannelListenerRequest::Accept { .. } => "accept",
3500            ChannelListenerRequest::_UnknownMethod {
3501                method_type: fidl::MethodType::OneWay,
3502                ..
3503            } => "unknown one-way method",
3504            ChannelListenerRequest::_UnknownMethod {
3505                method_type: fidl::MethodType::TwoWay,
3506                ..
3507            } => "unknown two-way method",
3508        }
3509    }
3510}
3511
3512#[derive(Debug, Clone)]
3513pub struct ChannelListenerControlHandle {
3514    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3515}
3516
3517impl fidl::endpoints::ControlHandle for ChannelListenerControlHandle {
3518    fn shutdown(&self) {
3519        self.inner.shutdown()
3520    }
3521    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3522        self.inner.shutdown_with_epitaph(status)
3523    }
3524
3525    fn is_closed(&self) -> bool {
3526        self.inner.channel().is_closed()
3527    }
3528    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3529        self.inner.channel().on_closed()
3530    }
3531
3532    #[cfg(target_os = "fuchsia")]
3533    fn signal_peer(
3534        &self,
3535        clear_mask: zx::Signals,
3536        set_mask: zx::Signals,
3537    ) -> Result<(), zx_status::Status> {
3538        use fidl::Peered;
3539        self.inner.channel().signal_peer(clear_mask, set_mask)
3540    }
3541}
3542
3543impl ChannelListenerControlHandle {}
3544
3545#[must_use = "FIDL methods require a response to be sent"]
3546#[derive(Debug)]
3547pub struct ChannelListenerAcceptResponder {
3548    control_handle: std::mem::ManuallyDrop<ChannelListenerControlHandle>,
3549    tx_id: u32,
3550}
3551
3552/// Set the the channel to be shutdown (see [`ChannelListenerControlHandle::shutdown`])
3553/// if the responder is dropped without sending a response, so that the client
3554/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3555impl std::ops::Drop for ChannelListenerAcceptResponder {
3556    fn drop(&mut self) {
3557        self.control_handle.shutdown();
3558        // Safety: drops once, never accessed again
3559        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3560    }
3561}
3562
3563impl fidl::endpoints::Responder for ChannelListenerAcceptResponder {
3564    type ControlHandle = ChannelListenerControlHandle;
3565
3566    fn control_handle(&self) -> &ChannelListenerControlHandle {
3567        &self.control_handle
3568    }
3569
3570    fn drop_without_shutdown(mut self) {
3571        // Safety: drops once, never accessed again due to mem::forget
3572        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3573        // Prevent Drop from running (which would shut down the channel)
3574        std::mem::forget(self);
3575    }
3576}
3577
3578impl ChannelListenerAcceptResponder {
3579    /// Sends a response to the FIDL transaction.
3580    ///
3581    /// Sets the channel to shutdown if an error occurs.
3582    pub fn send(self) -> Result<(), fidl::Error> {
3583        let _result = self.send_raw();
3584        if _result.is_err() {
3585            self.control_handle.shutdown();
3586        }
3587        self.drop_without_shutdown();
3588        _result
3589    }
3590
3591    /// Similar to "send" but does not shutdown the channel if an error occurs.
3592    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3593        let _result = self.send_raw();
3594        self.drop_without_shutdown();
3595        _result
3596    }
3597
3598    fn send_raw(&self) -> Result<(), fidl::Error> {
3599        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3600            fidl::encoding::Flexible::new(()),
3601            self.tx_id,
3602            0x6f535bd36b20fc7b,
3603            fidl::encoding::DynamicFlags::FLEXIBLE,
3604        )
3605    }
3606}
3607
3608#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3609pub struct ChannelListenerRegistryMarker;
3610
3611impl fidl::endpoints::ProtocolMarker for ChannelListenerRegistryMarker {
3612    type Proxy = ChannelListenerRegistryProxy;
3613    type RequestStream = ChannelListenerRegistryRequestStream;
3614    #[cfg(target_os = "fuchsia")]
3615    type SynchronousProxy = ChannelListenerRegistrySynchronousProxy;
3616
3617    const DEBUG_NAME: &'static str = "(anonymous) ChannelListenerRegistry";
3618}
3619pub type ChannelListenerRegistryListenL2capResult =
3620    Result<ChannelListenerRegistryListenL2capResponse, i32>;
3621
3622pub trait ChannelListenerRegistryProxyInterface: Send + Sync {
3623    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
3624        + Send;
3625    fn r#listen_l2cap(
3626        &self,
3627        payload: ChannelListenerRegistryListenL2capRequest,
3628    ) -> Self::ListenL2capResponseFut;
3629}
3630#[derive(Debug)]
3631#[cfg(target_os = "fuchsia")]
3632pub struct ChannelListenerRegistrySynchronousProxy {
3633    client: fidl::client::sync::Client,
3634}
3635
3636#[cfg(target_os = "fuchsia")]
3637impl fidl::endpoints::SynchronousProxy for ChannelListenerRegistrySynchronousProxy {
3638    type Proxy = ChannelListenerRegistryProxy;
3639    type Protocol = ChannelListenerRegistryMarker;
3640
3641    fn from_channel(inner: fidl::Channel) -> Self {
3642        Self::new(inner)
3643    }
3644
3645    fn into_channel(self) -> fidl::Channel {
3646        self.client.into_channel()
3647    }
3648
3649    fn as_channel(&self) -> &fidl::Channel {
3650        self.client.as_channel()
3651    }
3652}
3653
3654#[cfg(target_os = "fuchsia")]
3655impl ChannelListenerRegistrySynchronousProxy {
3656    pub fn new(channel: fidl::Channel) -> Self {
3657        let protocol_name =
3658            <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3659        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3660    }
3661
3662    pub fn into_channel(self) -> fidl::Channel {
3663        self.client.into_channel()
3664    }
3665
3666    /// Waits until an event arrives and returns it. It is safe for other
3667    /// threads to make concurrent requests while waiting for an event.
3668    pub fn wait_for_event(
3669        &self,
3670        deadline: zx::MonotonicInstant,
3671    ) -> Result<ChannelListenerRegistryEvent, fidl::Error> {
3672        ChannelListenerRegistryEvent::decode(self.client.wait_for_event(deadline)?)
3673    }
3674
3675    /// Register a listener for incoming channels. The registry will assign a
3676    /// PSM value that is unique for the local device, as well as open a
3677    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
3678    /// event that all PSMs have been assigned, this call will fail with
3679    /// `ZX_ERR_NO_RESOURCES`.
3680    ///
3681    /// Note that the method of service discovery or advertising is defined by
3682    /// the service or protocol, so it is the responsibility of the caller to
3683    /// communicate the assigned PSM to any clients.
3684    pub fn r#listen_l2cap(
3685        &self,
3686        mut payload: ChannelListenerRegistryListenL2capRequest,
3687        ___deadline: zx::MonotonicInstant,
3688    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
3689        let _response = self.client.send_query::<
3690            ChannelListenerRegistryListenL2capRequest,
3691            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
3692        >(
3693            &mut payload,
3694            0x39c6e9001d102338,
3695            fidl::encoding::DynamicFlags::empty(),
3696            ___deadline,
3697        )?;
3698        Ok(_response.map(|x| x))
3699    }
3700}
3701
3702#[cfg(target_os = "fuchsia")]
3703impl From<ChannelListenerRegistrySynchronousProxy> for zx::Handle {
3704    fn from(value: ChannelListenerRegistrySynchronousProxy) -> Self {
3705        value.into_channel().into()
3706    }
3707}
3708
3709#[cfg(target_os = "fuchsia")]
3710impl From<fidl::Channel> for ChannelListenerRegistrySynchronousProxy {
3711    fn from(value: fidl::Channel) -> Self {
3712        Self::new(value)
3713    }
3714}
3715
3716#[cfg(target_os = "fuchsia")]
3717impl fidl::endpoints::FromClient for ChannelListenerRegistrySynchronousProxy {
3718    type Protocol = ChannelListenerRegistryMarker;
3719
3720    fn from_client(value: fidl::endpoints::ClientEnd<ChannelListenerRegistryMarker>) -> Self {
3721        Self::new(value.into_channel())
3722    }
3723}
3724
3725#[derive(Debug, Clone)]
3726pub struct ChannelListenerRegistryProxy {
3727    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3728}
3729
3730impl fidl::endpoints::Proxy for ChannelListenerRegistryProxy {
3731    type Protocol = ChannelListenerRegistryMarker;
3732
3733    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3734        Self::new(inner)
3735    }
3736
3737    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3738        self.client.into_channel().map_err(|client| Self { client })
3739    }
3740
3741    fn as_channel(&self) -> &::fidl::AsyncChannel {
3742        self.client.as_channel()
3743    }
3744}
3745
3746impl ChannelListenerRegistryProxy {
3747    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelListenerRegistry.
3748    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3749        let protocol_name =
3750            <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3751        Self { client: fidl::client::Client::new(channel, protocol_name) }
3752    }
3753
3754    /// Get a Stream of events from the remote end of the protocol.
3755    ///
3756    /// # Panics
3757    ///
3758    /// Panics if the event stream was already taken.
3759    pub fn take_event_stream(&self) -> ChannelListenerRegistryEventStream {
3760        ChannelListenerRegistryEventStream { event_receiver: self.client.take_event_receiver() }
3761    }
3762
3763    /// Register a listener for incoming channels. The registry will assign a
3764    /// PSM value that is unique for the local device, as well as open a
3765    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
3766    /// event that all PSMs have been assigned, this call will fail with
3767    /// `ZX_ERR_NO_RESOURCES`.
3768    ///
3769    /// Note that the method of service discovery or advertising is defined by
3770    /// the service or protocol, so it is the responsibility of the caller to
3771    /// communicate the assigned PSM to any clients.
3772    pub fn r#listen_l2cap(
3773        &self,
3774        mut payload: ChannelListenerRegistryListenL2capRequest,
3775    ) -> fidl::client::QueryResponseFut<
3776        ChannelListenerRegistryListenL2capResult,
3777        fidl::encoding::DefaultFuchsiaResourceDialect,
3778    > {
3779        ChannelListenerRegistryProxyInterface::r#listen_l2cap(self, payload)
3780    }
3781}
3782
3783impl ChannelListenerRegistryProxyInterface for ChannelListenerRegistryProxy {
3784    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
3785        ChannelListenerRegistryListenL2capResult,
3786        fidl::encoding::DefaultFuchsiaResourceDialect,
3787    >;
3788    fn r#listen_l2cap(
3789        &self,
3790        mut payload: ChannelListenerRegistryListenL2capRequest,
3791    ) -> Self::ListenL2capResponseFut {
3792        fn _decode(
3793            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3794        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
3795            let _response = fidl::client::decode_transaction_body::<
3796                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
3797                fidl::encoding::DefaultFuchsiaResourceDialect,
3798                0x39c6e9001d102338,
3799            >(_buf?)?;
3800            Ok(_response.map(|x| x))
3801        }
3802        self.client.send_query_and_decode::<
3803            ChannelListenerRegistryListenL2capRequest,
3804            ChannelListenerRegistryListenL2capResult,
3805        >(
3806            &mut payload,
3807            0x39c6e9001d102338,
3808            fidl::encoding::DynamicFlags::empty(),
3809            _decode,
3810        )
3811    }
3812}
3813
3814pub struct ChannelListenerRegistryEventStream {
3815    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3816}
3817
3818impl std::marker::Unpin for ChannelListenerRegistryEventStream {}
3819
3820impl futures::stream::FusedStream for ChannelListenerRegistryEventStream {
3821    fn is_terminated(&self) -> bool {
3822        self.event_receiver.is_terminated()
3823    }
3824}
3825
3826impl futures::Stream for ChannelListenerRegistryEventStream {
3827    type Item = Result<ChannelListenerRegistryEvent, fidl::Error>;
3828
3829    fn poll_next(
3830        mut self: std::pin::Pin<&mut Self>,
3831        cx: &mut std::task::Context<'_>,
3832    ) -> std::task::Poll<Option<Self::Item>> {
3833        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3834            &mut self.event_receiver,
3835            cx
3836        )?) {
3837            Some(buf) => std::task::Poll::Ready(Some(ChannelListenerRegistryEvent::decode(buf))),
3838            None => std::task::Poll::Ready(None),
3839        }
3840    }
3841}
3842
3843#[derive(Debug)]
3844pub enum ChannelListenerRegistryEvent {}
3845
3846impl ChannelListenerRegistryEvent {
3847    /// Decodes a message buffer as a [`ChannelListenerRegistryEvent`].
3848    fn decode(
3849        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3850    ) -> Result<ChannelListenerRegistryEvent, fidl::Error> {
3851        let (bytes, _handles) = buf.split_mut();
3852        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3853        debug_assert_eq!(tx_header.tx_id, 0);
3854        match tx_header.ordinal {
3855            _ => Err(fidl::Error::UnknownOrdinal {
3856                ordinal: tx_header.ordinal,
3857                protocol_name:
3858                    <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3859            }),
3860        }
3861    }
3862}
3863
3864/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelListenerRegistry.
3865pub struct ChannelListenerRegistryRequestStream {
3866    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3867    is_terminated: bool,
3868}
3869
3870impl std::marker::Unpin for ChannelListenerRegistryRequestStream {}
3871
3872impl futures::stream::FusedStream for ChannelListenerRegistryRequestStream {
3873    fn is_terminated(&self) -> bool {
3874        self.is_terminated
3875    }
3876}
3877
3878impl fidl::endpoints::RequestStream for ChannelListenerRegistryRequestStream {
3879    type Protocol = ChannelListenerRegistryMarker;
3880    type ControlHandle = ChannelListenerRegistryControlHandle;
3881
3882    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3883        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3884    }
3885
3886    fn control_handle(&self) -> Self::ControlHandle {
3887        ChannelListenerRegistryControlHandle { inner: self.inner.clone() }
3888    }
3889
3890    fn into_inner(
3891        self,
3892    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3893    {
3894        (self.inner, self.is_terminated)
3895    }
3896
3897    fn from_inner(
3898        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3899        is_terminated: bool,
3900    ) -> Self {
3901        Self { inner, is_terminated }
3902    }
3903}
3904
3905impl futures::Stream for ChannelListenerRegistryRequestStream {
3906    type Item = Result<ChannelListenerRegistryRequest, fidl::Error>;
3907
3908    fn poll_next(
3909        mut self: std::pin::Pin<&mut Self>,
3910        cx: &mut std::task::Context<'_>,
3911    ) -> std::task::Poll<Option<Self::Item>> {
3912        let this = &mut *self;
3913        if this.inner.check_shutdown(cx) {
3914            this.is_terminated = true;
3915            return std::task::Poll::Ready(None);
3916        }
3917        if this.is_terminated {
3918            panic!("polled ChannelListenerRegistryRequestStream after completion");
3919        }
3920        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3921            |bytes, handles| {
3922                match this.inner.channel().read_etc(cx, bytes, handles) {
3923                    std::task::Poll::Ready(Ok(())) => {}
3924                    std::task::Poll::Pending => return std::task::Poll::Pending,
3925                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3926                        this.is_terminated = true;
3927                        return std::task::Poll::Ready(None);
3928                    }
3929                    std::task::Poll::Ready(Err(e)) => {
3930                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3931                            e.into(),
3932                        ))))
3933                    }
3934                }
3935
3936                // A message has been received from the channel
3937                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3938
3939                std::task::Poll::Ready(Some(match header.ordinal {
3940                0x39c6e9001d102338 => {
3941                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3942                    let mut req = fidl::new_empty!(ChannelListenerRegistryListenL2capRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
3943                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
3944                    let control_handle = ChannelListenerRegistryControlHandle {
3945                        inner: this.inner.clone(),
3946                    };
3947                    Ok(ChannelListenerRegistryRequest::ListenL2cap {payload: req,
3948                        responder: ChannelListenerRegistryListenL2capResponder {
3949                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3950                            tx_id: header.tx_id,
3951                        },
3952                    })
3953                }
3954                _ => Err(fidl::Error::UnknownOrdinal {
3955                    ordinal: header.ordinal,
3956                    protocol_name: <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3957                }),
3958            }))
3959            },
3960        )
3961    }
3962}
3963
3964/// Represents the ability to register and accept incoming connections on
3965/// connection oriented channels.
3966#[derive(Debug)]
3967pub enum ChannelListenerRegistryRequest {
3968    /// Register a listener for incoming channels. The registry will assign a
3969    /// PSM value that is unique for the local device, as well as open a
3970    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
3971    /// event that all PSMs have been assigned, this call will fail with
3972    /// `ZX_ERR_NO_RESOURCES`.
3973    ///
3974    /// Note that the method of service discovery or advertising is defined by
3975    /// the service or protocol, so it is the responsibility of the caller to
3976    /// communicate the assigned PSM to any clients.
3977    ListenL2cap {
3978        payload: ChannelListenerRegistryListenL2capRequest,
3979        responder: ChannelListenerRegistryListenL2capResponder,
3980    },
3981}
3982
3983impl ChannelListenerRegistryRequest {
3984    #[allow(irrefutable_let_patterns)]
3985    pub fn into_listen_l2cap(
3986        self,
3987    ) -> Option<(
3988        ChannelListenerRegistryListenL2capRequest,
3989        ChannelListenerRegistryListenL2capResponder,
3990    )> {
3991        if let ChannelListenerRegistryRequest::ListenL2cap { payload, responder } = self {
3992            Some((payload, responder))
3993        } else {
3994            None
3995        }
3996    }
3997
3998    /// Name of the method defined in FIDL
3999    pub fn method_name(&self) -> &'static str {
4000        match *self {
4001            ChannelListenerRegistryRequest::ListenL2cap { .. } => "listen_l2cap",
4002        }
4003    }
4004}
4005
4006#[derive(Debug, Clone)]
4007pub struct ChannelListenerRegistryControlHandle {
4008    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4009}
4010
4011impl fidl::endpoints::ControlHandle for ChannelListenerRegistryControlHandle {
4012    fn shutdown(&self) {
4013        self.inner.shutdown()
4014    }
4015    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4016        self.inner.shutdown_with_epitaph(status)
4017    }
4018
4019    fn is_closed(&self) -> bool {
4020        self.inner.channel().is_closed()
4021    }
4022    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4023        self.inner.channel().on_closed()
4024    }
4025
4026    #[cfg(target_os = "fuchsia")]
4027    fn signal_peer(
4028        &self,
4029        clear_mask: zx::Signals,
4030        set_mask: zx::Signals,
4031    ) -> Result<(), zx_status::Status> {
4032        use fidl::Peered;
4033        self.inner.channel().signal_peer(clear_mask, set_mask)
4034    }
4035}
4036
4037impl ChannelListenerRegistryControlHandle {}
4038
4039#[must_use = "FIDL methods require a response to be sent"]
4040#[derive(Debug)]
4041pub struct ChannelListenerRegistryListenL2capResponder {
4042    control_handle: std::mem::ManuallyDrop<ChannelListenerRegistryControlHandle>,
4043    tx_id: u32,
4044}
4045
4046/// Set the the channel to be shutdown (see [`ChannelListenerRegistryControlHandle::shutdown`])
4047/// if the responder is dropped without sending a response, so that the client
4048/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4049impl std::ops::Drop for ChannelListenerRegistryListenL2capResponder {
4050    fn drop(&mut self) {
4051        self.control_handle.shutdown();
4052        // Safety: drops once, never accessed again
4053        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4054    }
4055}
4056
4057impl fidl::endpoints::Responder for ChannelListenerRegistryListenL2capResponder {
4058    type ControlHandle = ChannelListenerRegistryControlHandle;
4059
4060    fn control_handle(&self) -> &ChannelListenerRegistryControlHandle {
4061        &self.control_handle
4062    }
4063
4064    fn drop_without_shutdown(mut self) {
4065        // Safety: drops once, never accessed again due to mem::forget
4066        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4067        // Prevent Drop from running (which would shut down the channel)
4068        std::mem::forget(self);
4069    }
4070}
4071
4072impl ChannelListenerRegistryListenL2capResponder {
4073    /// Sends a response to the FIDL transaction.
4074    ///
4075    /// Sets the channel to shutdown if an error occurs.
4076    pub fn send(
4077        self,
4078        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4079    ) -> Result<(), fidl::Error> {
4080        let _result = self.send_raw(result);
4081        if _result.is_err() {
4082            self.control_handle.shutdown();
4083        }
4084        self.drop_without_shutdown();
4085        _result
4086    }
4087
4088    /// Similar to "send" but does not shutdown the channel if an error occurs.
4089    pub fn send_no_shutdown_on_err(
4090        self,
4091        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4092    ) -> Result<(), fidl::Error> {
4093        let _result = self.send_raw(result);
4094        self.drop_without_shutdown();
4095        _result
4096    }
4097
4098    fn send_raw(
4099        &self,
4100        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4101    ) -> Result<(), fidl::Error> {
4102        self.control_handle.inner.send::<fidl::encoding::ResultType<
4103            ChannelListenerRegistryListenL2capResponse,
4104            i32,
4105        >>(
4106            result,
4107            self.tx_id,
4108            0x39c6e9001d102338,
4109            fidl::encoding::DynamicFlags::empty(),
4110        )
4111    }
4112}
4113
4114#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4115pub struct CodecDelayMarker;
4116
4117impl fidl::endpoints::ProtocolMarker for CodecDelayMarker {
4118    type Proxy = CodecDelayProxy;
4119    type RequestStream = CodecDelayRequestStream;
4120    #[cfg(target_os = "fuchsia")]
4121    type SynchronousProxy = CodecDelaySynchronousProxy;
4122
4123    const DEBUG_NAME: &'static str = "(anonymous) CodecDelay";
4124}
4125pub type CodecDelayGetCodecLocalDelayRangeResult =
4126    Result<CodecDelayGetCodecLocalDelayRangeResponse, i32>;
4127
4128pub trait CodecDelayProxyInterface: Send + Sync {
4129    type GetCodecLocalDelayRangeResponseFut: std::future::Future<Output = Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error>>
4130        + Send;
4131    fn r#get_codec_local_delay_range(
4132        &self,
4133        payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4134    ) -> Self::GetCodecLocalDelayRangeResponseFut;
4135}
4136#[derive(Debug)]
4137#[cfg(target_os = "fuchsia")]
4138pub struct CodecDelaySynchronousProxy {
4139    client: fidl::client::sync::Client,
4140}
4141
4142#[cfg(target_os = "fuchsia")]
4143impl fidl::endpoints::SynchronousProxy for CodecDelaySynchronousProxy {
4144    type Proxy = CodecDelayProxy;
4145    type Protocol = CodecDelayMarker;
4146
4147    fn from_channel(inner: fidl::Channel) -> Self {
4148        Self::new(inner)
4149    }
4150
4151    fn into_channel(self) -> fidl::Channel {
4152        self.client.into_channel()
4153    }
4154
4155    fn as_channel(&self) -> &fidl::Channel {
4156        self.client.as_channel()
4157    }
4158}
4159
4160#[cfg(target_os = "fuchsia")]
4161impl CodecDelaySynchronousProxy {
4162    pub fn new(channel: fidl::Channel) -> Self {
4163        let protocol_name = <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4164        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4165    }
4166
4167    pub fn into_channel(self) -> fidl::Channel {
4168        self.client.into_channel()
4169    }
4170
4171    /// Waits until an event arrives and returns it. It is safe for other
4172    /// threads to make concurrent requests while waiting for an event.
4173    pub fn wait_for_event(
4174        &self,
4175        deadline: zx::MonotonicInstant,
4176    ) -> Result<CodecDelayEvent, fidl::Error> {
4177        CodecDelayEvent::decode(self.client.wait_for_event(deadline)?)
4178    }
4179
4180    /// Retrieve the range of controller delay for the codec specified with the provided stream
4181    /// attributes.
4182    ///
4183    /// On success, returns the minimum and maximum allowed delay.
4184    ///
4185    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
4186    /// Returns ZX_ERR_INTERNAL for all other failures.
4187    pub fn r#get_codec_local_delay_range(
4188        &self,
4189        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4190        ___deadline: zx::MonotonicInstant,
4191    ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
4192        let _response = self.client.send_query::<
4193            CodecDelayGetCodecLocalDelayRangeRequest,
4194            fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4195        >(
4196            payload,
4197            0x1cf34fdeed80b4d,
4198            fidl::encoding::DynamicFlags::empty(),
4199            ___deadline,
4200        )?;
4201        Ok(_response.map(|x| x))
4202    }
4203}
4204
4205#[cfg(target_os = "fuchsia")]
4206impl From<CodecDelaySynchronousProxy> for zx::Handle {
4207    fn from(value: CodecDelaySynchronousProxy) -> Self {
4208        value.into_channel().into()
4209    }
4210}
4211
4212#[cfg(target_os = "fuchsia")]
4213impl From<fidl::Channel> for CodecDelaySynchronousProxy {
4214    fn from(value: fidl::Channel) -> Self {
4215        Self::new(value)
4216    }
4217}
4218
4219#[cfg(target_os = "fuchsia")]
4220impl fidl::endpoints::FromClient for CodecDelaySynchronousProxy {
4221    type Protocol = CodecDelayMarker;
4222
4223    fn from_client(value: fidl::endpoints::ClientEnd<CodecDelayMarker>) -> Self {
4224        Self::new(value.into_channel())
4225    }
4226}
4227
4228#[derive(Debug, Clone)]
4229pub struct CodecDelayProxy {
4230    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4231}
4232
4233impl fidl::endpoints::Proxy for CodecDelayProxy {
4234    type Protocol = CodecDelayMarker;
4235
4236    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4237        Self::new(inner)
4238    }
4239
4240    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4241        self.client.into_channel().map_err(|client| Self { client })
4242    }
4243
4244    fn as_channel(&self) -> &::fidl::AsyncChannel {
4245        self.client.as_channel()
4246    }
4247}
4248
4249impl CodecDelayProxy {
4250    /// Create a new Proxy for fuchsia.bluetooth.le/CodecDelay.
4251    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4252        let protocol_name = <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4253        Self { client: fidl::client::Client::new(channel, protocol_name) }
4254    }
4255
4256    /// Get a Stream of events from the remote end of the protocol.
4257    ///
4258    /// # Panics
4259    ///
4260    /// Panics if the event stream was already taken.
4261    pub fn take_event_stream(&self) -> CodecDelayEventStream {
4262        CodecDelayEventStream { event_receiver: self.client.take_event_receiver() }
4263    }
4264
4265    /// Retrieve the range of controller delay for the codec specified with the provided stream
4266    /// attributes.
4267    ///
4268    /// On success, returns the minimum and maximum allowed delay.
4269    ///
4270    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
4271    /// Returns ZX_ERR_INTERNAL for all other failures.
4272    pub fn r#get_codec_local_delay_range(
4273        &self,
4274        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4275    ) -> fidl::client::QueryResponseFut<
4276        CodecDelayGetCodecLocalDelayRangeResult,
4277        fidl::encoding::DefaultFuchsiaResourceDialect,
4278    > {
4279        CodecDelayProxyInterface::r#get_codec_local_delay_range(self, payload)
4280    }
4281}
4282
4283impl CodecDelayProxyInterface for CodecDelayProxy {
4284    type GetCodecLocalDelayRangeResponseFut = fidl::client::QueryResponseFut<
4285        CodecDelayGetCodecLocalDelayRangeResult,
4286        fidl::encoding::DefaultFuchsiaResourceDialect,
4287    >;
4288    fn r#get_codec_local_delay_range(
4289        &self,
4290        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4291    ) -> Self::GetCodecLocalDelayRangeResponseFut {
4292        fn _decode(
4293            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4294        ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
4295            let _response = fidl::client::decode_transaction_body::<
4296                fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4297                fidl::encoding::DefaultFuchsiaResourceDialect,
4298                0x1cf34fdeed80b4d,
4299            >(_buf?)?;
4300            Ok(_response.map(|x| x))
4301        }
4302        self.client.send_query_and_decode::<
4303            CodecDelayGetCodecLocalDelayRangeRequest,
4304            CodecDelayGetCodecLocalDelayRangeResult,
4305        >(
4306            payload,
4307            0x1cf34fdeed80b4d,
4308            fidl::encoding::DynamicFlags::empty(),
4309            _decode,
4310        )
4311    }
4312}
4313
4314pub struct CodecDelayEventStream {
4315    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4316}
4317
4318impl std::marker::Unpin for CodecDelayEventStream {}
4319
4320impl futures::stream::FusedStream for CodecDelayEventStream {
4321    fn is_terminated(&self) -> bool {
4322        self.event_receiver.is_terminated()
4323    }
4324}
4325
4326impl futures::Stream for CodecDelayEventStream {
4327    type Item = Result<CodecDelayEvent, fidl::Error>;
4328
4329    fn poll_next(
4330        mut self: std::pin::Pin<&mut Self>,
4331        cx: &mut std::task::Context<'_>,
4332    ) -> std::task::Poll<Option<Self::Item>> {
4333        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4334            &mut self.event_receiver,
4335            cx
4336        )?) {
4337            Some(buf) => std::task::Poll::Ready(Some(CodecDelayEvent::decode(buf))),
4338            None => std::task::Poll::Ready(None),
4339        }
4340    }
4341}
4342
4343#[derive(Debug)]
4344pub enum CodecDelayEvent {}
4345
4346impl CodecDelayEvent {
4347    /// Decodes a message buffer as a [`CodecDelayEvent`].
4348    fn decode(
4349        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4350    ) -> Result<CodecDelayEvent, fidl::Error> {
4351        let (bytes, _handles) = buf.split_mut();
4352        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4353        debug_assert_eq!(tx_header.tx_id, 0);
4354        match tx_header.ordinal {
4355            _ => Err(fidl::Error::UnknownOrdinal {
4356                ordinal: tx_header.ordinal,
4357                protocol_name: <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4358            }),
4359        }
4360    }
4361}
4362
4363/// A Stream of incoming requests for fuchsia.bluetooth.le/CodecDelay.
4364pub struct CodecDelayRequestStream {
4365    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4366    is_terminated: bool,
4367}
4368
4369impl std::marker::Unpin for CodecDelayRequestStream {}
4370
4371impl futures::stream::FusedStream for CodecDelayRequestStream {
4372    fn is_terminated(&self) -> bool {
4373        self.is_terminated
4374    }
4375}
4376
4377impl fidl::endpoints::RequestStream for CodecDelayRequestStream {
4378    type Protocol = CodecDelayMarker;
4379    type ControlHandle = CodecDelayControlHandle;
4380
4381    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4382        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4383    }
4384
4385    fn control_handle(&self) -> Self::ControlHandle {
4386        CodecDelayControlHandle { inner: self.inner.clone() }
4387    }
4388
4389    fn into_inner(
4390        self,
4391    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4392    {
4393        (self.inner, self.is_terminated)
4394    }
4395
4396    fn from_inner(
4397        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4398        is_terminated: bool,
4399    ) -> Self {
4400        Self { inner, is_terminated }
4401    }
4402}
4403
4404impl futures::Stream for CodecDelayRequestStream {
4405    type Item = Result<CodecDelayRequest, fidl::Error>;
4406
4407    fn poll_next(
4408        mut self: std::pin::Pin<&mut Self>,
4409        cx: &mut std::task::Context<'_>,
4410    ) -> std::task::Poll<Option<Self::Item>> {
4411        let this = &mut *self;
4412        if this.inner.check_shutdown(cx) {
4413            this.is_terminated = true;
4414            return std::task::Poll::Ready(None);
4415        }
4416        if this.is_terminated {
4417            panic!("polled CodecDelayRequestStream after completion");
4418        }
4419        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4420            |bytes, handles| {
4421                match this.inner.channel().read_etc(cx, bytes, handles) {
4422                    std::task::Poll::Ready(Ok(())) => {}
4423                    std::task::Poll::Pending => return std::task::Poll::Pending,
4424                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4425                        this.is_terminated = true;
4426                        return std::task::Poll::Ready(None);
4427                    }
4428                    std::task::Poll::Ready(Err(e)) => {
4429                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4430                            e.into(),
4431                        ))))
4432                    }
4433                }
4434
4435                // A message has been received from the channel
4436                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4437
4438                std::task::Poll::Ready(Some(match header.ordinal {
4439                    0x1cf34fdeed80b4d => {
4440                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4441                        let mut req = fidl::new_empty!(
4442                            CodecDelayGetCodecLocalDelayRangeRequest,
4443                            fidl::encoding::DefaultFuchsiaResourceDialect
4444                        );
4445                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecDelayGetCodecLocalDelayRangeRequest>(&header, _body_bytes, handles, &mut req)?;
4446                        let control_handle = CodecDelayControlHandle { inner: this.inner.clone() };
4447                        Ok(CodecDelayRequest::GetCodecLocalDelayRange {
4448                            payload: req,
4449                            responder: CodecDelayGetCodecLocalDelayRangeResponder {
4450                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4451                                tx_id: header.tx_id,
4452                            },
4453                        })
4454                    }
4455                    _ => Err(fidl::Error::UnknownOrdinal {
4456                        ordinal: header.ordinal,
4457                        protocol_name:
4458                            <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4459                    }),
4460                }))
4461            },
4462        )
4463    }
4464}
4465
4466/// This protocol allows us to retrieve controller local delay values. It is not intended to be
4467/// used stand-alone, but to be composed into protocols that need access to this information.
4468#[derive(Debug)]
4469pub enum CodecDelayRequest {
4470    /// Retrieve the range of controller delay for the codec specified with the provided stream
4471    /// attributes.
4472    ///
4473    /// On success, returns the minimum and maximum allowed delay.
4474    ///
4475    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
4476    /// Returns ZX_ERR_INTERNAL for all other failures.
4477    GetCodecLocalDelayRange {
4478        payload: CodecDelayGetCodecLocalDelayRangeRequest,
4479        responder: CodecDelayGetCodecLocalDelayRangeResponder,
4480    },
4481}
4482
4483impl CodecDelayRequest {
4484    #[allow(irrefutable_let_patterns)]
4485    pub fn into_get_codec_local_delay_range(
4486        self,
4487    ) -> Option<(
4488        CodecDelayGetCodecLocalDelayRangeRequest,
4489        CodecDelayGetCodecLocalDelayRangeResponder,
4490    )> {
4491        if let CodecDelayRequest::GetCodecLocalDelayRange { payload, responder } = self {
4492            Some((payload, responder))
4493        } else {
4494            None
4495        }
4496    }
4497
4498    /// Name of the method defined in FIDL
4499    pub fn method_name(&self) -> &'static str {
4500        match *self {
4501            CodecDelayRequest::GetCodecLocalDelayRange { .. } => "get_codec_local_delay_range",
4502        }
4503    }
4504}
4505
4506#[derive(Debug, Clone)]
4507pub struct CodecDelayControlHandle {
4508    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4509}
4510
4511impl fidl::endpoints::ControlHandle for CodecDelayControlHandle {
4512    fn shutdown(&self) {
4513        self.inner.shutdown()
4514    }
4515    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4516        self.inner.shutdown_with_epitaph(status)
4517    }
4518
4519    fn is_closed(&self) -> bool {
4520        self.inner.channel().is_closed()
4521    }
4522    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4523        self.inner.channel().on_closed()
4524    }
4525
4526    #[cfg(target_os = "fuchsia")]
4527    fn signal_peer(
4528        &self,
4529        clear_mask: zx::Signals,
4530        set_mask: zx::Signals,
4531    ) -> Result<(), zx_status::Status> {
4532        use fidl::Peered;
4533        self.inner.channel().signal_peer(clear_mask, set_mask)
4534    }
4535}
4536
4537impl CodecDelayControlHandle {}
4538
4539#[must_use = "FIDL methods require a response to be sent"]
4540#[derive(Debug)]
4541pub struct CodecDelayGetCodecLocalDelayRangeResponder {
4542    control_handle: std::mem::ManuallyDrop<CodecDelayControlHandle>,
4543    tx_id: u32,
4544}
4545
4546/// Set the the channel to be shutdown (see [`CodecDelayControlHandle::shutdown`])
4547/// if the responder is dropped without sending a response, so that the client
4548/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4549impl std::ops::Drop for CodecDelayGetCodecLocalDelayRangeResponder {
4550    fn drop(&mut self) {
4551        self.control_handle.shutdown();
4552        // Safety: drops once, never accessed again
4553        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4554    }
4555}
4556
4557impl fidl::endpoints::Responder for CodecDelayGetCodecLocalDelayRangeResponder {
4558    type ControlHandle = CodecDelayControlHandle;
4559
4560    fn control_handle(&self) -> &CodecDelayControlHandle {
4561        &self.control_handle
4562    }
4563
4564    fn drop_without_shutdown(mut self) {
4565        // Safety: drops once, never accessed again due to mem::forget
4566        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4567        // Prevent Drop from running (which would shut down the channel)
4568        std::mem::forget(self);
4569    }
4570}
4571
4572impl CodecDelayGetCodecLocalDelayRangeResponder {
4573    /// Sends a response to the FIDL transaction.
4574    ///
4575    /// Sets the channel to shutdown if an error occurs.
4576    pub fn send(
4577        self,
4578        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4579    ) -> Result<(), fidl::Error> {
4580        let _result = self.send_raw(result);
4581        if _result.is_err() {
4582            self.control_handle.shutdown();
4583        }
4584        self.drop_without_shutdown();
4585        _result
4586    }
4587
4588    /// Similar to "send" but does not shutdown the channel if an error occurs.
4589    pub fn send_no_shutdown_on_err(
4590        self,
4591        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4592    ) -> Result<(), fidl::Error> {
4593        let _result = self.send_raw(result);
4594        self.drop_without_shutdown();
4595        _result
4596    }
4597
4598    fn send_raw(
4599        &self,
4600        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
4601    ) -> Result<(), fidl::Error> {
4602        self.control_handle.inner.send::<fidl::encoding::ResultType<
4603            CodecDelayGetCodecLocalDelayRangeResponse,
4604            i32,
4605        >>(
4606            result,
4607            self.tx_id,
4608            0x1cf34fdeed80b4d,
4609            fidl::encoding::DynamicFlags::empty(),
4610        )
4611    }
4612}
4613
4614#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4615pub struct ConnectedIsochronousGroupMarker;
4616
4617impl fidl::endpoints::ProtocolMarker for ConnectedIsochronousGroupMarker {
4618    type Proxy = ConnectedIsochronousGroupProxy;
4619    type RequestStream = ConnectedIsochronousGroupRequestStream;
4620    #[cfg(target_os = "fuchsia")]
4621    type SynchronousProxy = ConnectedIsochronousGroupSynchronousProxy;
4622
4623    const DEBUG_NAME: &'static str = "(anonymous) ConnectedIsochronousGroup";
4624}
4625pub type ConnectedIsochronousGroupEstablishStreamsResult = Result<(), EstablishStreamsError>;
4626
4627pub trait ConnectedIsochronousGroupProxyInterface: Send + Sync {
4628    type EstablishStreamsResponseFut: std::future::Future<
4629            Output = Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error>,
4630        > + Send;
4631    fn r#establish_streams(
4632        &self,
4633        payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4634    ) -> Self::EstablishStreamsResponseFut;
4635    fn r#remove(&self) -> Result<(), fidl::Error>;
4636}
4637#[derive(Debug)]
4638#[cfg(target_os = "fuchsia")]
4639pub struct ConnectedIsochronousGroupSynchronousProxy {
4640    client: fidl::client::sync::Client,
4641}
4642
4643#[cfg(target_os = "fuchsia")]
4644impl fidl::endpoints::SynchronousProxy for ConnectedIsochronousGroupSynchronousProxy {
4645    type Proxy = ConnectedIsochronousGroupProxy;
4646    type Protocol = ConnectedIsochronousGroupMarker;
4647
4648    fn from_channel(inner: fidl::Channel) -> Self {
4649        Self::new(inner)
4650    }
4651
4652    fn into_channel(self) -> fidl::Channel {
4653        self.client.into_channel()
4654    }
4655
4656    fn as_channel(&self) -> &fidl::Channel {
4657        self.client.as_channel()
4658    }
4659}
4660
4661#[cfg(target_os = "fuchsia")]
4662impl ConnectedIsochronousGroupSynchronousProxy {
4663    pub fn new(channel: fidl::Channel) -> Self {
4664        let protocol_name =
4665            <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4666        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4667    }
4668
4669    pub fn into_channel(self) -> fidl::Channel {
4670        self.client.into_channel()
4671    }
4672
4673    /// Waits until an event arrives and returns it. It is safe for other
4674    /// threads to make concurrent requests while waiting for an event.
4675    pub fn wait_for_event(
4676        &self,
4677        deadline: zx::MonotonicInstant,
4678    ) -> Result<ConnectedIsochronousGroupEvent, fidl::Error> {
4679        ConnectedIsochronousGroupEvent::decode(self.client.wait_for_event(deadline)?)
4680    }
4681
4682    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
4683    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
4684    /// be sent on the IsochronousStream.
4685    ///
4686    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
4687    /// returned.
4688    ///
4689    /// Otherwise, this call returns once each CIS specified has connected.
4690    pub fn r#establish_streams(
4691        &self,
4692        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4693        ___deadline: zx::MonotonicInstant,
4694    ) -> Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error> {
4695        let _response = self.client.send_query::<
4696            ConnectedIsochronousGroupEstablishStreamsRequest,
4697            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EstablishStreamsError>,
4698        >(
4699            payload,
4700            0xc7296c5edb4dacc,
4701            fidl::encoding::DynamicFlags::FLEXIBLE,
4702            ___deadline,
4703        )?
4704        .into_result::<ConnectedIsochronousGroupMarker>("establish_streams")?;
4705        Ok(_response.map(|x| x))
4706    }
4707
4708    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
4709    /// all of the associated streams have closed and the group has been removed.
4710    pub fn r#remove(&self) -> Result<(), fidl::Error> {
4711        self.client.send::<fidl::encoding::EmptyPayload>(
4712            (),
4713            0xbed433babd20503,
4714            fidl::encoding::DynamicFlags::FLEXIBLE,
4715        )
4716    }
4717}
4718
4719#[cfg(target_os = "fuchsia")]
4720impl From<ConnectedIsochronousGroupSynchronousProxy> for zx::Handle {
4721    fn from(value: ConnectedIsochronousGroupSynchronousProxy) -> Self {
4722        value.into_channel().into()
4723    }
4724}
4725
4726#[cfg(target_os = "fuchsia")]
4727impl From<fidl::Channel> for ConnectedIsochronousGroupSynchronousProxy {
4728    fn from(value: fidl::Channel) -> Self {
4729        Self::new(value)
4730    }
4731}
4732
4733#[cfg(target_os = "fuchsia")]
4734impl fidl::endpoints::FromClient for ConnectedIsochronousGroupSynchronousProxy {
4735    type Protocol = ConnectedIsochronousGroupMarker;
4736
4737    fn from_client(value: fidl::endpoints::ClientEnd<ConnectedIsochronousGroupMarker>) -> Self {
4738        Self::new(value.into_channel())
4739    }
4740}
4741
4742#[derive(Debug, Clone)]
4743pub struct ConnectedIsochronousGroupProxy {
4744    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4745}
4746
4747impl fidl::endpoints::Proxy for ConnectedIsochronousGroupProxy {
4748    type Protocol = ConnectedIsochronousGroupMarker;
4749
4750    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4751        Self::new(inner)
4752    }
4753
4754    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4755        self.client.into_channel().map_err(|client| Self { client })
4756    }
4757
4758    fn as_channel(&self) -> &::fidl::AsyncChannel {
4759        self.client.as_channel()
4760    }
4761}
4762
4763impl ConnectedIsochronousGroupProxy {
4764    /// Create a new Proxy for fuchsia.bluetooth.le/ConnectedIsochronousGroup.
4765    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4766        let protocol_name =
4767            <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4768        Self { client: fidl::client::Client::new(channel, protocol_name) }
4769    }
4770
4771    /// Get a Stream of events from the remote end of the protocol.
4772    ///
4773    /// # Panics
4774    ///
4775    /// Panics if the event stream was already taken.
4776    pub fn take_event_stream(&self) -> ConnectedIsochronousGroupEventStream {
4777        ConnectedIsochronousGroupEventStream { event_receiver: self.client.take_event_receiver() }
4778    }
4779
4780    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
4781    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
4782    /// be sent on the IsochronousStream.
4783    ///
4784    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
4785    /// returned.
4786    ///
4787    /// Otherwise, this call returns once each CIS specified has connected.
4788    pub fn r#establish_streams(
4789        &self,
4790        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4791    ) -> fidl::client::QueryResponseFut<
4792        ConnectedIsochronousGroupEstablishStreamsResult,
4793        fidl::encoding::DefaultFuchsiaResourceDialect,
4794    > {
4795        ConnectedIsochronousGroupProxyInterface::r#establish_streams(self, payload)
4796    }
4797
4798    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
4799    /// all of the associated streams have closed and the group has been removed.
4800    pub fn r#remove(&self) -> Result<(), fidl::Error> {
4801        ConnectedIsochronousGroupProxyInterface::r#remove(self)
4802    }
4803}
4804
4805impl ConnectedIsochronousGroupProxyInterface for ConnectedIsochronousGroupProxy {
4806    type EstablishStreamsResponseFut = fidl::client::QueryResponseFut<
4807        ConnectedIsochronousGroupEstablishStreamsResult,
4808        fidl::encoding::DefaultFuchsiaResourceDialect,
4809    >;
4810    fn r#establish_streams(
4811        &self,
4812        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
4813    ) -> Self::EstablishStreamsResponseFut {
4814        fn _decode(
4815            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4816        ) -> Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error> {
4817            let _response = fidl::client::decode_transaction_body::<
4818                fidl::encoding::FlexibleResultType<
4819                    fidl::encoding::EmptyStruct,
4820                    EstablishStreamsError,
4821                >,
4822                fidl::encoding::DefaultFuchsiaResourceDialect,
4823                0xc7296c5edb4dacc,
4824            >(_buf?)?
4825            .into_result::<ConnectedIsochronousGroupMarker>("establish_streams")?;
4826            Ok(_response.map(|x| x))
4827        }
4828        self.client.send_query_and_decode::<
4829            ConnectedIsochronousGroupEstablishStreamsRequest,
4830            ConnectedIsochronousGroupEstablishStreamsResult,
4831        >(
4832            payload,
4833            0xc7296c5edb4dacc,
4834            fidl::encoding::DynamicFlags::FLEXIBLE,
4835            _decode,
4836        )
4837    }
4838
4839    fn r#remove(&self) -> Result<(), fidl::Error> {
4840        self.client.send::<fidl::encoding::EmptyPayload>(
4841            (),
4842            0xbed433babd20503,
4843            fidl::encoding::DynamicFlags::FLEXIBLE,
4844        )
4845    }
4846}
4847
4848pub struct ConnectedIsochronousGroupEventStream {
4849    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4850}
4851
4852impl std::marker::Unpin for ConnectedIsochronousGroupEventStream {}
4853
4854impl futures::stream::FusedStream for ConnectedIsochronousGroupEventStream {
4855    fn is_terminated(&self) -> bool {
4856        self.event_receiver.is_terminated()
4857    }
4858}
4859
4860impl futures::Stream for ConnectedIsochronousGroupEventStream {
4861    type Item = Result<ConnectedIsochronousGroupEvent, fidl::Error>;
4862
4863    fn poll_next(
4864        mut self: std::pin::Pin<&mut Self>,
4865        cx: &mut std::task::Context<'_>,
4866    ) -> std::task::Poll<Option<Self::Item>> {
4867        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4868            &mut self.event_receiver,
4869            cx
4870        )?) {
4871            Some(buf) => std::task::Poll::Ready(Some(ConnectedIsochronousGroupEvent::decode(buf))),
4872            None => std::task::Poll::Ready(None),
4873        }
4874    }
4875}
4876
4877#[derive(Debug)]
4878pub enum ConnectedIsochronousGroupEvent {
4879    #[non_exhaustive]
4880    _UnknownEvent {
4881        /// Ordinal of the event that was sent.
4882        ordinal: u64,
4883    },
4884}
4885
4886impl ConnectedIsochronousGroupEvent {
4887    /// Decodes a message buffer as a [`ConnectedIsochronousGroupEvent`].
4888    fn decode(
4889        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4890    ) -> Result<ConnectedIsochronousGroupEvent, fidl::Error> {
4891        let (bytes, _handles) = buf.split_mut();
4892        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4893        debug_assert_eq!(tx_header.tx_id, 0);
4894        match tx_header.ordinal {
4895            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4896                Ok(ConnectedIsochronousGroupEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4897            }
4898            _ => Err(fidl::Error::UnknownOrdinal {
4899                ordinal: tx_header.ordinal,
4900                protocol_name:
4901                    <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4902            }),
4903        }
4904    }
4905}
4906
4907/// A Stream of incoming requests for fuchsia.bluetooth.le/ConnectedIsochronousGroup.
4908pub struct ConnectedIsochronousGroupRequestStream {
4909    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4910    is_terminated: bool,
4911}
4912
4913impl std::marker::Unpin for ConnectedIsochronousGroupRequestStream {}
4914
4915impl futures::stream::FusedStream for ConnectedIsochronousGroupRequestStream {
4916    fn is_terminated(&self) -> bool {
4917        self.is_terminated
4918    }
4919}
4920
4921impl fidl::endpoints::RequestStream for ConnectedIsochronousGroupRequestStream {
4922    type Protocol = ConnectedIsochronousGroupMarker;
4923    type ControlHandle = ConnectedIsochronousGroupControlHandle;
4924
4925    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4926        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4927    }
4928
4929    fn control_handle(&self) -> Self::ControlHandle {
4930        ConnectedIsochronousGroupControlHandle { inner: self.inner.clone() }
4931    }
4932
4933    fn into_inner(
4934        self,
4935    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4936    {
4937        (self.inner, self.is_terminated)
4938    }
4939
4940    fn from_inner(
4941        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4942        is_terminated: bool,
4943    ) -> Self {
4944        Self { inner, is_terminated }
4945    }
4946}
4947
4948impl futures::Stream for ConnectedIsochronousGroupRequestStream {
4949    type Item = Result<ConnectedIsochronousGroupRequest, fidl::Error>;
4950
4951    fn poll_next(
4952        mut self: std::pin::Pin<&mut Self>,
4953        cx: &mut std::task::Context<'_>,
4954    ) -> std::task::Poll<Option<Self::Item>> {
4955        let this = &mut *self;
4956        if this.inner.check_shutdown(cx) {
4957            this.is_terminated = true;
4958            return std::task::Poll::Ready(None);
4959        }
4960        if this.is_terminated {
4961            panic!("polled ConnectedIsochronousGroupRequestStream after completion");
4962        }
4963        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4964            |bytes, handles| {
4965                match this.inner.channel().read_etc(cx, bytes, handles) {
4966                    std::task::Poll::Ready(Ok(())) => {}
4967                    std::task::Poll::Pending => return std::task::Poll::Pending,
4968                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4969                        this.is_terminated = true;
4970                        return std::task::Poll::Ready(None);
4971                    }
4972                    std::task::Poll::Ready(Err(e)) => {
4973                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4974                            e.into(),
4975                        ))))
4976                    }
4977                }
4978
4979                // A message has been received from the channel
4980                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4981
4982                std::task::Poll::Ready(Some(match header.ordinal {
4983                0xc7296c5edb4dacc => {
4984                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4985                    let mut req = fidl::new_empty!(ConnectedIsochronousGroupEstablishStreamsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4986                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectedIsochronousGroupEstablishStreamsRequest>(&header, _body_bytes, handles, &mut req)?;
4987                    let control_handle = ConnectedIsochronousGroupControlHandle {
4988                        inner: this.inner.clone(),
4989                    };
4990                    Ok(ConnectedIsochronousGroupRequest::EstablishStreams {payload: req,
4991                        responder: ConnectedIsochronousGroupEstablishStreamsResponder {
4992                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4993                            tx_id: header.tx_id,
4994                        },
4995                    })
4996                }
4997                0xbed433babd20503 => {
4998                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4999                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5000                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5001                    let control_handle = ConnectedIsochronousGroupControlHandle {
5002                        inner: this.inner.clone(),
5003                    };
5004                    Ok(ConnectedIsochronousGroupRequest::Remove {
5005                        control_handle,
5006                    })
5007                }
5008                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5009                    Ok(ConnectedIsochronousGroupRequest::_UnknownMethod {
5010                        ordinal: header.ordinal,
5011                        control_handle: ConnectedIsochronousGroupControlHandle { inner: this.inner.clone() },
5012                        method_type: fidl::MethodType::OneWay,
5013                    })
5014                }
5015                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5016                    this.inner.send_framework_err(
5017                        fidl::encoding::FrameworkErr::UnknownMethod,
5018                        header.tx_id,
5019                        header.ordinal,
5020                        header.dynamic_flags(),
5021                        (bytes, handles),
5022                    )?;
5023                    Ok(ConnectedIsochronousGroupRequest::_UnknownMethod {
5024                        ordinal: header.ordinal,
5025                        control_handle: ConnectedIsochronousGroupControlHandle { inner: this.inner.clone() },
5026                        method_type: fidl::MethodType::TwoWay,
5027                    })
5028                }
5029                _ => Err(fidl::Error::UnknownOrdinal {
5030                    ordinal: header.ordinal,
5031                    protocol_name: <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5032                }),
5033            }))
5034            },
5035        )
5036    }
5037}
5038
5039#[derive(Debug)]
5040pub enum ConnectedIsochronousGroupRequest {
5041    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
5042    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
5043    /// be sent on the IsochronousStream.
5044    ///
5045    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
5046    /// returned.
5047    ///
5048    /// Otherwise, this call returns once each CIS specified has connected.
5049    EstablishStreams {
5050        payload: ConnectedIsochronousGroupEstablishStreamsRequest,
5051        responder: ConnectedIsochronousGroupEstablishStreamsResponder,
5052    },
5053    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
5054    /// all of the associated streams have closed and the group has been removed.
5055    Remove { control_handle: ConnectedIsochronousGroupControlHandle },
5056    /// An interaction was received which does not match any known method.
5057    #[non_exhaustive]
5058    _UnknownMethod {
5059        /// Ordinal of the method that was called.
5060        ordinal: u64,
5061        control_handle: ConnectedIsochronousGroupControlHandle,
5062        method_type: fidl::MethodType,
5063    },
5064}
5065
5066impl ConnectedIsochronousGroupRequest {
5067    #[allow(irrefutable_let_patterns)]
5068    pub fn into_establish_streams(
5069        self,
5070    ) -> Option<(
5071        ConnectedIsochronousGroupEstablishStreamsRequest,
5072        ConnectedIsochronousGroupEstablishStreamsResponder,
5073    )> {
5074        if let ConnectedIsochronousGroupRequest::EstablishStreams { payload, responder } = self {
5075            Some((payload, responder))
5076        } else {
5077            None
5078        }
5079    }
5080
5081    #[allow(irrefutable_let_patterns)]
5082    pub fn into_remove(self) -> Option<(ConnectedIsochronousGroupControlHandle)> {
5083        if let ConnectedIsochronousGroupRequest::Remove { control_handle } = self {
5084            Some((control_handle))
5085        } else {
5086            None
5087        }
5088    }
5089
5090    /// Name of the method defined in FIDL
5091    pub fn method_name(&self) -> &'static str {
5092        match *self {
5093            ConnectedIsochronousGroupRequest::EstablishStreams { .. } => "establish_streams",
5094            ConnectedIsochronousGroupRequest::Remove { .. } => "remove",
5095            ConnectedIsochronousGroupRequest::_UnknownMethod {
5096                method_type: fidl::MethodType::OneWay,
5097                ..
5098            } => "unknown one-way method",
5099            ConnectedIsochronousGroupRequest::_UnknownMethod {
5100                method_type: fidl::MethodType::TwoWay,
5101                ..
5102            } => "unknown two-way method",
5103        }
5104    }
5105}
5106
5107#[derive(Debug, Clone)]
5108pub struct ConnectedIsochronousGroupControlHandle {
5109    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5110}
5111
5112impl fidl::endpoints::ControlHandle for ConnectedIsochronousGroupControlHandle {
5113    fn shutdown(&self) {
5114        self.inner.shutdown()
5115    }
5116    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5117        self.inner.shutdown_with_epitaph(status)
5118    }
5119
5120    fn is_closed(&self) -> bool {
5121        self.inner.channel().is_closed()
5122    }
5123    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5124        self.inner.channel().on_closed()
5125    }
5126
5127    #[cfg(target_os = "fuchsia")]
5128    fn signal_peer(
5129        &self,
5130        clear_mask: zx::Signals,
5131        set_mask: zx::Signals,
5132    ) -> Result<(), zx_status::Status> {
5133        use fidl::Peered;
5134        self.inner.channel().signal_peer(clear_mask, set_mask)
5135    }
5136}
5137
5138impl ConnectedIsochronousGroupControlHandle {}
5139
5140#[must_use = "FIDL methods require a response to be sent"]
5141#[derive(Debug)]
5142pub struct ConnectedIsochronousGroupEstablishStreamsResponder {
5143    control_handle: std::mem::ManuallyDrop<ConnectedIsochronousGroupControlHandle>,
5144    tx_id: u32,
5145}
5146
5147/// Set the the channel to be shutdown (see [`ConnectedIsochronousGroupControlHandle::shutdown`])
5148/// if the responder is dropped without sending a response, so that the client
5149/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5150impl std::ops::Drop for ConnectedIsochronousGroupEstablishStreamsResponder {
5151    fn drop(&mut self) {
5152        self.control_handle.shutdown();
5153        // Safety: drops once, never accessed again
5154        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5155    }
5156}
5157
5158impl fidl::endpoints::Responder for ConnectedIsochronousGroupEstablishStreamsResponder {
5159    type ControlHandle = ConnectedIsochronousGroupControlHandle;
5160
5161    fn control_handle(&self) -> &ConnectedIsochronousGroupControlHandle {
5162        &self.control_handle
5163    }
5164
5165    fn drop_without_shutdown(mut self) {
5166        // Safety: drops once, never accessed again due to mem::forget
5167        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5168        // Prevent Drop from running (which would shut down the channel)
5169        std::mem::forget(self);
5170    }
5171}
5172
5173impl ConnectedIsochronousGroupEstablishStreamsResponder {
5174    /// Sends a response to the FIDL transaction.
5175    ///
5176    /// Sets the channel to shutdown if an error occurs.
5177    pub fn send(self, mut result: Result<(), EstablishStreamsError>) -> Result<(), fidl::Error> {
5178        let _result = self.send_raw(result);
5179        if _result.is_err() {
5180            self.control_handle.shutdown();
5181        }
5182        self.drop_without_shutdown();
5183        _result
5184    }
5185
5186    /// Similar to "send" but does not shutdown the channel if an error occurs.
5187    pub fn send_no_shutdown_on_err(
5188        self,
5189        mut result: Result<(), EstablishStreamsError>,
5190    ) -> Result<(), fidl::Error> {
5191        let _result = self.send_raw(result);
5192        self.drop_without_shutdown();
5193        _result
5194    }
5195
5196    fn send_raw(&self, mut result: Result<(), EstablishStreamsError>) -> Result<(), fidl::Error> {
5197        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5198            fidl::encoding::EmptyStruct,
5199            EstablishStreamsError,
5200        >>(
5201            fidl::encoding::FlexibleResult::new(result),
5202            self.tx_id,
5203            0xc7296c5edb4dacc,
5204            fidl::encoding::DynamicFlags::FLEXIBLE,
5205        )
5206    }
5207}
5208
5209#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5210pub struct ConnectionMarker;
5211
5212impl fidl::endpoints::ProtocolMarker for ConnectionMarker {
5213    type Proxy = ConnectionProxy;
5214    type RequestStream = ConnectionRequestStream;
5215    #[cfg(target_os = "fuchsia")]
5216    type SynchronousProxy = ConnectionSynchronousProxy;
5217
5218    const DEBUG_NAME: &'static str = "(anonymous) Connection";
5219}
5220
5221pub trait ConnectionProxyInterface: Send + Sync {
5222    type GetCodecLocalDelayRangeResponseFut: std::future::Future<Output = Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error>>
5223        + Send;
5224    fn r#get_codec_local_delay_range(
5225        &self,
5226        payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5227    ) -> Self::GetCodecLocalDelayRangeResponseFut;
5228    fn r#request_gatt_client(
5229        &self,
5230        client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5231    ) -> Result<(), fidl::Error>;
5232    fn r#accept_cis(&self, payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error>;
5233    fn r#connect_l2cap(&self, payload: ConnectionConnectL2capRequest) -> Result<(), fidl::Error>;
5234}
5235#[derive(Debug)]
5236#[cfg(target_os = "fuchsia")]
5237pub struct ConnectionSynchronousProxy {
5238    client: fidl::client::sync::Client,
5239}
5240
5241#[cfg(target_os = "fuchsia")]
5242impl fidl::endpoints::SynchronousProxy for ConnectionSynchronousProxy {
5243    type Proxy = ConnectionProxy;
5244    type Protocol = ConnectionMarker;
5245
5246    fn from_channel(inner: fidl::Channel) -> Self {
5247        Self::new(inner)
5248    }
5249
5250    fn into_channel(self) -> fidl::Channel {
5251        self.client.into_channel()
5252    }
5253
5254    fn as_channel(&self) -> &fidl::Channel {
5255        self.client.as_channel()
5256    }
5257}
5258
5259#[cfg(target_os = "fuchsia")]
5260impl ConnectionSynchronousProxy {
5261    pub fn new(channel: fidl::Channel) -> Self {
5262        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5263        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5264    }
5265
5266    pub fn into_channel(self) -> fidl::Channel {
5267        self.client.into_channel()
5268    }
5269
5270    /// Waits until an event arrives and returns it. It is safe for other
5271    /// threads to make concurrent requests while waiting for an event.
5272    pub fn wait_for_event(
5273        &self,
5274        deadline: zx::MonotonicInstant,
5275    ) -> Result<ConnectionEvent, fidl::Error> {
5276        ConnectionEvent::decode(self.client.wait_for_event(deadline)?)
5277    }
5278
5279    /// Retrieve the range of controller delay for the codec specified with the provided stream
5280    /// attributes.
5281    ///
5282    /// On success, returns the minimum and maximum allowed delay.
5283    ///
5284    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5285    /// Returns ZX_ERR_INTERNAL for all other failures.
5286    pub fn r#get_codec_local_delay_range(
5287        &self,
5288        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5289        ___deadline: zx::MonotonicInstant,
5290    ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
5291        let _response = self.client.send_query::<
5292            CodecDelayGetCodecLocalDelayRangeRequest,
5293            fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5294        >(
5295            payload,
5296            0x1cf34fdeed80b4d,
5297            fidl::encoding::DynamicFlags::empty(),
5298            ___deadline,
5299        )?;
5300        Ok(_response.map(|x| x))
5301    }
5302
5303    /// The following epitaphs may be sent by the server on error:
5304    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
5305    ///                           protocol. The existing Client should be used.
5306    pub fn r#request_gatt_client(
5307        &self,
5308        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5309    ) -> Result<(), fidl::Error> {
5310        self.client.send::<ConnectionRequestGattClientRequest>(
5311            (client,),
5312            0x2a670e0fec6ccc6b,
5313            fidl::encoding::DynamicFlags::empty(),
5314        )
5315    }
5316
5317    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
5318    /// CIS requests that have not explicitly been allowed will be rejected.
5319    ///
5320    /// The provided IsochronousStream will be used for future notification of established
5321    /// connections.
5322    ///
5323    /// The host may wait for multiple incoming connections simultaneously, although each
5324    /// must have a combination of CIG/CIS values that is unique to this connection.
5325    ///
5326    /// If we are not operating in the peripheral role in this connection, connection_stream
5327    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
5328    ///
5329    /// If we are already waiting for another connection with the same combination of CIG/CIS
5330    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
5331    pub fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
5332        self.client.send::<ConnectionAcceptCisRequest>(
5333            &mut payload,
5334            0x7e6338c237088144,
5335            fidl::encoding::DynamicFlags::empty(),
5336        )
5337    }
5338
5339    /// Connect to an L2CAP LE connection-oriented channel.
5340    pub fn r#connect_l2cap(
5341        &self,
5342        mut payload: ConnectionConnectL2capRequest,
5343    ) -> Result<(), fidl::Error> {
5344        self.client.send::<ConnectionConnectL2capRequest>(
5345            &mut payload,
5346            0x12351316feaebce9,
5347            fidl::encoding::DynamicFlags::empty(),
5348        )
5349    }
5350}
5351
5352#[cfg(target_os = "fuchsia")]
5353impl From<ConnectionSynchronousProxy> for zx::Handle {
5354    fn from(value: ConnectionSynchronousProxy) -> Self {
5355        value.into_channel().into()
5356    }
5357}
5358
5359#[cfg(target_os = "fuchsia")]
5360impl From<fidl::Channel> for ConnectionSynchronousProxy {
5361    fn from(value: fidl::Channel) -> Self {
5362        Self::new(value)
5363    }
5364}
5365
5366#[cfg(target_os = "fuchsia")]
5367impl fidl::endpoints::FromClient for ConnectionSynchronousProxy {
5368    type Protocol = ConnectionMarker;
5369
5370    fn from_client(value: fidl::endpoints::ClientEnd<ConnectionMarker>) -> Self {
5371        Self::new(value.into_channel())
5372    }
5373}
5374
5375#[derive(Debug, Clone)]
5376pub struct ConnectionProxy {
5377    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5378}
5379
5380impl fidl::endpoints::Proxy for ConnectionProxy {
5381    type Protocol = ConnectionMarker;
5382
5383    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5384        Self::new(inner)
5385    }
5386
5387    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5388        self.client.into_channel().map_err(|client| Self { client })
5389    }
5390
5391    fn as_channel(&self) -> &::fidl::AsyncChannel {
5392        self.client.as_channel()
5393    }
5394}
5395
5396impl ConnectionProxy {
5397    /// Create a new Proxy for fuchsia.bluetooth.le/Connection.
5398    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5399        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5400        Self { client: fidl::client::Client::new(channel, protocol_name) }
5401    }
5402
5403    /// Get a Stream of events from the remote end of the protocol.
5404    ///
5405    /// # Panics
5406    ///
5407    /// Panics if the event stream was already taken.
5408    pub fn take_event_stream(&self) -> ConnectionEventStream {
5409        ConnectionEventStream { event_receiver: self.client.take_event_receiver() }
5410    }
5411
5412    /// Retrieve the range of controller delay for the codec specified with the provided stream
5413    /// attributes.
5414    ///
5415    /// On success, returns the minimum and maximum allowed delay.
5416    ///
5417    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5418    /// Returns ZX_ERR_INTERNAL for all other failures.
5419    pub fn r#get_codec_local_delay_range(
5420        &self,
5421        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5422    ) -> fidl::client::QueryResponseFut<
5423        CodecDelayGetCodecLocalDelayRangeResult,
5424        fidl::encoding::DefaultFuchsiaResourceDialect,
5425    > {
5426        ConnectionProxyInterface::r#get_codec_local_delay_range(self, payload)
5427    }
5428
5429    /// The following epitaphs may be sent by the server on error:
5430    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
5431    ///                           protocol. The existing Client should be used.
5432    pub fn r#request_gatt_client(
5433        &self,
5434        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5435    ) -> Result<(), fidl::Error> {
5436        ConnectionProxyInterface::r#request_gatt_client(self, client)
5437    }
5438
5439    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
5440    /// CIS requests that have not explicitly been allowed will be rejected.
5441    ///
5442    /// The provided IsochronousStream will be used for future notification of established
5443    /// connections.
5444    ///
5445    /// The host may wait for multiple incoming connections simultaneously, although each
5446    /// must have a combination of CIG/CIS values that is unique to this connection.
5447    ///
5448    /// If we are not operating in the peripheral role in this connection, connection_stream
5449    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
5450    ///
5451    /// If we are already waiting for another connection with the same combination of CIG/CIS
5452    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
5453    pub fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
5454        ConnectionProxyInterface::r#accept_cis(self, payload)
5455    }
5456
5457    /// Connect to an L2CAP LE connection-oriented channel.
5458    pub fn r#connect_l2cap(
5459        &self,
5460        mut payload: ConnectionConnectL2capRequest,
5461    ) -> Result<(), fidl::Error> {
5462        ConnectionProxyInterface::r#connect_l2cap(self, payload)
5463    }
5464}
5465
5466impl ConnectionProxyInterface for ConnectionProxy {
5467    type GetCodecLocalDelayRangeResponseFut = fidl::client::QueryResponseFut<
5468        CodecDelayGetCodecLocalDelayRangeResult,
5469        fidl::encoding::DefaultFuchsiaResourceDialect,
5470    >;
5471    fn r#get_codec_local_delay_range(
5472        &self,
5473        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5474    ) -> Self::GetCodecLocalDelayRangeResponseFut {
5475        fn _decode(
5476            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5477        ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
5478            let _response = fidl::client::decode_transaction_body::<
5479                fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5480                fidl::encoding::DefaultFuchsiaResourceDialect,
5481                0x1cf34fdeed80b4d,
5482            >(_buf?)?;
5483            Ok(_response.map(|x| x))
5484        }
5485        self.client.send_query_and_decode::<
5486            CodecDelayGetCodecLocalDelayRangeRequest,
5487            CodecDelayGetCodecLocalDelayRangeResult,
5488        >(
5489            payload,
5490            0x1cf34fdeed80b4d,
5491            fidl::encoding::DynamicFlags::empty(),
5492            _decode,
5493        )
5494    }
5495
5496    fn r#request_gatt_client(
5497        &self,
5498        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5499    ) -> Result<(), fidl::Error> {
5500        self.client.send::<ConnectionRequestGattClientRequest>(
5501            (client,),
5502            0x2a670e0fec6ccc6b,
5503            fidl::encoding::DynamicFlags::empty(),
5504        )
5505    }
5506
5507    fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
5508        self.client.send::<ConnectionAcceptCisRequest>(
5509            &mut payload,
5510            0x7e6338c237088144,
5511            fidl::encoding::DynamicFlags::empty(),
5512        )
5513    }
5514
5515    fn r#connect_l2cap(
5516        &self,
5517        mut payload: ConnectionConnectL2capRequest,
5518    ) -> Result<(), fidl::Error> {
5519        self.client.send::<ConnectionConnectL2capRequest>(
5520            &mut payload,
5521            0x12351316feaebce9,
5522            fidl::encoding::DynamicFlags::empty(),
5523        )
5524    }
5525}
5526
5527pub struct ConnectionEventStream {
5528    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5529}
5530
5531impl std::marker::Unpin for ConnectionEventStream {}
5532
5533impl futures::stream::FusedStream for ConnectionEventStream {
5534    fn is_terminated(&self) -> bool {
5535        self.event_receiver.is_terminated()
5536    }
5537}
5538
5539impl futures::Stream for ConnectionEventStream {
5540    type Item = Result<ConnectionEvent, fidl::Error>;
5541
5542    fn poll_next(
5543        mut self: std::pin::Pin<&mut Self>,
5544        cx: &mut std::task::Context<'_>,
5545    ) -> std::task::Poll<Option<Self::Item>> {
5546        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5547            &mut self.event_receiver,
5548            cx
5549        )?) {
5550            Some(buf) => std::task::Poll::Ready(Some(ConnectionEvent::decode(buf))),
5551            None => std::task::Poll::Ready(None),
5552        }
5553    }
5554}
5555
5556#[derive(Debug)]
5557pub enum ConnectionEvent {}
5558
5559impl ConnectionEvent {
5560    /// Decodes a message buffer as a [`ConnectionEvent`].
5561    fn decode(
5562        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5563    ) -> Result<ConnectionEvent, fidl::Error> {
5564        let (bytes, _handles) = buf.split_mut();
5565        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5566        debug_assert_eq!(tx_header.tx_id, 0);
5567        match tx_header.ordinal {
5568            _ => Err(fidl::Error::UnknownOrdinal {
5569                ordinal: tx_header.ordinal,
5570                protocol_name: <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5571            }),
5572        }
5573    }
5574}
5575
5576/// A Stream of incoming requests for fuchsia.bluetooth.le/Connection.
5577pub struct ConnectionRequestStream {
5578    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5579    is_terminated: bool,
5580}
5581
5582impl std::marker::Unpin for ConnectionRequestStream {}
5583
5584impl futures::stream::FusedStream for ConnectionRequestStream {
5585    fn is_terminated(&self) -> bool {
5586        self.is_terminated
5587    }
5588}
5589
5590impl fidl::endpoints::RequestStream for ConnectionRequestStream {
5591    type Protocol = ConnectionMarker;
5592    type ControlHandle = ConnectionControlHandle;
5593
5594    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5595        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5596    }
5597
5598    fn control_handle(&self) -> Self::ControlHandle {
5599        ConnectionControlHandle { inner: self.inner.clone() }
5600    }
5601
5602    fn into_inner(
5603        self,
5604    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5605    {
5606        (self.inner, self.is_terminated)
5607    }
5608
5609    fn from_inner(
5610        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5611        is_terminated: bool,
5612    ) -> Self {
5613        Self { inner, is_terminated }
5614    }
5615}
5616
5617impl futures::Stream for ConnectionRequestStream {
5618    type Item = Result<ConnectionRequest, fidl::Error>;
5619
5620    fn poll_next(
5621        mut self: std::pin::Pin<&mut Self>,
5622        cx: &mut std::task::Context<'_>,
5623    ) -> std::task::Poll<Option<Self::Item>> {
5624        let this = &mut *self;
5625        if this.inner.check_shutdown(cx) {
5626            this.is_terminated = true;
5627            return std::task::Poll::Ready(None);
5628        }
5629        if this.is_terminated {
5630            panic!("polled ConnectionRequestStream after completion");
5631        }
5632        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5633            |bytes, handles| {
5634                match this.inner.channel().read_etc(cx, bytes, handles) {
5635                    std::task::Poll::Ready(Ok(())) => {}
5636                    std::task::Poll::Pending => return std::task::Poll::Pending,
5637                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5638                        this.is_terminated = true;
5639                        return std::task::Poll::Ready(None);
5640                    }
5641                    std::task::Poll::Ready(Err(e)) => {
5642                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5643                            e.into(),
5644                        ))))
5645                    }
5646                }
5647
5648                // A message has been received from the channel
5649                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5650
5651                std::task::Poll::Ready(Some(match header.ordinal {
5652                    0x1cf34fdeed80b4d => {
5653                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5654                        let mut req = fidl::new_empty!(
5655                            CodecDelayGetCodecLocalDelayRangeRequest,
5656                            fidl::encoding::DefaultFuchsiaResourceDialect
5657                        );
5658                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecDelayGetCodecLocalDelayRangeRequest>(&header, _body_bytes, handles, &mut req)?;
5659                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5660                        Ok(ConnectionRequest::GetCodecLocalDelayRange {
5661                            payload: req,
5662                            responder: ConnectionGetCodecLocalDelayRangeResponder {
5663                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5664                                tx_id: header.tx_id,
5665                            },
5666                        })
5667                    }
5668                    0x2a670e0fec6ccc6b => {
5669                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5670                        let mut req = fidl::new_empty!(
5671                            ConnectionRequestGattClientRequest,
5672                            fidl::encoding::DefaultFuchsiaResourceDialect
5673                        );
5674                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionRequestGattClientRequest>(&header, _body_bytes, handles, &mut req)?;
5675                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5676                        Ok(ConnectionRequest::RequestGattClient {
5677                            client: req.client,
5678
5679                            control_handle,
5680                        })
5681                    }
5682                    0x7e6338c237088144 => {
5683                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5684                        let mut req = fidl::new_empty!(
5685                            ConnectionAcceptCisRequest,
5686                            fidl::encoding::DefaultFuchsiaResourceDialect
5687                        );
5688                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionAcceptCisRequest>(&header, _body_bytes, handles, &mut req)?;
5689                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5690                        Ok(ConnectionRequest::AcceptCis { payload: req, control_handle })
5691                    }
5692                    0x12351316feaebce9 => {
5693                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5694                        let mut req = fidl::new_empty!(
5695                            ConnectionConnectL2capRequest,
5696                            fidl::encoding::DefaultFuchsiaResourceDialect
5697                        );
5698                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionConnectL2capRequest>(&header, _body_bytes, handles, &mut req)?;
5699                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
5700                        Ok(ConnectionRequest::ConnectL2cap { payload: req, control_handle })
5701                    }
5702                    _ => Err(fidl::Error::UnknownOrdinal {
5703                        ordinal: header.ordinal,
5704                        protocol_name:
5705                            <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5706                    }),
5707                }))
5708            },
5709        )
5710    }
5711}
5712
5713/// Protocol that represents the connection to a peer. This can be used to interact with GATT
5714/// services and establish L2CAP channels.
5715///
5716/// This lifetime of this capability is tied to that of the LE connection it represents. Closing the
5717/// channel results in a disconnection if no other clients hold a Connection to the same peer.
5718#[derive(Debug)]
5719pub enum ConnectionRequest {
5720    /// Retrieve the range of controller delay for the codec specified with the provided stream
5721    /// attributes.
5722    ///
5723    /// On success, returns the minimum and maximum allowed delay.
5724    ///
5725    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5726    /// Returns ZX_ERR_INTERNAL for all other failures.
5727    GetCodecLocalDelayRange {
5728        payload: CodecDelayGetCodecLocalDelayRangeRequest,
5729        responder: ConnectionGetCodecLocalDelayRangeResponder,
5730    },
5731    /// The following epitaphs may be sent by the server on error:
5732    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
5733    ///                           protocol. The existing Client should be used.
5734    RequestGattClient {
5735        client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5736        control_handle: ConnectionControlHandle,
5737    },
5738    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
5739    /// CIS requests that have not explicitly been allowed will be rejected.
5740    ///
5741    /// The provided IsochronousStream will be used for future notification of established
5742    /// connections.
5743    ///
5744    /// The host may wait for multiple incoming connections simultaneously, although each
5745    /// must have a combination of CIG/CIS values that is unique to this connection.
5746    ///
5747    /// If we are not operating in the peripheral role in this connection, connection_stream
5748    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
5749    ///
5750    /// If we are already waiting for another connection with the same combination of CIG/CIS
5751    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
5752    AcceptCis { payload: ConnectionAcceptCisRequest, control_handle: ConnectionControlHandle },
5753    /// Connect to an L2CAP LE connection-oriented channel.
5754    ConnectL2cap { payload: ConnectionConnectL2capRequest, control_handle: ConnectionControlHandle },
5755}
5756
5757impl ConnectionRequest {
5758    #[allow(irrefutable_let_patterns)]
5759    pub fn into_get_codec_local_delay_range(
5760        self,
5761    ) -> Option<(
5762        CodecDelayGetCodecLocalDelayRangeRequest,
5763        ConnectionGetCodecLocalDelayRangeResponder,
5764    )> {
5765        if let ConnectionRequest::GetCodecLocalDelayRange { payload, responder } = self {
5766            Some((payload, responder))
5767        } else {
5768            None
5769        }
5770    }
5771
5772    #[allow(irrefutable_let_patterns)]
5773    pub fn into_request_gatt_client(
5774        self,
5775    ) -> Option<(
5776        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
5777        ConnectionControlHandle,
5778    )> {
5779        if let ConnectionRequest::RequestGattClient { client, control_handle } = self {
5780            Some((client, control_handle))
5781        } else {
5782            None
5783        }
5784    }
5785
5786    #[allow(irrefutable_let_patterns)]
5787    pub fn into_accept_cis(self) -> Option<(ConnectionAcceptCisRequest, ConnectionControlHandle)> {
5788        if let ConnectionRequest::AcceptCis { payload, control_handle } = self {
5789            Some((payload, control_handle))
5790        } else {
5791            None
5792        }
5793    }
5794
5795    #[allow(irrefutable_let_patterns)]
5796    pub fn into_connect_l2cap(
5797        self,
5798    ) -> Option<(ConnectionConnectL2capRequest, ConnectionControlHandle)> {
5799        if let ConnectionRequest::ConnectL2cap { payload, control_handle } = self {
5800            Some((payload, control_handle))
5801        } else {
5802            None
5803        }
5804    }
5805
5806    /// Name of the method defined in FIDL
5807    pub fn method_name(&self) -> &'static str {
5808        match *self {
5809            ConnectionRequest::GetCodecLocalDelayRange { .. } => "get_codec_local_delay_range",
5810            ConnectionRequest::RequestGattClient { .. } => "request_gatt_client",
5811            ConnectionRequest::AcceptCis { .. } => "accept_cis",
5812            ConnectionRequest::ConnectL2cap { .. } => "connect_l2cap",
5813        }
5814    }
5815}
5816
5817#[derive(Debug, Clone)]
5818pub struct ConnectionControlHandle {
5819    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5820}
5821
5822impl fidl::endpoints::ControlHandle for ConnectionControlHandle {
5823    fn shutdown(&self) {
5824        self.inner.shutdown()
5825    }
5826    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5827        self.inner.shutdown_with_epitaph(status)
5828    }
5829
5830    fn is_closed(&self) -> bool {
5831        self.inner.channel().is_closed()
5832    }
5833    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5834        self.inner.channel().on_closed()
5835    }
5836
5837    #[cfg(target_os = "fuchsia")]
5838    fn signal_peer(
5839        &self,
5840        clear_mask: zx::Signals,
5841        set_mask: zx::Signals,
5842    ) -> Result<(), zx_status::Status> {
5843        use fidl::Peered;
5844        self.inner.channel().signal_peer(clear_mask, set_mask)
5845    }
5846}
5847
5848impl ConnectionControlHandle {}
5849
5850#[must_use = "FIDL methods require a response to be sent"]
5851#[derive(Debug)]
5852pub struct ConnectionGetCodecLocalDelayRangeResponder {
5853    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
5854    tx_id: u32,
5855}
5856
5857/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
5858/// if the responder is dropped without sending a response, so that the client
5859/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5860impl std::ops::Drop for ConnectionGetCodecLocalDelayRangeResponder {
5861    fn drop(&mut self) {
5862        self.control_handle.shutdown();
5863        // Safety: drops once, never accessed again
5864        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5865    }
5866}
5867
5868impl fidl::endpoints::Responder for ConnectionGetCodecLocalDelayRangeResponder {
5869    type ControlHandle = ConnectionControlHandle;
5870
5871    fn control_handle(&self) -> &ConnectionControlHandle {
5872        &self.control_handle
5873    }
5874
5875    fn drop_without_shutdown(mut self) {
5876        // Safety: drops once, never accessed again due to mem::forget
5877        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5878        // Prevent Drop from running (which would shut down the channel)
5879        std::mem::forget(self);
5880    }
5881}
5882
5883impl ConnectionGetCodecLocalDelayRangeResponder {
5884    /// Sends a response to the FIDL transaction.
5885    ///
5886    /// Sets the channel to shutdown if an error occurs.
5887    pub fn send(
5888        self,
5889        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5890    ) -> Result<(), fidl::Error> {
5891        let _result = self.send_raw(result);
5892        if _result.is_err() {
5893            self.control_handle.shutdown();
5894        }
5895        self.drop_without_shutdown();
5896        _result
5897    }
5898
5899    /// Similar to "send" but does not shutdown the channel if an error occurs.
5900    pub fn send_no_shutdown_on_err(
5901        self,
5902        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5903    ) -> Result<(), fidl::Error> {
5904        let _result = self.send_raw(result);
5905        self.drop_without_shutdown();
5906        _result
5907    }
5908
5909    fn send_raw(
5910        &self,
5911        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5912    ) -> Result<(), fidl::Error> {
5913        self.control_handle.inner.send::<fidl::encoding::ResultType<
5914            CodecDelayGetCodecLocalDelayRangeResponse,
5915            i32,
5916        >>(
5917            result,
5918            self.tx_id,
5919            0x1cf34fdeed80b4d,
5920            fidl::encoding::DynamicFlags::empty(),
5921        )
5922    }
5923}
5924
5925#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5926pub struct IsochronousStreamMarker;
5927
5928impl fidl::endpoints::ProtocolMarker for IsochronousStreamMarker {
5929    type Proxy = IsochronousStreamProxy;
5930    type RequestStream = IsochronousStreamRequestStream;
5931    #[cfg(target_os = "fuchsia")]
5932    type SynchronousProxy = IsochronousStreamSynchronousProxy;
5933
5934    const DEBUG_NAME: &'static str = "(anonymous) IsochronousStream";
5935}
5936pub type IsochronousStreamSetupDataPathResult = Result<(), i32>;
5937pub type IsochronousStreamWriteResult = Result<(), i32>;
5938
5939pub trait IsochronousStreamProxyInterface: Send + Sync {
5940    type SetupDataPathResponseFut: std::future::Future<Output = Result<IsochronousStreamSetupDataPathResult, fidl::Error>>
5941        + Send;
5942    fn r#setup_data_path(
5943        &self,
5944        payload: &IsochronousStreamSetupDataPathRequest,
5945    ) -> Self::SetupDataPathResponseFut;
5946    type ReadResponseFut: std::future::Future<Output = Result<IsochronousStreamReadResponse, fidl::Error>>
5947        + Send;
5948    fn r#read(&self) -> Self::ReadResponseFut;
5949    type WriteResponseFut: std::future::Future<Output = Result<IsochronousStreamWriteResult, fidl::Error>>
5950        + Send;
5951    fn r#write(&self, payload: &IsochronousStreamWriteRequest) -> Self::WriteResponseFut;
5952}
5953#[derive(Debug)]
5954#[cfg(target_os = "fuchsia")]
5955pub struct IsochronousStreamSynchronousProxy {
5956    client: fidl::client::sync::Client,
5957}
5958
5959#[cfg(target_os = "fuchsia")]
5960impl fidl::endpoints::SynchronousProxy for IsochronousStreamSynchronousProxy {
5961    type Proxy = IsochronousStreamProxy;
5962    type Protocol = IsochronousStreamMarker;
5963
5964    fn from_channel(inner: fidl::Channel) -> Self {
5965        Self::new(inner)
5966    }
5967
5968    fn into_channel(self) -> fidl::Channel {
5969        self.client.into_channel()
5970    }
5971
5972    fn as_channel(&self) -> &fidl::Channel {
5973        self.client.as_channel()
5974    }
5975}
5976
5977#[cfg(target_os = "fuchsia")]
5978impl IsochronousStreamSynchronousProxy {
5979    pub fn new(channel: fidl::Channel) -> Self {
5980        let protocol_name =
5981            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5982        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5983    }
5984
5985    pub fn into_channel(self) -> fidl::Channel {
5986        self.client.into_channel()
5987    }
5988
5989    /// Waits until an event arrives and returns it. It is safe for other
5990    /// threads to make concurrent requests while waiting for an event.
5991    pub fn wait_for_event(
5992        &self,
5993        deadline: zx::MonotonicInstant,
5994    ) -> Result<IsochronousStreamEvent, fidl::Error> {
5995        IsochronousStreamEvent::decode(self.client.wait_for_event(deadline)?)
5996    }
5997
5998    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
5999    /// transport is currently supported.
6000    ///
6001    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
6002    /// direction.
6003    ///
6004    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
6005    /// accepted.
6006    ///
6007    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
6008    /// controller's supported range.
6009    pub fn r#setup_data_path(
6010        &self,
6011        mut payload: &IsochronousStreamSetupDataPathRequest,
6012        ___deadline: zx::MonotonicInstant,
6013    ) -> Result<IsochronousStreamSetupDataPathResult, fidl::Error> {
6014        let _response = self.client.send_query::<
6015            IsochronousStreamSetupDataPathRequest,
6016            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6017        >(
6018            payload,
6019            0x7ec1e2b9cc6d2fbe,
6020            fidl::encoding::DynamicFlags::FLEXIBLE,
6021            ___deadline,
6022        )?
6023        .into_result::<IsochronousStreamMarker>("setup_data_path")?;
6024        Ok(_response.map(|x| x))
6025    }
6026
6027    /// Receive data from an output (controller => host) ISO stream that has been established and
6028    /// set up. Designed to be used with a hanging get pattern.
6029    ///
6030    /// Can be invoked before the ISO data stream has been established and set up, but will not
6031    /// return until after it has been set up and data has been received.
6032    pub fn r#read(
6033        &self,
6034        ___deadline: zx::MonotonicInstant,
6035    ) -> Result<IsochronousStreamReadResponse, fidl::Error> {
6036        let _response = self.client.send_query::<
6037            fidl::encoding::EmptyPayload,
6038            fidl::encoding::FlexibleType<IsochronousStreamReadResponse>,
6039        >(
6040            (),
6041            0x6d7d8b4950ed3a32,
6042            fidl::encoding::DynamicFlags::FLEXIBLE,
6043            ___deadline,
6044        )?
6045        .into_result::<IsochronousStreamMarker>("read")?;
6046        Ok(_response)
6047    }
6048
6049    /// Send data to an established ISO stream (host => controller).
6050    ///
6051    /// Returns ZX_ERR_INTERNAL for any errors encountered.
6052    pub fn r#write(
6053        &self,
6054        mut payload: &IsochronousStreamWriteRequest,
6055        ___deadline: zx::MonotonicInstant,
6056    ) -> Result<IsochronousStreamWriteResult, fidl::Error> {
6057        let _response = self.client.send_query::<
6058            IsochronousStreamWriteRequest,
6059            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6060        >(
6061            payload,
6062            0x5282e90b667d0d43,
6063            fidl::encoding::DynamicFlags::FLEXIBLE,
6064            ___deadline,
6065        )?
6066        .into_result::<IsochronousStreamMarker>("write")?;
6067        Ok(_response.map(|x| x))
6068    }
6069}
6070
6071#[cfg(target_os = "fuchsia")]
6072impl From<IsochronousStreamSynchronousProxy> for zx::Handle {
6073    fn from(value: IsochronousStreamSynchronousProxy) -> Self {
6074        value.into_channel().into()
6075    }
6076}
6077
6078#[cfg(target_os = "fuchsia")]
6079impl From<fidl::Channel> for IsochronousStreamSynchronousProxy {
6080    fn from(value: fidl::Channel) -> Self {
6081        Self::new(value)
6082    }
6083}
6084
6085#[cfg(target_os = "fuchsia")]
6086impl fidl::endpoints::FromClient for IsochronousStreamSynchronousProxy {
6087    type Protocol = IsochronousStreamMarker;
6088
6089    fn from_client(value: fidl::endpoints::ClientEnd<IsochronousStreamMarker>) -> Self {
6090        Self::new(value.into_channel())
6091    }
6092}
6093
6094#[derive(Debug, Clone)]
6095pub struct IsochronousStreamProxy {
6096    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6097}
6098
6099impl fidl::endpoints::Proxy for IsochronousStreamProxy {
6100    type Protocol = IsochronousStreamMarker;
6101
6102    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6103        Self::new(inner)
6104    }
6105
6106    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6107        self.client.into_channel().map_err(|client| Self { client })
6108    }
6109
6110    fn as_channel(&self) -> &::fidl::AsyncChannel {
6111        self.client.as_channel()
6112    }
6113}
6114
6115impl IsochronousStreamProxy {
6116    /// Create a new Proxy for fuchsia.bluetooth.le/IsochronousStream.
6117    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6118        let protocol_name =
6119            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6120        Self { client: fidl::client::Client::new(channel, protocol_name) }
6121    }
6122
6123    /// Get a Stream of events from the remote end of the protocol.
6124    ///
6125    /// # Panics
6126    ///
6127    /// Panics if the event stream was already taken.
6128    pub fn take_event_stream(&self) -> IsochronousStreamEventStream {
6129        IsochronousStreamEventStream { event_receiver: self.client.take_event_receiver() }
6130    }
6131
6132    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
6133    /// transport is currently supported.
6134    ///
6135    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
6136    /// direction.
6137    ///
6138    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
6139    /// accepted.
6140    ///
6141    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
6142    /// controller's supported range.
6143    pub fn r#setup_data_path(
6144        &self,
6145        mut payload: &IsochronousStreamSetupDataPathRequest,
6146    ) -> fidl::client::QueryResponseFut<
6147        IsochronousStreamSetupDataPathResult,
6148        fidl::encoding::DefaultFuchsiaResourceDialect,
6149    > {
6150        IsochronousStreamProxyInterface::r#setup_data_path(self, payload)
6151    }
6152
6153    /// Receive data from an output (controller => host) ISO stream that has been established and
6154    /// set up. Designed to be used with a hanging get pattern.
6155    ///
6156    /// Can be invoked before the ISO data stream has been established and set up, but will not
6157    /// return until after it has been set up and data has been received.
6158    pub fn r#read(
6159        &self,
6160    ) -> fidl::client::QueryResponseFut<
6161        IsochronousStreamReadResponse,
6162        fidl::encoding::DefaultFuchsiaResourceDialect,
6163    > {
6164        IsochronousStreamProxyInterface::r#read(self)
6165    }
6166
6167    /// Send data to an established ISO stream (host => controller).
6168    ///
6169    /// Returns ZX_ERR_INTERNAL for any errors encountered.
6170    pub fn r#write(
6171        &self,
6172        mut payload: &IsochronousStreamWriteRequest,
6173    ) -> fidl::client::QueryResponseFut<
6174        IsochronousStreamWriteResult,
6175        fidl::encoding::DefaultFuchsiaResourceDialect,
6176    > {
6177        IsochronousStreamProxyInterface::r#write(self, payload)
6178    }
6179}
6180
6181impl IsochronousStreamProxyInterface for IsochronousStreamProxy {
6182    type SetupDataPathResponseFut = fidl::client::QueryResponseFut<
6183        IsochronousStreamSetupDataPathResult,
6184        fidl::encoding::DefaultFuchsiaResourceDialect,
6185    >;
6186    fn r#setup_data_path(
6187        &self,
6188        mut payload: &IsochronousStreamSetupDataPathRequest,
6189    ) -> Self::SetupDataPathResponseFut {
6190        fn _decode(
6191            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6192        ) -> Result<IsochronousStreamSetupDataPathResult, fidl::Error> {
6193            let _response = fidl::client::decode_transaction_body::<
6194                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6195                fidl::encoding::DefaultFuchsiaResourceDialect,
6196                0x7ec1e2b9cc6d2fbe,
6197            >(_buf?)?
6198            .into_result::<IsochronousStreamMarker>("setup_data_path")?;
6199            Ok(_response.map(|x| x))
6200        }
6201        self.client.send_query_and_decode::<
6202            IsochronousStreamSetupDataPathRequest,
6203            IsochronousStreamSetupDataPathResult,
6204        >(
6205            payload,
6206            0x7ec1e2b9cc6d2fbe,
6207            fidl::encoding::DynamicFlags::FLEXIBLE,
6208            _decode,
6209        )
6210    }
6211
6212    type ReadResponseFut = fidl::client::QueryResponseFut<
6213        IsochronousStreamReadResponse,
6214        fidl::encoding::DefaultFuchsiaResourceDialect,
6215    >;
6216    fn r#read(&self) -> Self::ReadResponseFut {
6217        fn _decode(
6218            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6219        ) -> Result<IsochronousStreamReadResponse, fidl::Error> {
6220            let _response = fidl::client::decode_transaction_body::<
6221                fidl::encoding::FlexibleType<IsochronousStreamReadResponse>,
6222                fidl::encoding::DefaultFuchsiaResourceDialect,
6223                0x6d7d8b4950ed3a32,
6224            >(_buf?)?
6225            .into_result::<IsochronousStreamMarker>("read")?;
6226            Ok(_response)
6227        }
6228        self.client
6229            .send_query_and_decode::<fidl::encoding::EmptyPayload, IsochronousStreamReadResponse>(
6230                (),
6231                0x6d7d8b4950ed3a32,
6232                fidl::encoding::DynamicFlags::FLEXIBLE,
6233                _decode,
6234            )
6235    }
6236
6237    type WriteResponseFut = fidl::client::QueryResponseFut<
6238        IsochronousStreamWriteResult,
6239        fidl::encoding::DefaultFuchsiaResourceDialect,
6240    >;
6241    fn r#write(&self, mut payload: &IsochronousStreamWriteRequest) -> Self::WriteResponseFut {
6242        fn _decode(
6243            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6244        ) -> Result<IsochronousStreamWriteResult, fidl::Error> {
6245            let _response = fidl::client::decode_transaction_body::<
6246                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6247                fidl::encoding::DefaultFuchsiaResourceDialect,
6248                0x5282e90b667d0d43,
6249            >(_buf?)?
6250            .into_result::<IsochronousStreamMarker>("write")?;
6251            Ok(_response.map(|x| x))
6252        }
6253        self.client
6254            .send_query_and_decode::<IsochronousStreamWriteRequest, IsochronousStreamWriteResult>(
6255                payload,
6256                0x5282e90b667d0d43,
6257                fidl::encoding::DynamicFlags::FLEXIBLE,
6258                _decode,
6259            )
6260    }
6261}
6262
6263pub struct IsochronousStreamEventStream {
6264    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6265}
6266
6267impl std::marker::Unpin for IsochronousStreamEventStream {}
6268
6269impl futures::stream::FusedStream for IsochronousStreamEventStream {
6270    fn is_terminated(&self) -> bool {
6271        self.event_receiver.is_terminated()
6272    }
6273}
6274
6275impl futures::Stream for IsochronousStreamEventStream {
6276    type Item = Result<IsochronousStreamEvent, fidl::Error>;
6277
6278    fn poll_next(
6279        mut self: std::pin::Pin<&mut Self>,
6280        cx: &mut std::task::Context<'_>,
6281    ) -> std::task::Poll<Option<Self::Item>> {
6282        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6283            &mut self.event_receiver,
6284            cx
6285        )?) {
6286            Some(buf) => std::task::Poll::Ready(Some(IsochronousStreamEvent::decode(buf))),
6287            None => std::task::Poll::Ready(None),
6288        }
6289    }
6290}
6291
6292#[derive(Debug)]
6293pub enum IsochronousStreamEvent {
6294    OnEstablished {
6295        payload: IsochronousStreamOnEstablishedRequest,
6296    },
6297    #[non_exhaustive]
6298    _UnknownEvent {
6299        /// Ordinal of the event that was sent.
6300        ordinal: u64,
6301    },
6302}
6303
6304impl IsochronousStreamEvent {
6305    #[allow(irrefutable_let_patterns)]
6306    pub fn into_on_established(self) -> Option<IsochronousStreamOnEstablishedRequest> {
6307        if let IsochronousStreamEvent::OnEstablished { payload } = self {
6308            Some((payload))
6309        } else {
6310            None
6311        }
6312    }
6313
6314    /// Decodes a message buffer as a [`IsochronousStreamEvent`].
6315    fn decode(
6316        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6317    ) -> Result<IsochronousStreamEvent, fidl::Error> {
6318        let (bytes, _handles) = buf.split_mut();
6319        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6320        debug_assert_eq!(tx_header.tx_id, 0);
6321        match tx_header.ordinal {
6322            0x341c50e9d10f3421 => {
6323                let mut out = fidl::new_empty!(
6324                    IsochronousStreamOnEstablishedRequest,
6325                    fidl::encoding::DefaultFuchsiaResourceDialect
6326                );
6327                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamOnEstablishedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6328                Ok((IsochronousStreamEvent::OnEstablished { payload: out }))
6329            }
6330            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6331                Ok(IsochronousStreamEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6332            }
6333            _ => Err(fidl::Error::UnknownOrdinal {
6334                ordinal: tx_header.ordinal,
6335                protocol_name:
6336                    <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6337            }),
6338        }
6339    }
6340}
6341
6342/// A Stream of incoming requests for fuchsia.bluetooth.le/IsochronousStream.
6343pub struct IsochronousStreamRequestStream {
6344    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6345    is_terminated: bool,
6346}
6347
6348impl std::marker::Unpin for IsochronousStreamRequestStream {}
6349
6350impl futures::stream::FusedStream for IsochronousStreamRequestStream {
6351    fn is_terminated(&self) -> bool {
6352        self.is_terminated
6353    }
6354}
6355
6356impl fidl::endpoints::RequestStream for IsochronousStreamRequestStream {
6357    type Protocol = IsochronousStreamMarker;
6358    type ControlHandle = IsochronousStreamControlHandle;
6359
6360    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6361        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6362    }
6363
6364    fn control_handle(&self) -> Self::ControlHandle {
6365        IsochronousStreamControlHandle { inner: self.inner.clone() }
6366    }
6367
6368    fn into_inner(
6369        self,
6370    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6371    {
6372        (self.inner, self.is_terminated)
6373    }
6374
6375    fn from_inner(
6376        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6377        is_terminated: bool,
6378    ) -> Self {
6379        Self { inner, is_terminated }
6380    }
6381}
6382
6383impl futures::Stream for IsochronousStreamRequestStream {
6384    type Item = Result<IsochronousStreamRequest, fidl::Error>;
6385
6386    fn poll_next(
6387        mut self: std::pin::Pin<&mut Self>,
6388        cx: &mut std::task::Context<'_>,
6389    ) -> std::task::Poll<Option<Self::Item>> {
6390        let this = &mut *self;
6391        if this.inner.check_shutdown(cx) {
6392            this.is_terminated = true;
6393            return std::task::Poll::Ready(None);
6394        }
6395        if this.is_terminated {
6396            panic!("polled IsochronousStreamRequestStream after completion");
6397        }
6398        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6399            |bytes, handles| {
6400                match this.inner.channel().read_etc(cx, bytes, handles) {
6401                    std::task::Poll::Ready(Ok(())) => {}
6402                    std::task::Poll::Pending => return std::task::Poll::Pending,
6403                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6404                        this.is_terminated = true;
6405                        return std::task::Poll::Ready(None);
6406                    }
6407                    std::task::Poll::Ready(Err(e)) => {
6408                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6409                            e.into(),
6410                        ))))
6411                    }
6412                }
6413
6414                // A message has been received from the channel
6415                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6416
6417                std::task::Poll::Ready(Some(match header.ordinal {
6418                    0x7ec1e2b9cc6d2fbe => {
6419                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6420                        let mut req = fidl::new_empty!(
6421                            IsochronousStreamSetupDataPathRequest,
6422                            fidl::encoding::DefaultFuchsiaResourceDialect
6423                        );
6424                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamSetupDataPathRequest>(&header, _body_bytes, handles, &mut req)?;
6425                        let control_handle =
6426                            IsochronousStreamControlHandle { inner: this.inner.clone() };
6427                        Ok(IsochronousStreamRequest::SetupDataPath {
6428                            payload: req,
6429                            responder: IsochronousStreamSetupDataPathResponder {
6430                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6431                                tx_id: header.tx_id,
6432                            },
6433                        })
6434                    }
6435                    0x6d7d8b4950ed3a32 => {
6436                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6437                        let mut req = fidl::new_empty!(
6438                            fidl::encoding::EmptyPayload,
6439                            fidl::encoding::DefaultFuchsiaResourceDialect
6440                        );
6441                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6442                        let control_handle =
6443                            IsochronousStreamControlHandle { inner: this.inner.clone() };
6444                        Ok(IsochronousStreamRequest::Read {
6445                            responder: IsochronousStreamReadResponder {
6446                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6447                                tx_id: header.tx_id,
6448                            },
6449                        })
6450                    }
6451                    0x5282e90b667d0d43 => {
6452                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6453                        let mut req = fidl::new_empty!(
6454                            IsochronousStreamWriteRequest,
6455                            fidl::encoding::DefaultFuchsiaResourceDialect
6456                        );
6457                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamWriteRequest>(&header, _body_bytes, handles, &mut req)?;
6458                        let control_handle =
6459                            IsochronousStreamControlHandle { inner: this.inner.clone() };
6460                        Ok(IsochronousStreamRequest::Write {
6461                            payload: req,
6462                            responder: IsochronousStreamWriteResponder {
6463                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6464                                tx_id: header.tx_id,
6465                            },
6466                        })
6467                    }
6468                    _ if header.tx_id == 0
6469                        && header
6470                            .dynamic_flags()
6471                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6472                    {
6473                        Ok(IsochronousStreamRequest::_UnknownMethod {
6474                            ordinal: header.ordinal,
6475                            control_handle: IsochronousStreamControlHandle {
6476                                inner: this.inner.clone(),
6477                            },
6478                            method_type: fidl::MethodType::OneWay,
6479                        })
6480                    }
6481                    _ if header
6482                        .dynamic_flags()
6483                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6484                    {
6485                        this.inner.send_framework_err(
6486                            fidl::encoding::FrameworkErr::UnknownMethod,
6487                            header.tx_id,
6488                            header.ordinal,
6489                            header.dynamic_flags(),
6490                            (bytes, handles),
6491                        )?;
6492                        Ok(IsochronousStreamRequest::_UnknownMethod {
6493                            ordinal: header.ordinal,
6494                            control_handle: IsochronousStreamControlHandle {
6495                                inner: this.inner.clone(),
6496                            },
6497                            method_type: fidl::MethodType::TwoWay,
6498                        })
6499                    }
6500                    _ => Err(fidl::Error::UnknownOrdinal {
6501                        ordinal: header.ordinal,
6502                        protocol_name:
6503                            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6504                    }),
6505                }))
6506            },
6507        )
6508    }
6509}
6510
6511#[derive(Debug)]
6512pub enum IsochronousStreamRequest {
6513    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
6514    /// transport is currently supported.
6515    ///
6516    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
6517    /// direction.
6518    ///
6519    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
6520    /// accepted.
6521    ///
6522    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
6523    /// controller's supported range.
6524    SetupDataPath {
6525        payload: IsochronousStreamSetupDataPathRequest,
6526        responder: IsochronousStreamSetupDataPathResponder,
6527    },
6528    /// Receive data from an output (controller => host) ISO stream that has been established and
6529    /// set up. Designed to be used with a hanging get pattern.
6530    ///
6531    /// Can be invoked before the ISO data stream has been established and set up, but will not
6532    /// return until after it has been set up and data has been received.
6533    Read { responder: IsochronousStreamReadResponder },
6534    /// Send data to an established ISO stream (host => controller).
6535    ///
6536    /// Returns ZX_ERR_INTERNAL for any errors encountered.
6537    Write { payload: IsochronousStreamWriteRequest, responder: IsochronousStreamWriteResponder },
6538    /// An interaction was received which does not match any known method.
6539    #[non_exhaustive]
6540    _UnknownMethod {
6541        /// Ordinal of the method that was called.
6542        ordinal: u64,
6543        control_handle: IsochronousStreamControlHandle,
6544        method_type: fidl::MethodType,
6545    },
6546}
6547
6548impl IsochronousStreamRequest {
6549    #[allow(irrefutable_let_patterns)]
6550    pub fn into_setup_data_path(
6551        self,
6552    ) -> Option<(IsochronousStreamSetupDataPathRequest, IsochronousStreamSetupDataPathResponder)>
6553    {
6554        if let IsochronousStreamRequest::SetupDataPath { payload, responder } = self {
6555            Some((payload, responder))
6556        } else {
6557            None
6558        }
6559    }
6560
6561    #[allow(irrefutable_let_patterns)]
6562    pub fn into_read(self) -> Option<(IsochronousStreamReadResponder)> {
6563        if let IsochronousStreamRequest::Read { responder } = self {
6564            Some((responder))
6565        } else {
6566            None
6567        }
6568    }
6569
6570    #[allow(irrefutable_let_patterns)]
6571    pub fn into_write(
6572        self,
6573    ) -> Option<(IsochronousStreamWriteRequest, IsochronousStreamWriteResponder)> {
6574        if let IsochronousStreamRequest::Write { payload, responder } = self {
6575            Some((payload, responder))
6576        } else {
6577            None
6578        }
6579    }
6580
6581    /// Name of the method defined in FIDL
6582    pub fn method_name(&self) -> &'static str {
6583        match *self {
6584            IsochronousStreamRequest::SetupDataPath { .. } => "setup_data_path",
6585            IsochronousStreamRequest::Read { .. } => "read",
6586            IsochronousStreamRequest::Write { .. } => "write",
6587            IsochronousStreamRequest::_UnknownMethod {
6588                method_type: fidl::MethodType::OneWay,
6589                ..
6590            } => "unknown one-way method",
6591            IsochronousStreamRequest::_UnknownMethod {
6592                method_type: fidl::MethodType::TwoWay,
6593                ..
6594            } => "unknown two-way method",
6595        }
6596    }
6597}
6598
6599#[derive(Debug, Clone)]
6600pub struct IsochronousStreamControlHandle {
6601    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6602}
6603
6604impl fidl::endpoints::ControlHandle for IsochronousStreamControlHandle {
6605    fn shutdown(&self) {
6606        self.inner.shutdown()
6607    }
6608    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6609        self.inner.shutdown_with_epitaph(status)
6610    }
6611
6612    fn is_closed(&self) -> bool {
6613        self.inner.channel().is_closed()
6614    }
6615    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6616        self.inner.channel().on_closed()
6617    }
6618
6619    #[cfg(target_os = "fuchsia")]
6620    fn signal_peer(
6621        &self,
6622        clear_mask: zx::Signals,
6623        set_mask: zx::Signals,
6624    ) -> Result<(), zx_status::Status> {
6625        use fidl::Peered;
6626        self.inner.channel().signal_peer(clear_mask, set_mask)
6627    }
6628}
6629
6630impl IsochronousStreamControlHandle {
6631    pub fn send_on_established(
6632        &self,
6633        mut payload: &IsochronousStreamOnEstablishedRequest,
6634    ) -> Result<(), fidl::Error> {
6635        self.inner.send::<IsochronousStreamOnEstablishedRequest>(
6636            payload,
6637            0,
6638            0x341c50e9d10f3421,
6639            fidl::encoding::DynamicFlags::FLEXIBLE,
6640        )
6641    }
6642}
6643
6644#[must_use = "FIDL methods require a response to be sent"]
6645#[derive(Debug)]
6646pub struct IsochronousStreamSetupDataPathResponder {
6647    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
6648    tx_id: u32,
6649}
6650
6651/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
6652/// if the responder is dropped without sending a response, so that the client
6653/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6654impl std::ops::Drop for IsochronousStreamSetupDataPathResponder {
6655    fn drop(&mut self) {
6656        self.control_handle.shutdown();
6657        // Safety: drops once, never accessed again
6658        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6659    }
6660}
6661
6662impl fidl::endpoints::Responder for IsochronousStreamSetupDataPathResponder {
6663    type ControlHandle = IsochronousStreamControlHandle;
6664
6665    fn control_handle(&self) -> &IsochronousStreamControlHandle {
6666        &self.control_handle
6667    }
6668
6669    fn drop_without_shutdown(mut self) {
6670        // Safety: drops once, never accessed again due to mem::forget
6671        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6672        // Prevent Drop from running (which would shut down the channel)
6673        std::mem::forget(self);
6674    }
6675}
6676
6677impl IsochronousStreamSetupDataPathResponder {
6678    /// Sends a response to the FIDL transaction.
6679    ///
6680    /// Sets the channel to shutdown if an error occurs.
6681    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6682        let _result = self.send_raw(result);
6683        if _result.is_err() {
6684            self.control_handle.shutdown();
6685        }
6686        self.drop_without_shutdown();
6687        _result
6688    }
6689
6690    /// Similar to "send" but does not shutdown the channel if an error occurs.
6691    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6692        let _result = self.send_raw(result);
6693        self.drop_without_shutdown();
6694        _result
6695    }
6696
6697    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6698        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6699            fidl::encoding::EmptyStruct,
6700            i32,
6701        >>(
6702            fidl::encoding::FlexibleResult::new(result),
6703            self.tx_id,
6704            0x7ec1e2b9cc6d2fbe,
6705            fidl::encoding::DynamicFlags::FLEXIBLE,
6706        )
6707    }
6708}
6709
6710#[must_use = "FIDL methods require a response to be sent"]
6711#[derive(Debug)]
6712pub struct IsochronousStreamReadResponder {
6713    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
6714    tx_id: u32,
6715}
6716
6717/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
6718/// if the responder is dropped without sending a response, so that the client
6719/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6720impl std::ops::Drop for IsochronousStreamReadResponder {
6721    fn drop(&mut self) {
6722        self.control_handle.shutdown();
6723        // Safety: drops once, never accessed again
6724        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6725    }
6726}
6727
6728impl fidl::endpoints::Responder for IsochronousStreamReadResponder {
6729    type ControlHandle = IsochronousStreamControlHandle;
6730
6731    fn control_handle(&self) -> &IsochronousStreamControlHandle {
6732        &self.control_handle
6733    }
6734
6735    fn drop_without_shutdown(mut self) {
6736        // Safety: drops once, never accessed again due to mem::forget
6737        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6738        // Prevent Drop from running (which would shut down the channel)
6739        std::mem::forget(self);
6740    }
6741}
6742
6743impl IsochronousStreamReadResponder {
6744    /// Sends a response to the FIDL transaction.
6745    ///
6746    /// Sets the channel to shutdown if an error occurs.
6747    pub fn send(self, mut payload: &IsochronousStreamReadResponse) -> Result<(), fidl::Error> {
6748        let _result = self.send_raw(payload);
6749        if _result.is_err() {
6750            self.control_handle.shutdown();
6751        }
6752        self.drop_without_shutdown();
6753        _result
6754    }
6755
6756    /// Similar to "send" but does not shutdown the channel if an error occurs.
6757    pub fn send_no_shutdown_on_err(
6758        self,
6759        mut payload: &IsochronousStreamReadResponse,
6760    ) -> Result<(), fidl::Error> {
6761        let _result = self.send_raw(payload);
6762        self.drop_without_shutdown();
6763        _result
6764    }
6765
6766    fn send_raw(&self, mut payload: &IsochronousStreamReadResponse) -> Result<(), fidl::Error> {
6767        self.control_handle
6768            .inner
6769            .send::<fidl::encoding::FlexibleType<IsochronousStreamReadResponse>>(
6770                fidl::encoding::Flexible::new(payload),
6771                self.tx_id,
6772                0x6d7d8b4950ed3a32,
6773                fidl::encoding::DynamicFlags::FLEXIBLE,
6774            )
6775    }
6776}
6777
6778#[must_use = "FIDL methods require a response to be sent"]
6779#[derive(Debug)]
6780pub struct IsochronousStreamWriteResponder {
6781    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
6782    tx_id: u32,
6783}
6784
6785/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
6786/// if the responder is dropped without sending a response, so that the client
6787/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6788impl std::ops::Drop for IsochronousStreamWriteResponder {
6789    fn drop(&mut self) {
6790        self.control_handle.shutdown();
6791        // Safety: drops once, never accessed again
6792        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6793    }
6794}
6795
6796impl fidl::endpoints::Responder for IsochronousStreamWriteResponder {
6797    type ControlHandle = IsochronousStreamControlHandle;
6798
6799    fn control_handle(&self) -> &IsochronousStreamControlHandle {
6800        &self.control_handle
6801    }
6802
6803    fn drop_without_shutdown(mut self) {
6804        // Safety: drops once, never accessed again due to mem::forget
6805        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6806        // Prevent Drop from running (which would shut down the channel)
6807        std::mem::forget(self);
6808    }
6809}
6810
6811impl IsochronousStreamWriteResponder {
6812    /// Sends a response to the FIDL transaction.
6813    ///
6814    /// Sets the channel to shutdown if an error occurs.
6815    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6816        let _result = self.send_raw(result);
6817        if _result.is_err() {
6818            self.control_handle.shutdown();
6819        }
6820        self.drop_without_shutdown();
6821        _result
6822    }
6823
6824    /// Similar to "send" but does not shutdown the channel if an error occurs.
6825    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6826        let _result = self.send_raw(result);
6827        self.drop_without_shutdown();
6828        _result
6829    }
6830
6831    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6832        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6833            fidl::encoding::EmptyStruct,
6834            i32,
6835        >>(
6836            fidl::encoding::FlexibleResult::new(result),
6837            self.tx_id,
6838            0x5282e90b667d0d43,
6839            fidl::encoding::DynamicFlags::FLEXIBLE,
6840        )
6841    }
6842}
6843
6844#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6845pub struct PeripheralMarker;
6846
6847impl fidl::endpoints::ProtocolMarker for PeripheralMarker {
6848    type Proxy = PeripheralProxy;
6849    type RequestStream = PeripheralRequestStream;
6850    #[cfg(target_os = "fuchsia")]
6851    type SynchronousProxy = PeripheralSynchronousProxy;
6852
6853    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.Peripheral";
6854}
6855impl fidl::endpoints::DiscoverableProtocolMarker for PeripheralMarker {}
6856pub type PeripheralAdvertiseResult = Result<(), PeripheralError>;
6857pub type PeripheralStartAdvertisingResult = Result<(), PeripheralError>;
6858
6859pub trait PeripheralProxyInterface: Send + Sync {
6860    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
6861        + Send;
6862    fn r#listen_l2cap(
6863        &self,
6864        payload: ChannelListenerRegistryListenL2capRequest,
6865    ) -> Self::ListenL2capResponseFut;
6866    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralAdvertiseResult, fidl::Error>>
6867        + Send;
6868    fn r#advertise(
6869        &self,
6870        parameters: &AdvertisingParameters,
6871        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
6872    ) -> Self::AdvertiseResponseFut;
6873    type StartAdvertisingResponseFut: std::future::Future<Output = Result<PeripheralStartAdvertisingResult, fidl::Error>>
6874        + Send;
6875    fn r#start_advertising(
6876        &self,
6877        parameters: &AdvertisingParameters,
6878        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
6879    ) -> Self::StartAdvertisingResponseFut;
6880}
6881#[derive(Debug)]
6882#[cfg(target_os = "fuchsia")]
6883pub struct PeripheralSynchronousProxy {
6884    client: fidl::client::sync::Client,
6885}
6886
6887#[cfg(target_os = "fuchsia")]
6888impl fidl::endpoints::SynchronousProxy for PeripheralSynchronousProxy {
6889    type Proxy = PeripheralProxy;
6890    type Protocol = PeripheralMarker;
6891
6892    fn from_channel(inner: fidl::Channel) -> Self {
6893        Self::new(inner)
6894    }
6895
6896    fn into_channel(self) -> fidl::Channel {
6897        self.client.into_channel()
6898    }
6899
6900    fn as_channel(&self) -> &fidl::Channel {
6901        self.client.as_channel()
6902    }
6903}
6904
6905#[cfg(target_os = "fuchsia")]
6906impl PeripheralSynchronousProxy {
6907    pub fn new(channel: fidl::Channel) -> Self {
6908        let protocol_name = <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6909        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6910    }
6911
6912    pub fn into_channel(self) -> fidl::Channel {
6913        self.client.into_channel()
6914    }
6915
6916    /// Waits until an event arrives and returns it. It is safe for other
6917    /// threads to make concurrent requests while waiting for an event.
6918    pub fn wait_for_event(
6919        &self,
6920        deadline: zx::MonotonicInstant,
6921    ) -> Result<PeripheralEvent, fidl::Error> {
6922        PeripheralEvent::decode(self.client.wait_for_event(deadline)?)
6923    }
6924
6925    /// Register a listener for incoming channels. The registry will assign a
6926    /// PSM value that is unique for the local device, as well as open a
6927    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
6928    /// event that all PSMs have been assigned, this call will fail with
6929    /// `ZX_ERR_NO_RESOURCES`.
6930    ///
6931    /// Note that the method of service discovery or advertising is defined by
6932    /// the service or protocol, so it is the responsibility of the caller to
6933    /// communicate the assigned PSM to any clients.
6934    pub fn r#listen_l2cap(
6935        &self,
6936        mut payload: ChannelListenerRegistryListenL2capRequest,
6937        ___deadline: zx::MonotonicInstant,
6938    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
6939        let _response = self.client.send_query::<
6940            ChannelListenerRegistryListenL2capRequest,
6941            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
6942        >(
6943            &mut payload,
6944            0x39c6e9001d102338,
6945            fidl::encoding::DynamicFlags::empty(),
6946            ___deadline,
6947        )?;
6948        Ok(_response.map(|x| x))
6949    }
6950
6951    /// Start advertising continuously as a LE peripheral. If advertising cannot
6952    /// be initiated then `advertised_peripheral` will be closed and an error
6953    /// will be returned.
6954    ///
6955    /// This method may be called any number of times. To reconfigure an
6956    /// advertisement, first close the original advertisement and then initiate
6957    /// a new advertisement after an empty response is returned.
6958    ///
6959    /// If the client closes its end of the
6960    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
6961    /// advertising will be stopped. If the handle is closed before the request
6962    /// is fulfilled, advertising may be briefly enabled before it is
6963    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
6964    /// the Peripheral protocol, but this may be changed in the future
6965    /// (https://fxbug.dev/42157682).
6966    ///
6967    /// + request `parameters` Parameters used while configuring the advertising
6968    ///   instance.
6969    /// + request `advertised_peripheral` Protocol that remains valid for the
6970    ///   duration of this advertising session.
6971    /// - response An empty response will be sent when the advertisement is
6972    ///   successfully stopped (due to release of the `advertised_peripheral`
6973    ///   protocol). To prevent overlapping similar advertisements and transient
6974    ///   errors with limited advertising resources, waiting for a response is
6975    ///   recommended before calling `Advertise` again.
6976    /// * error If an error occurs, `advertised_peripheral` will be closed and a
6977    ///   `PeripheralError` will be returned.
6978    pub fn r#advertise(
6979        &self,
6980        mut parameters: &AdvertisingParameters,
6981        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
6982        ___deadline: zx::MonotonicInstant,
6983    ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
6984        let _response = self.client.send_query::<
6985            PeripheralAdvertiseRequest,
6986            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
6987        >(
6988            (parameters, advertised_peripheral,),
6989            0x2d9ec9260c32c17f,
6990            fidl::encoding::DynamicFlags::empty(),
6991            ___deadline,
6992        )?;
6993        Ok(_response.map(|x| x))
6994    }
6995
6996    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
6997    /// has successfully initiated. If advertising cannot be initiated, then the response will
6998    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
6999    ///
7000    /// This method can get called any number of times and successive calls can be made to
7001    /// reconfigure the advertising parameters. However only the most recent
7002    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
7003    ///
7004    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
7005    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
7006    /// advertisements.
7007    ///
7008    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
7009    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
7010    /// advertising will be briefly enabled before it is terminated.
7011    ///
7012    /// + request `parameters` Parameters used while configuring the advertising instance.
7013    /// + request `handle` Handle that remains valid for the duration of this advertising session.
7014    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
7015    ///         initiated. In this case the `handle` will be closed.
7016    pub fn r#start_advertising(
7017        &self,
7018        mut parameters: &AdvertisingParameters,
7019        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
7020        ___deadline: zx::MonotonicInstant,
7021    ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
7022        let _response = self.client.send_query::<
7023            PeripheralStartAdvertisingRequest,
7024            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
7025        >(
7026            (parameters, handle,),
7027            0x5875c1c575f00f7d,
7028            fidl::encoding::DynamicFlags::empty(),
7029            ___deadline,
7030        )?;
7031        Ok(_response.map(|x| x))
7032    }
7033}
7034
7035#[cfg(target_os = "fuchsia")]
7036impl From<PeripheralSynchronousProxy> for zx::Handle {
7037    fn from(value: PeripheralSynchronousProxy) -> Self {
7038        value.into_channel().into()
7039    }
7040}
7041
7042#[cfg(target_os = "fuchsia")]
7043impl From<fidl::Channel> for PeripheralSynchronousProxy {
7044    fn from(value: fidl::Channel) -> Self {
7045        Self::new(value)
7046    }
7047}
7048
7049#[cfg(target_os = "fuchsia")]
7050impl fidl::endpoints::FromClient for PeripheralSynchronousProxy {
7051    type Protocol = PeripheralMarker;
7052
7053    fn from_client(value: fidl::endpoints::ClientEnd<PeripheralMarker>) -> Self {
7054        Self::new(value.into_channel())
7055    }
7056}
7057
7058#[derive(Debug, Clone)]
7059pub struct PeripheralProxy {
7060    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7061}
7062
7063impl fidl::endpoints::Proxy for PeripheralProxy {
7064    type Protocol = PeripheralMarker;
7065
7066    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7067        Self::new(inner)
7068    }
7069
7070    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7071        self.client.into_channel().map_err(|client| Self { client })
7072    }
7073
7074    fn as_channel(&self) -> &::fidl::AsyncChannel {
7075        self.client.as_channel()
7076    }
7077}
7078
7079impl PeripheralProxy {
7080    /// Create a new Proxy for fuchsia.bluetooth.le/Peripheral.
7081    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7082        let protocol_name = <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7083        Self { client: fidl::client::Client::new(channel, protocol_name) }
7084    }
7085
7086    /// Get a Stream of events from the remote end of the protocol.
7087    ///
7088    /// # Panics
7089    ///
7090    /// Panics if the event stream was already taken.
7091    pub fn take_event_stream(&self) -> PeripheralEventStream {
7092        PeripheralEventStream { event_receiver: self.client.take_event_receiver() }
7093    }
7094
7095    /// Register a listener for incoming channels. The registry will assign a
7096    /// PSM value that is unique for the local device, as well as open a
7097    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
7098    /// event that all PSMs have been assigned, this call will fail with
7099    /// `ZX_ERR_NO_RESOURCES`.
7100    ///
7101    /// Note that the method of service discovery or advertising is defined by
7102    /// the service or protocol, so it is the responsibility of the caller to
7103    /// communicate the assigned PSM to any clients.
7104    pub fn r#listen_l2cap(
7105        &self,
7106        mut payload: ChannelListenerRegistryListenL2capRequest,
7107    ) -> fidl::client::QueryResponseFut<
7108        ChannelListenerRegistryListenL2capResult,
7109        fidl::encoding::DefaultFuchsiaResourceDialect,
7110    > {
7111        PeripheralProxyInterface::r#listen_l2cap(self, payload)
7112    }
7113
7114    /// Start advertising continuously as a LE peripheral. If advertising cannot
7115    /// be initiated then `advertised_peripheral` will be closed and an error
7116    /// will be returned.
7117    ///
7118    /// This method may be called any number of times. To reconfigure an
7119    /// advertisement, first close the original advertisement and then initiate
7120    /// a new advertisement after an empty response is returned.
7121    ///
7122    /// If the client closes its end of the
7123    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
7124    /// advertising will be stopped. If the handle is closed before the request
7125    /// is fulfilled, advertising may be briefly enabled before it is
7126    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
7127    /// the Peripheral protocol, but this may be changed in the future
7128    /// (https://fxbug.dev/42157682).
7129    ///
7130    /// + request `parameters` Parameters used while configuring the advertising
7131    ///   instance.
7132    /// + request `advertised_peripheral` Protocol that remains valid for the
7133    ///   duration of this advertising session.
7134    /// - response An empty response will be sent when the advertisement is
7135    ///   successfully stopped (due to release of the `advertised_peripheral`
7136    ///   protocol). To prevent overlapping similar advertisements and transient
7137    ///   errors with limited advertising resources, waiting for a response is
7138    ///   recommended before calling `Advertise` again.
7139    /// * error If an error occurs, `advertised_peripheral` will be closed and a
7140    ///   `PeripheralError` will be returned.
7141    pub fn r#advertise(
7142        &self,
7143        mut parameters: &AdvertisingParameters,
7144        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
7145    ) -> fidl::client::QueryResponseFut<
7146        PeripheralAdvertiseResult,
7147        fidl::encoding::DefaultFuchsiaResourceDialect,
7148    > {
7149        PeripheralProxyInterface::r#advertise(self, parameters, advertised_peripheral)
7150    }
7151
7152    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
7153    /// has successfully initiated. If advertising cannot be initiated, then the response will
7154    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
7155    ///
7156    /// This method can get called any number of times and successive calls can be made to
7157    /// reconfigure the advertising parameters. However only the most recent
7158    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
7159    ///
7160    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
7161    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
7162    /// advertisements.
7163    ///
7164    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
7165    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
7166    /// advertising will be briefly enabled before it is terminated.
7167    ///
7168    /// + request `parameters` Parameters used while configuring the advertising instance.
7169    /// + request `handle` Handle that remains valid for the duration of this advertising session.
7170    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
7171    ///         initiated. In this case the `handle` will be closed.
7172    pub fn r#start_advertising(
7173        &self,
7174        mut parameters: &AdvertisingParameters,
7175        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
7176    ) -> fidl::client::QueryResponseFut<
7177        PeripheralStartAdvertisingResult,
7178        fidl::encoding::DefaultFuchsiaResourceDialect,
7179    > {
7180        PeripheralProxyInterface::r#start_advertising(self, parameters, handle)
7181    }
7182}
7183
7184impl PeripheralProxyInterface for PeripheralProxy {
7185    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
7186        ChannelListenerRegistryListenL2capResult,
7187        fidl::encoding::DefaultFuchsiaResourceDialect,
7188    >;
7189    fn r#listen_l2cap(
7190        &self,
7191        mut payload: ChannelListenerRegistryListenL2capRequest,
7192    ) -> Self::ListenL2capResponseFut {
7193        fn _decode(
7194            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7195        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
7196            let _response = fidl::client::decode_transaction_body::<
7197                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
7198                fidl::encoding::DefaultFuchsiaResourceDialect,
7199                0x39c6e9001d102338,
7200            >(_buf?)?;
7201            Ok(_response.map(|x| x))
7202        }
7203        self.client.send_query_and_decode::<
7204            ChannelListenerRegistryListenL2capRequest,
7205            ChannelListenerRegistryListenL2capResult,
7206        >(
7207            &mut payload,
7208            0x39c6e9001d102338,
7209            fidl::encoding::DynamicFlags::empty(),
7210            _decode,
7211        )
7212    }
7213
7214    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
7215        PeripheralAdvertiseResult,
7216        fidl::encoding::DefaultFuchsiaResourceDialect,
7217    >;
7218    fn r#advertise(
7219        &self,
7220        mut parameters: &AdvertisingParameters,
7221        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
7222    ) -> Self::AdvertiseResponseFut {
7223        fn _decode(
7224            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7225        ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
7226            let _response = fidl::client::decode_transaction_body::<
7227                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
7228                fidl::encoding::DefaultFuchsiaResourceDialect,
7229                0x2d9ec9260c32c17f,
7230            >(_buf?)?;
7231            Ok(_response.map(|x| x))
7232        }
7233        self.client.send_query_and_decode::<PeripheralAdvertiseRequest, PeripheralAdvertiseResult>(
7234            (parameters, advertised_peripheral),
7235            0x2d9ec9260c32c17f,
7236            fidl::encoding::DynamicFlags::empty(),
7237            _decode,
7238        )
7239    }
7240
7241    type StartAdvertisingResponseFut = fidl::client::QueryResponseFut<
7242        PeripheralStartAdvertisingResult,
7243        fidl::encoding::DefaultFuchsiaResourceDialect,
7244    >;
7245    fn r#start_advertising(
7246        &self,
7247        mut parameters: &AdvertisingParameters,
7248        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
7249    ) -> Self::StartAdvertisingResponseFut {
7250        fn _decode(
7251            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7252        ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
7253            let _response = fidl::client::decode_transaction_body::<
7254                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
7255                fidl::encoding::DefaultFuchsiaResourceDialect,
7256                0x5875c1c575f00f7d,
7257            >(_buf?)?;
7258            Ok(_response.map(|x| x))
7259        }
7260        self.client.send_query_and_decode::<
7261            PeripheralStartAdvertisingRequest,
7262            PeripheralStartAdvertisingResult,
7263        >(
7264            (parameters, handle,),
7265            0x5875c1c575f00f7d,
7266            fidl::encoding::DynamicFlags::empty(),
7267            _decode,
7268        )
7269    }
7270}
7271
7272pub struct PeripheralEventStream {
7273    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7274}
7275
7276impl std::marker::Unpin for PeripheralEventStream {}
7277
7278impl futures::stream::FusedStream for PeripheralEventStream {
7279    fn is_terminated(&self) -> bool {
7280        self.event_receiver.is_terminated()
7281    }
7282}
7283
7284impl futures::Stream for PeripheralEventStream {
7285    type Item = Result<PeripheralEvent, fidl::Error>;
7286
7287    fn poll_next(
7288        mut self: std::pin::Pin<&mut Self>,
7289        cx: &mut std::task::Context<'_>,
7290    ) -> std::task::Poll<Option<Self::Item>> {
7291        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7292            &mut self.event_receiver,
7293            cx
7294        )?) {
7295            Some(buf) => std::task::Poll::Ready(Some(PeripheralEvent::decode(buf))),
7296            None => std::task::Poll::Ready(None),
7297        }
7298    }
7299}
7300
7301#[derive(Debug)]
7302pub enum PeripheralEvent {
7303    OnPeerConnected { peer: Peer, connection: fidl::endpoints::ClientEnd<ConnectionMarker> },
7304}
7305
7306impl PeripheralEvent {
7307    #[allow(irrefutable_let_patterns)]
7308    pub fn into_on_peer_connected(
7309        self,
7310    ) -> Option<(Peer, fidl::endpoints::ClientEnd<ConnectionMarker>)> {
7311        if let PeripheralEvent::OnPeerConnected { peer, connection } = self {
7312            Some((peer, connection))
7313        } else {
7314            None
7315        }
7316    }
7317
7318    /// Decodes a message buffer as a [`PeripheralEvent`].
7319    fn decode(
7320        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7321    ) -> Result<PeripheralEvent, fidl::Error> {
7322        let (bytes, _handles) = buf.split_mut();
7323        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7324        debug_assert_eq!(tx_header.tx_id, 0);
7325        match tx_header.ordinal {
7326            0x16135d464299e356 => {
7327                let mut out = fidl::new_empty!(
7328                    PeripheralOnPeerConnectedRequest,
7329                    fidl::encoding::DefaultFuchsiaResourceDialect
7330                );
7331                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralOnPeerConnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7332                Ok((PeripheralEvent::OnPeerConnected {
7333                    peer: out.peer,
7334                    connection: out.connection,
7335                }))
7336            }
7337            _ => Err(fidl::Error::UnknownOrdinal {
7338                ordinal: tx_header.ordinal,
7339                protocol_name: <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7340            }),
7341        }
7342    }
7343}
7344
7345/// A Stream of incoming requests for fuchsia.bluetooth.le/Peripheral.
7346pub struct PeripheralRequestStream {
7347    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7348    is_terminated: bool,
7349}
7350
7351impl std::marker::Unpin for PeripheralRequestStream {}
7352
7353impl futures::stream::FusedStream for PeripheralRequestStream {
7354    fn is_terminated(&self) -> bool {
7355        self.is_terminated
7356    }
7357}
7358
7359impl fidl::endpoints::RequestStream for PeripheralRequestStream {
7360    type Protocol = PeripheralMarker;
7361    type ControlHandle = PeripheralControlHandle;
7362
7363    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7364        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7365    }
7366
7367    fn control_handle(&self) -> Self::ControlHandle {
7368        PeripheralControlHandle { inner: self.inner.clone() }
7369    }
7370
7371    fn into_inner(
7372        self,
7373    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7374    {
7375        (self.inner, self.is_terminated)
7376    }
7377
7378    fn from_inner(
7379        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7380        is_terminated: bool,
7381    ) -> Self {
7382        Self { inner, is_terminated }
7383    }
7384}
7385
7386impl futures::Stream for PeripheralRequestStream {
7387    type Item = Result<PeripheralRequest, fidl::Error>;
7388
7389    fn poll_next(
7390        mut self: std::pin::Pin<&mut Self>,
7391        cx: &mut std::task::Context<'_>,
7392    ) -> std::task::Poll<Option<Self::Item>> {
7393        let this = &mut *self;
7394        if this.inner.check_shutdown(cx) {
7395            this.is_terminated = true;
7396            return std::task::Poll::Ready(None);
7397        }
7398        if this.is_terminated {
7399            panic!("polled PeripheralRequestStream after completion");
7400        }
7401        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7402            |bytes, handles| {
7403                match this.inner.channel().read_etc(cx, bytes, handles) {
7404                    std::task::Poll::Ready(Ok(())) => {}
7405                    std::task::Poll::Pending => return std::task::Poll::Pending,
7406                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7407                        this.is_terminated = true;
7408                        return std::task::Poll::Ready(None);
7409                    }
7410                    std::task::Poll::Ready(Err(e)) => {
7411                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7412                            e.into(),
7413                        ))))
7414                    }
7415                }
7416
7417                // A message has been received from the channel
7418                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7419
7420                std::task::Poll::Ready(Some(match header.ordinal {
7421                    0x39c6e9001d102338 => {
7422                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7423                        let mut req = fidl::new_empty!(
7424                            ChannelListenerRegistryListenL2capRequest,
7425                            fidl::encoding::DefaultFuchsiaResourceDialect
7426                        );
7427                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
7428                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
7429                        Ok(PeripheralRequest::ListenL2cap {
7430                            payload: req,
7431                            responder: PeripheralListenL2capResponder {
7432                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7433                                tx_id: header.tx_id,
7434                            },
7435                        })
7436                    }
7437                    0x2d9ec9260c32c17f => {
7438                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7439                        let mut req = fidl::new_empty!(
7440                            PeripheralAdvertiseRequest,
7441                            fidl::encoding::DefaultFuchsiaResourceDialect
7442                        );
7443                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
7444                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
7445                        Ok(PeripheralRequest::Advertise {
7446                            parameters: req.parameters,
7447                            advertised_peripheral: req.advertised_peripheral,
7448
7449                            responder: PeripheralAdvertiseResponder {
7450                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7451                                tx_id: header.tx_id,
7452                            },
7453                        })
7454                    }
7455                    0x5875c1c575f00f7d => {
7456                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7457                        let mut req = fidl::new_empty!(
7458                            PeripheralStartAdvertisingRequest,
7459                            fidl::encoding::DefaultFuchsiaResourceDialect
7460                        );
7461                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralStartAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
7462                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
7463                        Ok(PeripheralRequest::StartAdvertising {
7464                            parameters: req.parameters,
7465                            handle: req.handle,
7466
7467                            responder: PeripheralStartAdvertisingResponder {
7468                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7469                                tx_id: header.tx_id,
7470                            },
7471                        })
7472                    }
7473                    _ => Err(fidl::Error::UnknownOrdinal {
7474                        ordinal: header.ordinal,
7475                        protocol_name:
7476                            <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7477                    }),
7478                }))
7479            },
7480        )
7481    }
7482}
7483
7484#[derive(Debug)]
7485pub enum PeripheralRequest {
7486    /// Register a listener for incoming channels. The registry will assign a
7487    /// PSM value that is unique for the local device, as well as open a
7488    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
7489    /// event that all PSMs have been assigned, this call will fail with
7490    /// `ZX_ERR_NO_RESOURCES`.
7491    ///
7492    /// Note that the method of service discovery or advertising is defined by
7493    /// the service or protocol, so it is the responsibility of the caller to
7494    /// communicate the assigned PSM to any clients.
7495    ListenL2cap {
7496        payload: ChannelListenerRegistryListenL2capRequest,
7497        responder: PeripheralListenL2capResponder,
7498    },
7499    /// Start advertising continuously as a LE peripheral. If advertising cannot
7500    /// be initiated then `advertised_peripheral` will be closed and an error
7501    /// will be returned.
7502    ///
7503    /// This method may be called any number of times. To reconfigure an
7504    /// advertisement, first close the original advertisement and then initiate
7505    /// a new advertisement after an empty response is returned.
7506    ///
7507    /// If the client closes its end of the
7508    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
7509    /// advertising will be stopped. If the handle is closed before the request
7510    /// is fulfilled, advertising may be briefly enabled before it is
7511    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
7512    /// the Peripheral protocol, but this may be changed in the future
7513    /// (https://fxbug.dev/42157682).
7514    ///
7515    /// + request `parameters` Parameters used while configuring the advertising
7516    ///   instance.
7517    /// + request `advertised_peripheral` Protocol that remains valid for the
7518    ///   duration of this advertising session.
7519    /// - response An empty response will be sent when the advertisement is
7520    ///   successfully stopped (due to release of the `advertised_peripheral`
7521    ///   protocol). To prevent overlapping similar advertisements and transient
7522    ///   errors with limited advertising resources, waiting for a response is
7523    ///   recommended before calling `Advertise` again.
7524    /// * error If an error occurs, `advertised_peripheral` will be closed and a
7525    ///   `PeripheralError` will be returned.
7526    Advertise {
7527        parameters: AdvertisingParameters,
7528        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
7529        responder: PeripheralAdvertiseResponder,
7530    },
7531    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
7532    /// has successfully initiated. If advertising cannot be initiated, then the response will
7533    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
7534    ///
7535    /// This method can get called any number of times and successive calls can be made to
7536    /// reconfigure the advertising parameters. However only the most recent
7537    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
7538    ///
7539    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
7540    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
7541    /// advertisements.
7542    ///
7543    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
7544    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
7545    /// advertising will be briefly enabled before it is terminated.
7546    ///
7547    /// + request `parameters` Parameters used while configuring the advertising instance.
7548    /// + request `handle` Handle that remains valid for the duration of this advertising session.
7549    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
7550    ///         initiated. In this case the `handle` will be closed.
7551    StartAdvertising {
7552        parameters: AdvertisingParameters,
7553        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
7554        responder: PeripheralStartAdvertisingResponder,
7555    },
7556}
7557
7558impl PeripheralRequest {
7559    #[allow(irrefutable_let_patterns)]
7560    pub fn into_listen_l2cap(
7561        self,
7562    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PeripheralListenL2capResponder)> {
7563        if let PeripheralRequest::ListenL2cap { payload, responder } = self {
7564            Some((payload, responder))
7565        } else {
7566            None
7567        }
7568    }
7569
7570    #[allow(irrefutable_let_patterns)]
7571    pub fn into_advertise(
7572        self,
7573    ) -> Option<(
7574        AdvertisingParameters,
7575        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
7576        PeripheralAdvertiseResponder,
7577    )> {
7578        if let PeripheralRequest::Advertise { parameters, advertised_peripheral, responder } = self
7579        {
7580            Some((parameters, advertised_peripheral, responder))
7581        } else {
7582            None
7583        }
7584    }
7585
7586    #[allow(irrefutable_let_patterns)]
7587    pub fn into_start_advertising(
7588        self,
7589    ) -> Option<(
7590        AdvertisingParameters,
7591        fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
7592        PeripheralStartAdvertisingResponder,
7593    )> {
7594        if let PeripheralRequest::StartAdvertising { parameters, handle, responder } = self {
7595            Some((parameters, handle, responder))
7596        } else {
7597            None
7598        }
7599    }
7600
7601    /// Name of the method defined in FIDL
7602    pub fn method_name(&self) -> &'static str {
7603        match *self {
7604            PeripheralRequest::ListenL2cap { .. } => "listen_l2cap",
7605            PeripheralRequest::Advertise { .. } => "advertise",
7606            PeripheralRequest::StartAdvertising { .. } => "start_advertising",
7607        }
7608    }
7609}
7610
7611#[derive(Debug, Clone)]
7612pub struct PeripheralControlHandle {
7613    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7614}
7615
7616impl fidl::endpoints::ControlHandle for PeripheralControlHandle {
7617    fn shutdown(&self) {
7618        self.inner.shutdown()
7619    }
7620    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7621        self.inner.shutdown_with_epitaph(status)
7622    }
7623
7624    fn is_closed(&self) -> bool {
7625        self.inner.channel().is_closed()
7626    }
7627    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7628        self.inner.channel().on_closed()
7629    }
7630
7631    #[cfg(target_os = "fuchsia")]
7632    fn signal_peer(
7633        &self,
7634        clear_mask: zx::Signals,
7635        set_mask: zx::Signals,
7636    ) -> Result<(), zx_status::Status> {
7637        use fidl::Peered;
7638        self.inner.channel().signal_peer(clear_mask, set_mask)
7639    }
7640}
7641
7642impl PeripheralControlHandle {
7643    pub fn send_on_peer_connected(
7644        &self,
7645        mut peer: &Peer,
7646        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
7647    ) -> Result<(), fidl::Error> {
7648        self.inner.send::<PeripheralOnPeerConnectedRequest>(
7649            (peer, connection),
7650            0,
7651            0x16135d464299e356,
7652            fidl::encoding::DynamicFlags::empty(),
7653        )
7654    }
7655}
7656
7657#[must_use = "FIDL methods require a response to be sent"]
7658#[derive(Debug)]
7659pub struct PeripheralListenL2capResponder {
7660    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
7661    tx_id: u32,
7662}
7663
7664/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
7665/// if the responder is dropped without sending a response, so that the client
7666/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7667impl std::ops::Drop for PeripheralListenL2capResponder {
7668    fn drop(&mut self) {
7669        self.control_handle.shutdown();
7670        // Safety: drops once, never accessed again
7671        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7672    }
7673}
7674
7675impl fidl::endpoints::Responder for PeripheralListenL2capResponder {
7676    type ControlHandle = PeripheralControlHandle;
7677
7678    fn control_handle(&self) -> &PeripheralControlHandle {
7679        &self.control_handle
7680    }
7681
7682    fn drop_without_shutdown(mut self) {
7683        // Safety: drops once, never accessed again due to mem::forget
7684        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7685        // Prevent Drop from running (which would shut down the channel)
7686        std::mem::forget(self);
7687    }
7688}
7689
7690impl PeripheralListenL2capResponder {
7691    /// Sends a response to the FIDL transaction.
7692    ///
7693    /// Sets the channel to shutdown if an error occurs.
7694    pub fn send(
7695        self,
7696        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
7697    ) -> Result<(), fidl::Error> {
7698        let _result = self.send_raw(result);
7699        if _result.is_err() {
7700            self.control_handle.shutdown();
7701        }
7702        self.drop_without_shutdown();
7703        _result
7704    }
7705
7706    /// Similar to "send" but does not shutdown the channel if an error occurs.
7707    pub fn send_no_shutdown_on_err(
7708        self,
7709        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
7710    ) -> Result<(), fidl::Error> {
7711        let _result = self.send_raw(result);
7712        self.drop_without_shutdown();
7713        _result
7714    }
7715
7716    fn send_raw(
7717        &self,
7718        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
7719    ) -> Result<(), fidl::Error> {
7720        self.control_handle.inner.send::<fidl::encoding::ResultType<
7721            ChannelListenerRegistryListenL2capResponse,
7722            i32,
7723        >>(
7724            result,
7725            self.tx_id,
7726            0x39c6e9001d102338,
7727            fidl::encoding::DynamicFlags::empty(),
7728        )
7729    }
7730}
7731
7732#[must_use = "FIDL methods require a response to be sent"]
7733#[derive(Debug)]
7734pub struct PeripheralAdvertiseResponder {
7735    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
7736    tx_id: u32,
7737}
7738
7739/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
7740/// if the responder is dropped without sending a response, so that the client
7741/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7742impl std::ops::Drop for PeripheralAdvertiseResponder {
7743    fn drop(&mut self) {
7744        self.control_handle.shutdown();
7745        // Safety: drops once, never accessed again
7746        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7747    }
7748}
7749
7750impl fidl::endpoints::Responder for PeripheralAdvertiseResponder {
7751    type ControlHandle = PeripheralControlHandle;
7752
7753    fn control_handle(&self) -> &PeripheralControlHandle {
7754        &self.control_handle
7755    }
7756
7757    fn drop_without_shutdown(mut self) {
7758        // Safety: drops once, never accessed again due to mem::forget
7759        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7760        // Prevent Drop from running (which would shut down the channel)
7761        std::mem::forget(self);
7762    }
7763}
7764
7765impl PeripheralAdvertiseResponder {
7766    /// Sends a response to the FIDL transaction.
7767    ///
7768    /// Sets the channel to shutdown if an error occurs.
7769    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
7770        let _result = self.send_raw(result);
7771        if _result.is_err() {
7772            self.control_handle.shutdown();
7773        }
7774        self.drop_without_shutdown();
7775        _result
7776    }
7777
7778    /// Similar to "send" but does not shutdown the channel if an error occurs.
7779    pub fn send_no_shutdown_on_err(
7780        self,
7781        mut result: Result<(), PeripheralError>,
7782    ) -> Result<(), fidl::Error> {
7783        let _result = self.send_raw(result);
7784        self.drop_without_shutdown();
7785        _result
7786    }
7787
7788    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
7789        self.control_handle.inner.send::<fidl::encoding::ResultType<
7790            fidl::encoding::EmptyStruct,
7791            PeripheralError,
7792        >>(
7793            result,
7794            self.tx_id,
7795            0x2d9ec9260c32c17f,
7796            fidl::encoding::DynamicFlags::empty(),
7797        )
7798    }
7799}
7800
7801#[must_use = "FIDL methods require a response to be sent"]
7802#[derive(Debug)]
7803pub struct PeripheralStartAdvertisingResponder {
7804    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
7805    tx_id: u32,
7806}
7807
7808/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
7809/// if the responder is dropped without sending a response, so that the client
7810/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7811impl std::ops::Drop for PeripheralStartAdvertisingResponder {
7812    fn drop(&mut self) {
7813        self.control_handle.shutdown();
7814        // Safety: drops once, never accessed again
7815        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7816    }
7817}
7818
7819impl fidl::endpoints::Responder for PeripheralStartAdvertisingResponder {
7820    type ControlHandle = PeripheralControlHandle;
7821
7822    fn control_handle(&self) -> &PeripheralControlHandle {
7823        &self.control_handle
7824    }
7825
7826    fn drop_without_shutdown(mut self) {
7827        // Safety: drops once, never accessed again due to mem::forget
7828        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7829        // Prevent Drop from running (which would shut down the channel)
7830        std::mem::forget(self);
7831    }
7832}
7833
7834impl PeripheralStartAdvertisingResponder {
7835    /// Sends a response to the FIDL transaction.
7836    ///
7837    /// Sets the channel to shutdown if an error occurs.
7838    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
7839        let _result = self.send_raw(result);
7840        if _result.is_err() {
7841            self.control_handle.shutdown();
7842        }
7843        self.drop_without_shutdown();
7844        _result
7845    }
7846
7847    /// Similar to "send" but does not shutdown the channel if an error occurs.
7848    pub fn send_no_shutdown_on_err(
7849        self,
7850        mut result: Result<(), PeripheralError>,
7851    ) -> Result<(), fidl::Error> {
7852        let _result = self.send_raw(result);
7853        self.drop_without_shutdown();
7854        _result
7855    }
7856
7857    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
7858        self.control_handle.inner.send::<fidl::encoding::ResultType<
7859            fidl::encoding::EmptyStruct,
7860            PeripheralError,
7861        >>(
7862            result,
7863            self.tx_id,
7864            0x5875c1c575f00f7d,
7865            fidl::encoding::DynamicFlags::empty(),
7866        )
7867    }
7868}
7869
7870#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7871pub struct PrivilegedPeripheralMarker;
7872
7873impl fidl::endpoints::ProtocolMarker for PrivilegedPeripheralMarker {
7874    type Proxy = PrivilegedPeripheralProxy;
7875    type RequestStream = PrivilegedPeripheralRequestStream;
7876    #[cfg(target_os = "fuchsia")]
7877    type SynchronousProxy = PrivilegedPeripheralSynchronousProxy;
7878
7879    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.PrivilegedPeripheral";
7880}
7881impl fidl::endpoints::DiscoverableProtocolMarker for PrivilegedPeripheralMarker {}
7882
7883pub trait PrivilegedPeripheralProxyInterface: Send + Sync {
7884    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
7885        + Send;
7886    fn r#listen_l2cap(
7887        &self,
7888        payload: ChannelListenerRegistryListenL2capRequest,
7889    ) -> Self::ListenL2capResponseFut;
7890    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralAdvertiseResult, fidl::Error>>
7891        + Send;
7892    fn r#advertise(
7893        &self,
7894        parameters: &AdvertisingParameters,
7895        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
7896    ) -> Self::AdvertiseResponseFut;
7897    type StartAdvertisingResponseFut: std::future::Future<Output = Result<PeripheralStartAdvertisingResult, fidl::Error>>
7898        + Send;
7899    fn r#start_advertising(
7900        &self,
7901        parameters: &AdvertisingParameters,
7902        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
7903    ) -> Self::StartAdvertisingResponseFut;
7904}
7905#[derive(Debug)]
7906#[cfg(target_os = "fuchsia")]
7907pub struct PrivilegedPeripheralSynchronousProxy {
7908    client: fidl::client::sync::Client,
7909}
7910
7911#[cfg(target_os = "fuchsia")]
7912impl fidl::endpoints::SynchronousProxy for PrivilegedPeripheralSynchronousProxy {
7913    type Proxy = PrivilegedPeripheralProxy;
7914    type Protocol = PrivilegedPeripheralMarker;
7915
7916    fn from_channel(inner: fidl::Channel) -> Self {
7917        Self::new(inner)
7918    }
7919
7920    fn into_channel(self) -> fidl::Channel {
7921        self.client.into_channel()
7922    }
7923
7924    fn as_channel(&self) -> &fidl::Channel {
7925        self.client.as_channel()
7926    }
7927}
7928
7929#[cfg(target_os = "fuchsia")]
7930impl PrivilegedPeripheralSynchronousProxy {
7931    pub fn new(channel: fidl::Channel) -> Self {
7932        let protocol_name =
7933            <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7934        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7935    }
7936
7937    pub fn into_channel(self) -> fidl::Channel {
7938        self.client.into_channel()
7939    }
7940
7941    /// Waits until an event arrives and returns it. It is safe for other
7942    /// threads to make concurrent requests while waiting for an event.
7943    pub fn wait_for_event(
7944        &self,
7945        deadline: zx::MonotonicInstant,
7946    ) -> Result<PrivilegedPeripheralEvent, fidl::Error> {
7947        PrivilegedPeripheralEvent::decode(self.client.wait_for_event(deadline)?)
7948    }
7949
7950    /// Register a listener for incoming channels. The registry will assign a
7951    /// PSM value that is unique for the local device, as well as open a
7952    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
7953    /// event that all PSMs have been assigned, this call will fail with
7954    /// `ZX_ERR_NO_RESOURCES`.
7955    ///
7956    /// Note that the method of service discovery or advertising is defined by
7957    /// the service or protocol, so it is the responsibility of the caller to
7958    /// communicate the assigned PSM to any clients.
7959    pub fn r#listen_l2cap(
7960        &self,
7961        mut payload: ChannelListenerRegistryListenL2capRequest,
7962        ___deadline: zx::MonotonicInstant,
7963    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
7964        let _response = self.client.send_query::<
7965            ChannelListenerRegistryListenL2capRequest,
7966            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
7967        >(
7968            &mut payload,
7969            0x39c6e9001d102338,
7970            fidl::encoding::DynamicFlags::empty(),
7971            ___deadline,
7972        )?;
7973        Ok(_response.map(|x| x))
7974    }
7975
7976    /// Start advertising continuously as a LE peripheral. If advertising cannot
7977    /// be initiated then `advertised_peripheral` will be closed and an error
7978    /// will be returned.
7979    ///
7980    /// This method may be called any number of times. To reconfigure an
7981    /// advertisement, first close the original advertisement and then initiate
7982    /// a new advertisement after an empty response is returned.
7983    ///
7984    /// If the client closes its end of the
7985    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
7986    /// advertising will be stopped. If the handle is closed before the request
7987    /// is fulfilled, advertising may be briefly enabled before it is
7988    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
7989    /// the Peripheral protocol, but this may be changed in the future
7990    /// (https://fxbug.dev/42157682).
7991    ///
7992    /// + request `parameters` Parameters used while configuring the advertising
7993    ///   instance.
7994    /// + request `advertised_peripheral` Protocol that remains valid for the
7995    ///   duration of this advertising session.
7996    /// - response An empty response will be sent when the advertisement is
7997    ///   successfully stopped (due to release of the `advertised_peripheral`
7998    ///   protocol). To prevent overlapping similar advertisements and transient
7999    ///   errors with limited advertising resources, waiting for a response is
8000    ///   recommended before calling `Advertise` again.
8001    /// * error If an error occurs, `advertised_peripheral` will be closed and a
8002    ///   `PeripheralError` will be returned.
8003    pub fn r#advertise(
8004        &self,
8005        mut parameters: &AdvertisingParameters,
8006        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8007        ___deadline: zx::MonotonicInstant,
8008    ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
8009        let _response = self.client.send_query::<
8010            PeripheralAdvertiseRequest,
8011            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8012        >(
8013            (parameters, advertised_peripheral,),
8014            0x2d9ec9260c32c17f,
8015            fidl::encoding::DynamicFlags::empty(),
8016            ___deadline,
8017        )?;
8018        Ok(_response.map(|x| x))
8019    }
8020
8021    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
8022    /// has successfully initiated. If advertising cannot be initiated, then the response will
8023    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
8024    ///
8025    /// This method can get called any number of times and successive calls can be made to
8026    /// reconfigure the advertising parameters. However only the most recent
8027    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
8028    ///
8029    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
8030    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
8031    /// advertisements.
8032    ///
8033    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
8034    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
8035    /// advertising will be briefly enabled before it is terminated.
8036    ///
8037    /// + request `parameters` Parameters used while configuring the advertising instance.
8038    /// + request `handle` Handle that remains valid for the duration of this advertising session.
8039    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
8040    ///         initiated. In this case the `handle` will be closed.
8041    pub fn r#start_advertising(
8042        &self,
8043        mut parameters: &AdvertisingParameters,
8044        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8045        ___deadline: zx::MonotonicInstant,
8046    ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
8047        let _response = self.client.send_query::<
8048            PeripheralStartAdvertisingRequest,
8049            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8050        >(
8051            (parameters, handle,),
8052            0x5875c1c575f00f7d,
8053            fidl::encoding::DynamicFlags::empty(),
8054            ___deadline,
8055        )?;
8056        Ok(_response.map(|x| x))
8057    }
8058}
8059
8060#[cfg(target_os = "fuchsia")]
8061impl From<PrivilegedPeripheralSynchronousProxy> for zx::Handle {
8062    fn from(value: PrivilegedPeripheralSynchronousProxy) -> Self {
8063        value.into_channel().into()
8064    }
8065}
8066
8067#[cfg(target_os = "fuchsia")]
8068impl From<fidl::Channel> for PrivilegedPeripheralSynchronousProxy {
8069    fn from(value: fidl::Channel) -> Self {
8070        Self::new(value)
8071    }
8072}
8073
8074#[cfg(target_os = "fuchsia")]
8075impl fidl::endpoints::FromClient for PrivilegedPeripheralSynchronousProxy {
8076    type Protocol = PrivilegedPeripheralMarker;
8077
8078    fn from_client(value: fidl::endpoints::ClientEnd<PrivilegedPeripheralMarker>) -> Self {
8079        Self::new(value.into_channel())
8080    }
8081}
8082
8083#[derive(Debug, Clone)]
8084pub struct PrivilegedPeripheralProxy {
8085    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8086}
8087
8088impl fidl::endpoints::Proxy for PrivilegedPeripheralProxy {
8089    type Protocol = PrivilegedPeripheralMarker;
8090
8091    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8092        Self::new(inner)
8093    }
8094
8095    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8096        self.client.into_channel().map_err(|client| Self { client })
8097    }
8098
8099    fn as_channel(&self) -> &::fidl::AsyncChannel {
8100        self.client.as_channel()
8101    }
8102}
8103
8104impl PrivilegedPeripheralProxy {
8105    /// Create a new Proxy for fuchsia.bluetooth.le/PrivilegedPeripheral.
8106    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8107        let protocol_name =
8108            <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8109        Self { client: fidl::client::Client::new(channel, protocol_name) }
8110    }
8111
8112    /// Get a Stream of events from the remote end of the protocol.
8113    ///
8114    /// # Panics
8115    ///
8116    /// Panics if the event stream was already taken.
8117    pub fn take_event_stream(&self) -> PrivilegedPeripheralEventStream {
8118        PrivilegedPeripheralEventStream { event_receiver: self.client.take_event_receiver() }
8119    }
8120
8121    /// Register a listener for incoming channels. The registry will assign a
8122    /// PSM value that is unique for the local device, as well as open a
8123    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
8124    /// event that all PSMs have been assigned, this call will fail with
8125    /// `ZX_ERR_NO_RESOURCES`.
8126    ///
8127    /// Note that the method of service discovery or advertising is defined by
8128    /// the service or protocol, so it is the responsibility of the caller to
8129    /// communicate the assigned PSM to any clients.
8130    pub fn r#listen_l2cap(
8131        &self,
8132        mut payload: ChannelListenerRegistryListenL2capRequest,
8133    ) -> fidl::client::QueryResponseFut<
8134        ChannelListenerRegistryListenL2capResult,
8135        fidl::encoding::DefaultFuchsiaResourceDialect,
8136    > {
8137        PrivilegedPeripheralProxyInterface::r#listen_l2cap(self, payload)
8138    }
8139
8140    /// Start advertising continuously as a LE peripheral. If advertising cannot
8141    /// be initiated then `advertised_peripheral` will be closed and an error
8142    /// will be returned.
8143    ///
8144    /// This method may be called any number of times. To reconfigure an
8145    /// advertisement, first close the original advertisement and then initiate
8146    /// a new advertisement after an empty response is returned.
8147    ///
8148    /// If the client closes its end of the
8149    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
8150    /// advertising will be stopped. If the handle is closed before the request
8151    /// is fulfilled, advertising may be briefly enabled before it is
8152    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
8153    /// the Peripheral protocol, but this may be changed in the future
8154    /// (https://fxbug.dev/42157682).
8155    ///
8156    /// + request `parameters` Parameters used while configuring the advertising
8157    ///   instance.
8158    /// + request `advertised_peripheral` Protocol that remains valid for the
8159    ///   duration of this advertising session.
8160    /// - response An empty response will be sent when the advertisement is
8161    ///   successfully stopped (due to release of the `advertised_peripheral`
8162    ///   protocol). To prevent overlapping similar advertisements and transient
8163    ///   errors with limited advertising resources, waiting for a response is
8164    ///   recommended before calling `Advertise` again.
8165    /// * error If an error occurs, `advertised_peripheral` will be closed and a
8166    ///   `PeripheralError` will be returned.
8167    pub fn r#advertise(
8168        &self,
8169        mut parameters: &AdvertisingParameters,
8170        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8171    ) -> fidl::client::QueryResponseFut<
8172        PeripheralAdvertiseResult,
8173        fidl::encoding::DefaultFuchsiaResourceDialect,
8174    > {
8175        PrivilegedPeripheralProxyInterface::r#advertise(self, parameters, advertised_peripheral)
8176    }
8177
8178    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
8179    /// has successfully initiated. If advertising cannot be initiated, then the response will
8180    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
8181    ///
8182    /// This method can get called any number of times and successive calls can be made to
8183    /// reconfigure the advertising parameters. However only the most recent
8184    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
8185    ///
8186    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
8187    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
8188    /// advertisements.
8189    ///
8190    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
8191    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
8192    /// advertising will be briefly enabled before it is terminated.
8193    ///
8194    /// + request `parameters` Parameters used while configuring the advertising instance.
8195    /// + request `handle` Handle that remains valid for the duration of this advertising session.
8196    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
8197    ///         initiated. In this case the `handle` will be closed.
8198    pub fn r#start_advertising(
8199        &self,
8200        mut parameters: &AdvertisingParameters,
8201        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8202    ) -> fidl::client::QueryResponseFut<
8203        PeripheralStartAdvertisingResult,
8204        fidl::encoding::DefaultFuchsiaResourceDialect,
8205    > {
8206        PrivilegedPeripheralProxyInterface::r#start_advertising(self, parameters, handle)
8207    }
8208}
8209
8210impl PrivilegedPeripheralProxyInterface for PrivilegedPeripheralProxy {
8211    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
8212        ChannelListenerRegistryListenL2capResult,
8213        fidl::encoding::DefaultFuchsiaResourceDialect,
8214    >;
8215    fn r#listen_l2cap(
8216        &self,
8217        mut payload: ChannelListenerRegistryListenL2capRequest,
8218    ) -> Self::ListenL2capResponseFut {
8219        fn _decode(
8220            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8221        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
8222            let _response = fidl::client::decode_transaction_body::<
8223                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
8224                fidl::encoding::DefaultFuchsiaResourceDialect,
8225                0x39c6e9001d102338,
8226            >(_buf?)?;
8227            Ok(_response.map(|x| x))
8228        }
8229        self.client.send_query_and_decode::<
8230            ChannelListenerRegistryListenL2capRequest,
8231            ChannelListenerRegistryListenL2capResult,
8232        >(
8233            &mut payload,
8234            0x39c6e9001d102338,
8235            fidl::encoding::DynamicFlags::empty(),
8236            _decode,
8237        )
8238    }
8239
8240    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
8241        PeripheralAdvertiseResult,
8242        fidl::encoding::DefaultFuchsiaResourceDialect,
8243    >;
8244    fn r#advertise(
8245        &self,
8246        mut parameters: &AdvertisingParameters,
8247        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8248    ) -> Self::AdvertiseResponseFut {
8249        fn _decode(
8250            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8251        ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
8252            let _response = fidl::client::decode_transaction_body::<
8253                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8254                fidl::encoding::DefaultFuchsiaResourceDialect,
8255                0x2d9ec9260c32c17f,
8256            >(_buf?)?;
8257            Ok(_response.map(|x| x))
8258        }
8259        self.client.send_query_and_decode::<PeripheralAdvertiseRequest, PeripheralAdvertiseResult>(
8260            (parameters, advertised_peripheral),
8261            0x2d9ec9260c32c17f,
8262            fidl::encoding::DynamicFlags::empty(),
8263            _decode,
8264        )
8265    }
8266
8267    type StartAdvertisingResponseFut = fidl::client::QueryResponseFut<
8268        PeripheralStartAdvertisingResult,
8269        fidl::encoding::DefaultFuchsiaResourceDialect,
8270    >;
8271    fn r#start_advertising(
8272        &self,
8273        mut parameters: &AdvertisingParameters,
8274        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8275    ) -> Self::StartAdvertisingResponseFut {
8276        fn _decode(
8277            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8278        ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
8279            let _response = fidl::client::decode_transaction_body::<
8280                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
8281                fidl::encoding::DefaultFuchsiaResourceDialect,
8282                0x5875c1c575f00f7d,
8283            >(_buf?)?;
8284            Ok(_response.map(|x| x))
8285        }
8286        self.client.send_query_and_decode::<
8287            PeripheralStartAdvertisingRequest,
8288            PeripheralStartAdvertisingResult,
8289        >(
8290            (parameters, handle,),
8291            0x5875c1c575f00f7d,
8292            fidl::encoding::DynamicFlags::empty(),
8293            _decode,
8294        )
8295    }
8296}
8297
8298pub struct PrivilegedPeripheralEventStream {
8299    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8300}
8301
8302impl std::marker::Unpin for PrivilegedPeripheralEventStream {}
8303
8304impl futures::stream::FusedStream for PrivilegedPeripheralEventStream {
8305    fn is_terminated(&self) -> bool {
8306        self.event_receiver.is_terminated()
8307    }
8308}
8309
8310impl futures::Stream for PrivilegedPeripheralEventStream {
8311    type Item = Result<PrivilegedPeripheralEvent, fidl::Error>;
8312
8313    fn poll_next(
8314        mut self: std::pin::Pin<&mut Self>,
8315        cx: &mut std::task::Context<'_>,
8316    ) -> std::task::Poll<Option<Self::Item>> {
8317        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8318            &mut self.event_receiver,
8319            cx
8320        )?) {
8321            Some(buf) => std::task::Poll::Ready(Some(PrivilegedPeripheralEvent::decode(buf))),
8322            None => std::task::Poll::Ready(None),
8323        }
8324    }
8325}
8326
8327#[derive(Debug)]
8328pub enum PrivilegedPeripheralEvent {
8329    OnPeerConnected { peer: Peer, connection: fidl::endpoints::ClientEnd<ConnectionMarker> },
8330}
8331
8332impl PrivilegedPeripheralEvent {
8333    #[allow(irrefutable_let_patterns)]
8334    pub fn into_on_peer_connected(
8335        self,
8336    ) -> Option<(Peer, fidl::endpoints::ClientEnd<ConnectionMarker>)> {
8337        if let PrivilegedPeripheralEvent::OnPeerConnected { peer, connection } = self {
8338            Some((peer, connection))
8339        } else {
8340            None
8341        }
8342    }
8343
8344    /// Decodes a message buffer as a [`PrivilegedPeripheralEvent`].
8345    fn decode(
8346        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8347    ) -> Result<PrivilegedPeripheralEvent, fidl::Error> {
8348        let (bytes, _handles) = buf.split_mut();
8349        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8350        debug_assert_eq!(tx_header.tx_id, 0);
8351        match tx_header.ordinal {
8352            0x16135d464299e356 => {
8353                let mut out = fidl::new_empty!(
8354                    PeripheralOnPeerConnectedRequest,
8355                    fidl::encoding::DefaultFuchsiaResourceDialect
8356                );
8357                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralOnPeerConnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
8358                Ok((PrivilegedPeripheralEvent::OnPeerConnected {
8359                    peer: out.peer,
8360                    connection: out.connection,
8361                }))
8362            }
8363            _ => Err(fidl::Error::UnknownOrdinal {
8364                ordinal: tx_header.ordinal,
8365                protocol_name:
8366                    <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8367            }),
8368        }
8369    }
8370}
8371
8372/// A Stream of incoming requests for fuchsia.bluetooth.le/PrivilegedPeripheral.
8373pub struct PrivilegedPeripheralRequestStream {
8374    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8375    is_terminated: bool,
8376}
8377
8378impl std::marker::Unpin for PrivilegedPeripheralRequestStream {}
8379
8380impl futures::stream::FusedStream for PrivilegedPeripheralRequestStream {
8381    fn is_terminated(&self) -> bool {
8382        self.is_terminated
8383    }
8384}
8385
8386impl fidl::endpoints::RequestStream for PrivilegedPeripheralRequestStream {
8387    type Protocol = PrivilegedPeripheralMarker;
8388    type ControlHandle = PrivilegedPeripheralControlHandle;
8389
8390    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8391        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8392    }
8393
8394    fn control_handle(&self) -> Self::ControlHandle {
8395        PrivilegedPeripheralControlHandle { inner: self.inner.clone() }
8396    }
8397
8398    fn into_inner(
8399        self,
8400    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8401    {
8402        (self.inner, self.is_terminated)
8403    }
8404
8405    fn from_inner(
8406        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8407        is_terminated: bool,
8408    ) -> Self {
8409        Self { inner, is_terminated }
8410    }
8411}
8412
8413impl futures::Stream for PrivilegedPeripheralRequestStream {
8414    type Item = Result<PrivilegedPeripheralRequest, fidl::Error>;
8415
8416    fn poll_next(
8417        mut self: std::pin::Pin<&mut Self>,
8418        cx: &mut std::task::Context<'_>,
8419    ) -> std::task::Poll<Option<Self::Item>> {
8420        let this = &mut *self;
8421        if this.inner.check_shutdown(cx) {
8422            this.is_terminated = true;
8423            return std::task::Poll::Ready(None);
8424        }
8425        if this.is_terminated {
8426            panic!("polled PrivilegedPeripheralRequestStream after completion");
8427        }
8428        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8429            |bytes, handles| {
8430                match this.inner.channel().read_etc(cx, bytes, handles) {
8431                    std::task::Poll::Ready(Ok(())) => {}
8432                    std::task::Poll::Pending => return std::task::Poll::Pending,
8433                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8434                        this.is_terminated = true;
8435                        return std::task::Poll::Ready(None);
8436                    }
8437                    std::task::Poll::Ready(Err(e)) => {
8438                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8439                            e.into(),
8440                        ))))
8441                    }
8442                }
8443
8444                // A message has been received from the channel
8445                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8446
8447                std::task::Poll::Ready(Some(match header.ordinal {
8448                0x39c6e9001d102338 => {
8449                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8450                    let mut req = fidl::new_empty!(ChannelListenerRegistryListenL2capRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8451                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
8452                    let control_handle = PrivilegedPeripheralControlHandle {
8453                        inner: this.inner.clone(),
8454                    };
8455                    Ok(PrivilegedPeripheralRequest::ListenL2cap {payload: req,
8456                        responder: PrivilegedPeripheralListenL2capResponder {
8457                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8458                            tx_id: header.tx_id,
8459                        },
8460                    })
8461                }
8462                0x2d9ec9260c32c17f => {
8463                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8464                    let mut req = fidl::new_empty!(PeripheralAdvertiseRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8465                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
8466                    let control_handle = PrivilegedPeripheralControlHandle {
8467                        inner: this.inner.clone(),
8468                    };
8469                    Ok(PrivilegedPeripheralRequest::Advertise {parameters: req.parameters,
8470advertised_peripheral: req.advertised_peripheral,
8471
8472                        responder: PrivilegedPeripheralAdvertiseResponder {
8473                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8474                            tx_id: header.tx_id,
8475                        },
8476                    })
8477                }
8478                0x5875c1c575f00f7d => {
8479                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8480                    let mut req = fidl::new_empty!(PeripheralStartAdvertisingRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8481                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralStartAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
8482                    let control_handle = PrivilegedPeripheralControlHandle {
8483                        inner: this.inner.clone(),
8484                    };
8485                    Ok(PrivilegedPeripheralRequest::StartAdvertising {parameters: req.parameters,
8486handle: req.handle,
8487
8488                        responder: PrivilegedPeripheralStartAdvertisingResponder {
8489                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8490                            tx_id: header.tx_id,
8491                        },
8492                    })
8493                }
8494                _ => Err(fidl::Error::UnknownOrdinal {
8495                    ordinal: header.ordinal,
8496                    protocol_name: <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8497                }),
8498            }))
8499            },
8500        )
8501    }
8502}
8503
8504/// Privileged version of the Peripheral protocol.
8505/// This protocol should only be routed to trusted and system components. Using this protocol will
8506/// enable the client to break normal privacy restrictions which could leak information about the
8507/// location or owner of the device.
8508///
8509/// Use cases which reveal information are noted in documentation and marked as only available
8510/// through PrivilegedPeripheral, and are an error if used through Peripheral.
8511#[derive(Debug)]
8512pub enum PrivilegedPeripheralRequest {
8513    /// Register a listener for incoming channels. The registry will assign a
8514    /// PSM value that is unique for the local device, as well as open a
8515    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
8516    /// event that all PSMs have been assigned, this call will fail with
8517    /// `ZX_ERR_NO_RESOURCES`.
8518    ///
8519    /// Note that the method of service discovery or advertising is defined by
8520    /// the service or protocol, so it is the responsibility of the caller to
8521    /// communicate the assigned PSM to any clients.
8522    ListenL2cap {
8523        payload: ChannelListenerRegistryListenL2capRequest,
8524        responder: PrivilegedPeripheralListenL2capResponder,
8525    },
8526    /// Start advertising continuously as a LE peripheral. If advertising cannot
8527    /// be initiated then `advertised_peripheral` will be closed and an error
8528    /// will be returned.
8529    ///
8530    /// This method may be called any number of times. To reconfigure an
8531    /// advertisement, first close the original advertisement and then initiate
8532    /// a new advertisement after an empty response is returned.
8533    ///
8534    /// If the client closes its end of the
8535    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
8536    /// advertising will be stopped. If the handle is closed before the request
8537    /// is fulfilled, advertising may be briefly enabled before it is
8538    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
8539    /// the Peripheral protocol, but this may be changed in the future
8540    /// (https://fxbug.dev/42157682).
8541    ///
8542    /// + request `parameters` Parameters used while configuring the advertising
8543    ///   instance.
8544    /// + request `advertised_peripheral` Protocol that remains valid for the
8545    ///   duration of this advertising session.
8546    /// - response An empty response will be sent when the advertisement is
8547    ///   successfully stopped (due to release of the `advertised_peripheral`
8548    ///   protocol). To prevent overlapping similar advertisements and transient
8549    ///   errors with limited advertising resources, waiting for a response is
8550    ///   recommended before calling `Advertise` again.
8551    /// * error If an error occurs, `advertised_peripheral` will be closed and a
8552    ///   `PeripheralError` will be returned.
8553    Advertise {
8554        parameters: AdvertisingParameters,
8555        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8556        responder: PrivilegedPeripheralAdvertiseResponder,
8557    },
8558    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
8559    /// has successfully initiated. If advertising cannot be initiated, then the response will
8560    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
8561    ///
8562    /// This method can get called any number of times and successive calls can be made to
8563    /// reconfigure the advertising parameters. However only the most recent
8564    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
8565    ///
8566    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
8567    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
8568    /// advertisements.
8569    ///
8570    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
8571    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
8572    /// advertising will be briefly enabled before it is terminated.
8573    ///
8574    /// + request `parameters` Parameters used while configuring the advertising instance.
8575    /// + request `handle` Handle that remains valid for the duration of this advertising session.
8576    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
8577    ///         initiated. In this case the `handle` will be closed.
8578    StartAdvertising {
8579        parameters: AdvertisingParameters,
8580        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8581        responder: PrivilegedPeripheralStartAdvertisingResponder,
8582    },
8583}
8584
8585impl PrivilegedPeripheralRequest {
8586    #[allow(irrefutable_let_patterns)]
8587    pub fn into_listen_l2cap(
8588        self,
8589    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PrivilegedPeripheralListenL2capResponder)>
8590    {
8591        if let PrivilegedPeripheralRequest::ListenL2cap { payload, responder } = self {
8592            Some((payload, responder))
8593        } else {
8594            None
8595        }
8596    }
8597
8598    #[allow(irrefutable_let_patterns)]
8599    pub fn into_advertise(
8600        self,
8601    ) -> Option<(
8602        AdvertisingParameters,
8603        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8604        PrivilegedPeripheralAdvertiseResponder,
8605    )> {
8606        if let PrivilegedPeripheralRequest::Advertise {
8607            parameters,
8608            advertised_peripheral,
8609            responder,
8610        } = self
8611        {
8612            Some((parameters, advertised_peripheral, responder))
8613        } else {
8614            None
8615        }
8616    }
8617
8618    #[allow(irrefutable_let_patterns)]
8619    pub fn into_start_advertising(
8620        self,
8621    ) -> Option<(
8622        AdvertisingParameters,
8623        fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8624        PrivilegedPeripheralStartAdvertisingResponder,
8625    )> {
8626        if let PrivilegedPeripheralRequest::StartAdvertising { parameters, handle, responder } =
8627            self
8628        {
8629            Some((parameters, handle, responder))
8630        } else {
8631            None
8632        }
8633    }
8634
8635    /// Name of the method defined in FIDL
8636    pub fn method_name(&self) -> &'static str {
8637        match *self {
8638            PrivilegedPeripheralRequest::ListenL2cap { .. } => "listen_l2cap",
8639            PrivilegedPeripheralRequest::Advertise { .. } => "advertise",
8640            PrivilegedPeripheralRequest::StartAdvertising { .. } => "start_advertising",
8641        }
8642    }
8643}
8644
8645#[derive(Debug, Clone)]
8646pub struct PrivilegedPeripheralControlHandle {
8647    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8648}
8649
8650impl fidl::endpoints::ControlHandle for PrivilegedPeripheralControlHandle {
8651    fn shutdown(&self) {
8652        self.inner.shutdown()
8653    }
8654    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8655        self.inner.shutdown_with_epitaph(status)
8656    }
8657
8658    fn is_closed(&self) -> bool {
8659        self.inner.channel().is_closed()
8660    }
8661    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8662        self.inner.channel().on_closed()
8663    }
8664
8665    #[cfg(target_os = "fuchsia")]
8666    fn signal_peer(
8667        &self,
8668        clear_mask: zx::Signals,
8669        set_mask: zx::Signals,
8670    ) -> Result<(), zx_status::Status> {
8671        use fidl::Peered;
8672        self.inner.channel().signal_peer(clear_mask, set_mask)
8673    }
8674}
8675
8676impl PrivilegedPeripheralControlHandle {
8677    pub fn send_on_peer_connected(
8678        &self,
8679        mut peer: &Peer,
8680        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
8681    ) -> Result<(), fidl::Error> {
8682        self.inner.send::<PeripheralOnPeerConnectedRequest>(
8683            (peer, connection),
8684            0,
8685            0x16135d464299e356,
8686            fidl::encoding::DynamicFlags::empty(),
8687        )
8688    }
8689}
8690
8691#[must_use = "FIDL methods require a response to be sent"]
8692#[derive(Debug)]
8693pub struct PrivilegedPeripheralListenL2capResponder {
8694    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
8695    tx_id: u32,
8696}
8697
8698/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
8699/// if the responder is dropped without sending a response, so that the client
8700/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8701impl std::ops::Drop for PrivilegedPeripheralListenL2capResponder {
8702    fn drop(&mut self) {
8703        self.control_handle.shutdown();
8704        // Safety: drops once, never accessed again
8705        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8706    }
8707}
8708
8709impl fidl::endpoints::Responder for PrivilegedPeripheralListenL2capResponder {
8710    type ControlHandle = PrivilegedPeripheralControlHandle;
8711
8712    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
8713        &self.control_handle
8714    }
8715
8716    fn drop_without_shutdown(mut self) {
8717        // Safety: drops once, never accessed again due to mem::forget
8718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8719        // Prevent Drop from running (which would shut down the channel)
8720        std::mem::forget(self);
8721    }
8722}
8723
8724impl PrivilegedPeripheralListenL2capResponder {
8725    /// Sends a response to the FIDL transaction.
8726    ///
8727    /// Sets the channel to shutdown if an error occurs.
8728    pub fn send(
8729        self,
8730        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
8731    ) -> Result<(), fidl::Error> {
8732        let _result = self.send_raw(result);
8733        if _result.is_err() {
8734            self.control_handle.shutdown();
8735        }
8736        self.drop_without_shutdown();
8737        _result
8738    }
8739
8740    /// Similar to "send" but does not shutdown the channel if an error occurs.
8741    pub fn send_no_shutdown_on_err(
8742        self,
8743        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
8744    ) -> Result<(), fidl::Error> {
8745        let _result = self.send_raw(result);
8746        self.drop_without_shutdown();
8747        _result
8748    }
8749
8750    fn send_raw(
8751        &self,
8752        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
8753    ) -> Result<(), fidl::Error> {
8754        self.control_handle.inner.send::<fidl::encoding::ResultType<
8755            ChannelListenerRegistryListenL2capResponse,
8756            i32,
8757        >>(
8758            result,
8759            self.tx_id,
8760            0x39c6e9001d102338,
8761            fidl::encoding::DynamicFlags::empty(),
8762        )
8763    }
8764}
8765
8766#[must_use = "FIDL methods require a response to be sent"]
8767#[derive(Debug)]
8768pub struct PrivilegedPeripheralAdvertiseResponder {
8769    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
8770    tx_id: u32,
8771}
8772
8773/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
8774/// if the responder is dropped without sending a response, so that the client
8775/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8776impl std::ops::Drop for PrivilegedPeripheralAdvertiseResponder {
8777    fn drop(&mut self) {
8778        self.control_handle.shutdown();
8779        // Safety: drops once, never accessed again
8780        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8781    }
8782}
8783
8784impl fidl::endpoints::Responder for PrivilegedPeripheralAdvertiseResponder {
8785    type ControlHandle = PrivilegedPeripheralControlHandle;
8786
8787    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
8788        &self.control_handle
8789    }
8790
8791    fn drop_without_shutdown(mut self) {
8792        // Safety: drops once, never accessed again due to mem::forget
8793        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8794        // Prevent Drop from running (which would shut down the channel)
8795        std::mem::forget(self);
8796    }
8797}
8798
8799impl PrivilegedPeripheralAdvertiseResponder {
8800    /// Sends a response to the FIDL transaction.
8801    ///
8802    /// Sets the channel to shutdown if an error occurs.
8803    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
8804        let _result = self.send_raw(result);
8805        if _result.is_err() {
8806            self.control_handle.shutdown();
8807        }
8808        self.drop_without_shutdown();
8809        _result
8810    }
8811
8812    /// Similar to "send" but does not shutdown the channel if an error occurs.
8813    pub fn send_no_shutdown_on_err(
8814        self,
8815        mut result: Result<(), PeripheralError>,
8816    ) -> Result<(), fidl::Error> {
8817        let _result = self.send_raw(result);
8818        self.drop_without_shutdown();
8819        _result
8820    }
8821
8822    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
8823        self.control_handle.inner.send::<fidl::encoding::ResultType<
8824            fidl::encoding::EmptyStruct,
8825            PeripheralError,
8826        >>(
8827            result,
8828            self.tx_id,
8829            0x2d9ec9260c32c17f,
8830            fidl::encoding::DynamicFlags::empty(),
8831        )
8832    }
8833}
8834
8835#[must_use = "FIDL methods require a response to be sent"]
8836#[derive(Debug)]
8837pub struct PrivilegedPeripheralStartAdvertisingResponder {
8838    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
8839    tx_id: u32,
8840}
8841
8842/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
8843/// if the responder is dropped without sending a response, so that the client
8844/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8845impl std::ops::Drop for PrivilegedPeripheralStartAdvertisingResponder {
8846    fn drop(&mut self) {
8847        self.control_handle.shutdown();
8848        // Safety: drops once, never accessed again
8849        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8850    }
8851}
8852
8853impl fidl::endpoints::Responder for PrivilegedPeripheralStartAdvertisingResponder {
8854    type ControlHandle = PrivilegedPeripheralControlHandle;
8855
8856    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
8857        &self.control_handle
8858    }
8859
8860    fn drop_without_shutdown(mut self) {
8861        // Safety: drops once, never accessed again due to mem::forget
8862        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8863        // Prevent Drop from running (which would shut down the channel)
8864        std::mem::forget(self);
8865    }
8866}
8867
8868impl PrivilegedPeripheralStartAdvertisingResponder {
8869    /// Sends a response to the FIDL transaction.
8870    ///
8871    /// Sets the channel to shutdown if an error occurs.
8872    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
8873        let _result = self.send_raw(result);
8874        if _result.is_err() {
8875            self.control_handle.shutdown();
8876        }
8877        self.drop_without_shutdown();
8878        _result
8879    }
8880
8881    /// Similar to "send" but does not shutdown the channel if an error occurs.
8882    pub fn send_no_shutdown_on_err(
8883        self,
8884        mut result: Result<(), PeripheralError>,
8885    ) -> Result<(), fidl::Error> {
8886        let _result = self.send_raw(result);
8887        self.drop_without_shutdown();
8888        _result
8889    }
8890
8891    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
8892        self.control_handle.inner.send::<fidl::encoding::ResultType<
8893            fidl::encoding::EmptyStruct,
8894            PeripheralError,
8895        >>(
8896            result,
8897            self.tx_id,
8898            0x5875c1c575f00f7d,
8899            fidl::encoding::DynamicFlags::empty(),
8900        )
8901    }
8902}
8903
8904#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8905pub struct ScanResultWatcherMarker;
8906
8907impl fidl::endpoints::ProtocolMarker for ScanResultWatcherMarker {
8908    type Proxy = ScanResultWatcherProxy;
8909    type RequestStream = ScanResultWatcherRequestStream;
8910    #[cfg(target_os = "fuchsia")]
8911    type SynchronousProxy = ScanResultWatcherSynchronousProxy;
8912
8913    const DEBUG_NAME: &'static str = "(anonymous) ScanResultWatcher";
8914}
8915
8916pub trait ScanResultWatcherProxyInterface: Send + Sync {
8917    type WatchResponseFut: std::future::Future<Output = Result<Vec<Peer>, fidl::Error>> + Send;
8918    fn r#watch(&self) -> Self::WatchResponseFut;
8919}
8920#[derive(Debug)]
8921#[cfg(target_os = "fuchsia")]
8922pub struct ScanResultWatcherSynchronousProxy {
8923    client: fidl::client::sync::Client,
8924}
8925
8926#[cfg(target_os = "fuchsia")]
8927impl fidl::endpoints::SynchronousProxy for ScanResultWatcherSynchronousProxy {
8928    type Proxy = ScanResultWatcherProxy;
8929    type Protocol = ScanResultWatcherMarker;
8930
8931    fn from_channel(inner: fidl::Channel) -> Self {
8932        Self::new(inner)
8933    }
8934
8935    fn into_channel(self) -> fidl::Channel {
8936        self.client.into_channel()
8937    }
8938
8939    fn as_channel(&self) -> &fidl::Channel {
8940        self.client.as_channel()
8941    }
8942}
8943
8944#[cfg(target_os = "fuchsia")]
8945impl ScanResultWatcherSynchronousProxy {
8946    pub fn new(channel: fidl::Channel) -> Self {
8947        let protocol_name =
8948            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8949        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8950    }
8951
8952    pub fn into_channel(self) -> fidl::Channel {
8953        self.client.into_channel()
8954    }
8955
8956    /// Waits until an event arrives and returns it. It is safe for other
8957    /// threads to make concurrent requests while waiting for an event.
8958    pub fn wait_for_event(
8959        &self,
8960        deadline: zx::MonotonicInstant,
8961    ) -> Result<ScanResultWatcherEvent, fidl::Error> {
8962        ScanResultWatcherEvent::decode(self.client.wait_for_event(deadline)?)
8963    }
8964
8965    /// Returns a list of all LE peers that satisfy the filters indicated in
8966    /// `ScanOptions`. The first response(s) will return matching discovered
8967    /// peers immediately. Subsequent calls receive a response only when peers
8968    /// have been scanned or updated since the last call. If a second call to
8969    /// `Watch` is erronously sent while one call is already pending, the scan
8970    /// will be canceled and the protocol will be closed.
8971    ///
8972    /// - response `updated` Peers that were added or updated since the last
8973    ///   call to Watch().
8974    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<Peer>, fidl::Error> {
8975        let _response = self
8976            .client
8977            .send_query::<fidl::encoding::EmptyPayload, ScanResultWatcherWatchResponse>(
8978                (),
8979                0x713a122e949f301a,
8980                fidl::encoding::DynamicFlags::empty(),
8981                ___deadline,
8982            )?;
8983        Ok(_response.updated)
8984    }
8985}
8986
8987#[cfg(target_os = "fuchsia")]
8988impl From<ScanResultWatcherSynchronousProxy> for zx::Handle {
8989    fn from(value: ScanResultWatcherSynchronousProxy) -> Self {
8990        value.into_channel().into()
8991    }
8992}
8993
8994#[cfg(target_os = "fuchsia")]
8995impl From<fidl::Channel> for ScanResultWatcherSynchronousProxy {
8996    fn from(value: fidl::Channel) -> Self {
8997        Self::new(value)
8998    }
8999}
9000
9001#[cfg(target_os = "fuchsia")]
9002impl fidl::endpoints::FromClient for ScanResultWatcherSynchronousProxy {
9003    type Protocol = ScanResultWatcherMarker;
9004
9005    fn from_client(value: fidl::endpoints::ClientEnd<ScanResultWatcherMarker>) -> Self {
9006        Self::new(value.into_channel())
9007    }
9008}
9009
9010#[derive(Debug, Clone)]
9011pub struct ScanResultWatcherProxy {
9012    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
9013}
9014
9015impl fidl::endpoints::Proxy for ScanResultWatcherProxy {
9016    type Protocol = ScanResultWatcherMarker;
9017
9018    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
9019        Self::new(inner)
9020    }
9021
9022    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
9023        self.client.into_channel().map_err(|client| Self { client })
9024    }
9025
9026    fn as_channel(&self) -> &::fidl::AsyncChannel {
9027        self.client.as_channel()
9028    }
9029}
9030
9031impl ScanResultWatcherProxy {
9032    /// Create a new Proxy for fuchsia.bluetooth.le/ScanResultWatcher.
9033    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
9034        let protocol_name =
9035            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9036        Self { client: fidl::client::Client::new(channel, protocol_name) }
9037    }
9038
9039    /// Get a Stream of events from the remote end of the protocol.
9040    ///
9041    /// # Panics
9042    ///
9043    /// Panics if the event stream was already taken.
9044    pub fn take_event_stream(&self) -> ScanResultWatcherEventStream {
9045        ScanResultWatcherEventStream { event_receiver: self.client.take_event_receiver() }
9046    }
9047
9048    /// Returns a list of all LE peers that satisfy the filters indicated in
9049    /// `ScanOptions`. The first response(s) will return matching discovered
9050    /// peers immediately. Subsequent calls receive a response only when peers
9051    /// have been scanned or updated since the last call. If a second call to
9052    /// `Watch` is erronously sent while one call is already pending, the scan
9053    /// will be canceled and the protocol will be closed.
9054    ///
9055    /// - response `updated` Peers that were added or updated since the last
9056    ///   call to Watch().
9057    pub fn r#watch(
9058        &self,
9059    ) -> fidl::client::QueryResponseFut<Vec<Peer>, fidl::encoding::DefaultFuchsiaResourceDialect>
9060    {
9061        ScanResultWatcherProxyInterface::r#watch(self)
9062    }
9063}
9064
9065impl ScanResultWatcherProxyInterface for ScanResultWatcherProxy {
9066    type WatchResponseFut =
9067        fidl::client::QueryResponseFut<Vec<Peer>, fidl::encoding::DefaultFuchsiaResourceDialect>;
9068    fn r#watch(&self) -> Self::WatchResponseFut {
9069        fn _decode(
9070            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9071        ) -> Result<Vec<Peer>, fidl::Error> {
9072            let _response = fidl::client::decode_transaction_body::<
9073                ScanResultWatcherWatchResponse,
9074                fidl::encoding::DefaultFuchsiaResourceDialect,
9075                0x713a122e949f301a,
9076            >(_buf?)?;
9077            Ok(_response.updated)
9078        }
9079        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Peer>>(
9080            (),
9081            0x713a122e949f301a,
9082            fidl::encoding::DynamicFlags::empty(),
9083            _decode,
9084        )
9085    }
9086}
9087
9088pub struct ScanResultWatcherEventStream {
9089    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9090}
9091
9092impl std::marker::Unpin for ScanResultWatcherEventStream {}
9093
9094impl futures::stream::FusedStream for ScanResultWatcherEventStream {
9095    fn is_terminated(&self) -> bool {
9096        self.event_receiver.is_terminated()
9097    }
9098}
9099
9100impl futures::Stream for ScanResultWatcherEventStream {
9101    type Item = Result<ScanResultWatcherEvent, fidl::Error>;
9102
9103    fn poll_next(
9104        mut self: std::pin::Pin<&mut Self>,
9105        cx: &mut std::task::Context<'_>,
9106    ) -> std::task::Poll<Option<Self::Item>> {
9107        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9108            &mut self.event_receiver,
9109            cx
9110        )?) {
9111            Some(buf) => std::task::Poll::Ready(Some(ScanResultWatcherEvent::decode(buf))),
9112            None => std::task::Poll::Ready(None),
9113        }
9114    }
9115}
9116
9117#[derive(Debug)]
9118pub enum ScanResultWatcherEvent {}
9119
9120impl ScanResultWatcherEvent {
9121    /// Decodes a message buffer as a [`ScanResultWatcherEvent`].
9122    fn decode(
9123        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9124    ) -> Result<ScanResultWatcherEvent, fidl::Error> {
9125        let (bytes, _handles) = buf.split_mut();
9126        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9127        debug_assert_eq!(tx_header.tx_id, 0);
9128        match tx_header.ordinal {
9129            _ => Err(fidl::Error::UnknownOrdinal {
9130                ordinal: tx_header.ordinal,
9131                protocol_name:
9132                    <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9133            }),
9134        }
9135    }
9136}
9137
9138/// A Stream of incoming requests for fuchsia.bluetooth.le/ScanResultWatcher.
9139pub struct ScanResultWatcherRequestStream {
9140    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9141    is_terminated: bool,
9142}
9143
9144impl std::marker::Unpin for ScanResultWatcherRequestStream {}
9145
9146impl futures::stream::FusedStream for ScanResultWatcherRequestStream {
9147    fn is_terminated(&self) -> bool {
9148        self.is_terminated
9149    }
9150}
9151
9152impl fidl::endpoints::RequestStream for ScanResultWatcherRequestStream {
9153    type Protocol = ScanResultWatcherMarker;
9154    type ControlHandle = ScanResultWatcherControlHandle;
9155
9156    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9157        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9158    }
9159
9160    fn control_handle(&self) -> Self::ControlHandle {
9161        ScanResultWatcherControlHandle { inner: self.inner.clone() }
9162    }
9163
9164    fn into_inner(
9165        self,
9166    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9167    {
9168        (self.inner, self.is_terminated)
9169    }
9170
9171    fn from_inner(
9172        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9173        is_terminated: bool,
9174    ) -> Self {
9175        Self { inner, is_terminated }
9176    }
9177}
9178
9179impl futures::Stream for ScanResultWatcherRequestStream {
9180    type Item = Result<ScanResultWatcherRequest, fidl::Error>;
9181
9182    fn poll_next(
9183        mut self: std::pin::Pin<&mut Self>,
9184        cx: &mut std::task::Context<'_>,
9185    ) -> std::task::Poll<Option<Self::Item>> {
9186        let this = &mut *self;
9187        if this.inner.check_shutdown(cx) {
9188            this.is_terminated = true;
9189            return std::task::Poll::Ready(None);
9190        }
9191        if this.is_terminated {
9192            panic!("polled ScanResultWatcherRequestStream after completion");
9193        }
9194        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9195            |bytes, handles| {
9196                match this.inner.channel().read_etc(cx, bytes, handles) {
9197                    std::task::Poll::Ready(Ok(())) => {}
9198                    std::task::Poll::Pending => return std::task::Poll::Pending,
9199                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9200                        this.is_terminated = true;
9201                        return std::task::Poll::Ready(None);
9202                    }
9203                    std::task::Poll::Ready(Err(e)) => {
9204                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9205                            e.into(),
9206                        ))))
9207                    }
9208                }
9209
9210                // A message has been received from the channel
9211                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9212
9213                std::task::Poll::Ready(Some(match header.ordinal {
9214                    0x713a122e949f301a => {
9215                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9216                        let mut req = fidl::new_empty!(
9217                            fidl::encoding::EmptyPayload,
9218                            fidl::encoding::DefaultFuchsiaResourceDialect
9219                        );
9220                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9221                        let control_handle =
9222                            ScanResultWatcherControlHandle { inner: this.inner.clone() };
9223                        Ok(ScanResultWatcherRequest::Watch {
9224                            responder: ScanResultWatcherWatchResponder {
9225                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9226                                tx_id: header.tx_id,
9227                            },
9228                        })
9229                    }
9230                    _ => Err(fidl::Error::UnknownOrdinal {
9231                        ordinal: header.ordinal,
9232                        protocol_name:
9233                            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9234                    }),
9235                }))
9236            },
9237        )
9238    }
9239}
9240
9241/// Represents an active scan procedure. This protocol remains valid for the
9242/// duration of a scan and can be used to obtain scan results. The client can
9243/// close the protocol to stop scanning. If a scan is stopped by the system, the
9244/// protocol will be closed with the epitaph `CANCELED` to communicate this to
9245/// the client.
9246#[derive(Debug)]
9247pub enum ScanResultWatcherRequest {
9248    /// Returns a list of all LE peers that satisfy the filters indicated in
9249    /// `ScanOptions`. The first response(s) will return matching discovered
9250    /// peers immediately. Subsequent calls receive a response only when peers
9251    /// have been scanned or updated since the last call. If a second call to
9252    /// `Watch` is erronously sent while one call is already pending, the scan
9253    /// will be canceled and the protocol will be closed.
9254    ///
9255    /// - response `updated` Peers that were added or updated since the last
9256    ///   call to Watch().
9257    Watch { responder: ScanResultWatcherWatchResponder },
9258}
9259
9260impl ScanResultWatcherRequest {
9261    #[allow(irrefutable_let_patterns)]
9262    pub fn into_watch(self) -> Option<(ScanResultWatcherWatchResponder)> {
9263        if let ScanResultWatcherRequest::Watch { responder } = self {
9264            Some((responder))
9265        } else {
9266            None
9267        }
9268    }
9269
9270    /// Name of the method defined in FIDL
9271    pub fn method_name(&self) -> &'static str {
9272        match *self {
9273            ScanResultWatcherRequest::Watch { .. } => "watch",
9274        }
9275    }
9276}
9277
9278#[derive(Debug, Clone)]
9279pub struct ScanResultWatcherControlHandle {
9280    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9281}
9282
9283impl fidl::endpoints::ControlHandle for ScanResultWatcherControlHandle {
9284    fn shutdown(&self) {
9285        self.inner.shutdown()
9286    }
9287    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9288        self.inner.shutdown_with_epitaph(status)
9289    }
9290
9291    fn is_closed(&self) -> bool {
9292        self.inner.channel().is_closed()
9293    }
9294    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
9295        self.inner.channel().on_closed()
9296    }
9297
9298    #[cfg(target_os = "fuchsia")]
9299    fn signal_peer(
9300        &self,
9301        clear_mask: zx::Signals,
9302        set_mask: zx::Signals,
9303    ) -> Result<(), zx_status::Status> {
9304        use fidl::Peered;
9305        self.inner.channel().signal_peer(clear_mask, set_mask)
9306    }
9307}
9308
9309impl ScanResultWatcherControlHandle {}
9310
9311#[must_use = "FIDL methods require a response to be sent"]
9312#[derive(Debug)]
9313pub struct ScanResultWatcherWatchResponder {
9314    control_handle: std::mem::ManuallyDrop<ScanResultWatcherControlHandle>,
9315    tx_id: u32,
9316}
9317
9318/// Set the the channel to be shutdown (see [`ScanResultWatcherControlHandle::shutdown`])
9319/// if the responder is dropped without sending a response, so that the client
9320/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9321impl std::ops::Drop for ScanResultWatcherWatchResponder {
9322    fn drop(&mut self) {
9323        self.control_handle.shutdown();
9324        // Safety: drops once, never accessed again
9325        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9326    }
9327}
9328
9329impl fidl::endpoints::Responder for ScanResultWatcherWatchResponder {
9330    type ControlHandle = ScanResultWatcherControlHandle;
9331
9332    fn control_handle(&self) -> &ScanResultWatcherControlHandle {
9333        &self.control_handle
9334    }
9335
9336    fn drop_without_shutdown(mut self) {
9337        // Safety: drops once, never accessed again due to mem::forget
9338        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9339        // Prevent Drop from running (which would shut down the channel)
9340        std::mem::forget(self);
9341    }
9342}
9343
9344impl ScanResultWatcherWatchResponder {
9345    /// Sends a response to the FIDL transaction.
9346    ///
9347    /// Sets the channel to shutdown if an error occurs.
9348    pub fn send(self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
9349        let _result = self.send_raw(updated);
9350        if _result.is_err() {
9351            self.control_handle.shutdown();
9352        }
9353        self.drop_without_shutdown();
9354        _result
9355    }
9356
9357    /// Similar to "send" but does not shutdown the channel if an error occurs.
9358    pub fn send_no_shutdown_on_err(self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
9359        let _result = self.send_raw(updated);
9360        self.drop_without_shutdown();
9361        _result
9362    }
9363
9364    fn send_raw(&self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
9365        self.control_handle.inner.send::<ScanResultWatcherWatchResponse>(
9366            (updated,),
9367            self.tx_id,
9368            0x713a122e949f301a,
9369            fidl::encoding::DynamicFlags::empty(),
9370        )
9371    }
9372}
9373
9374mod internal {
9375    use super::*;
9376
9377    impl fidl::encoding::ResourceTypeMarker for AdvertisedPeripheralOnConnectedRequest {
9378        type Borrowed<'a> = &'a mut Self;
9379        fn take_or_borrow<'a>(
9380            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9381        ) -> Self::Borrowed<'a> {
9382            value
9383        }
9384    }
9385
9386    unsafe impl fidl::encoding::TypeMarker for AdvertisedPeripheralOnConnectedRequest {
9387        type Owned = Self;
9388
9389        #[inline(always)]
9390        fn inline_align(_context: fidl::encoding::Context) -> usize {
9391            8
9392        }
9393
9394        #[inline(always)]
9395        fn inline_size(_context: fidl::encoding::Context) -> usize {
9396            24
9397        }
9398    }
9399
9400    unsafe impl
9401        fidl::encoding::Encode<
9402            AdvertisedPeripheralOnConnectedRequest,
9403            fidl::encoding::DefaultFuchsiaResourceDialect,
9404        > for &mut AdvertisedPeripheralOnConnectedRequest
9405    {
9406        #[inline]
9407        unsafe fn encode(
9408            self,
9409            encoder: &mut fidl::encoding::Encoder<
9410                '_,
9411                fidl::encoding::DefaultFuchsiaResourceDialect,
9412            >,
9413            offset: usize,
9414            _depth: fidl::encoding::Depth,
9415        ) -> fidl::Result<()> {
9416            encoder.debug_check_bounds::<AdvertisedPeripheralOnConnectedRequest>(offset);
9417            // Delegate to tuple encoding.
9418            fidl::encoding::Encode::<AdvertisedPeripheralOnConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9419                (
9420                    <Peer as fidl::encoding::ValueTypeMarker>::borrow(&self.peer),
9421                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.connection),
9422                ),
9423                encoder, offset, _depth
9424            )
9425        }
9426    }
9427    unsafe impl<
9428            T0: fidl::encoding::Encode<Peer, fidl::encoding::DefaultFuchsiaResourceDialect>,
9429            T1: fidl::encoding::Encode<
9430                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
9431                fidl::encoding::DefaultFuchsiaResourceDialect,
9432            >,
9433        >
9434        fidl::encoding::Encode<
9435            AdvertisedPeripheralOnConnectedRequest,
9436            fidl::encoding::DefaultFuchsiaResourceDialect,
9437        > for (T0, T1)
9438    {
9439        #[inline]
9440        unsafe fn encode(
9441            self,
9442            encoder: &mut fidl::encoding::Encoder<
9443                '_,
9444                fidl::encoding::DefaultFuchsiaResourceDialect,
9445            >,
9446            offset: usize,
9447            depth: fidl::encoding::Depth,
9448        ) -> fidl::Result<()> {
9449            encoder.debug_check_bounds::<AdvertisedPeripheralOnConnectedRequest>(offset);
9450            // Zero out padding regions. There's no need to apply masks
9451            // because the unmasked parts will be overwritten by fields.
9452            unsafe {
9453                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
9454                (ptr as *mut u64).write_unaligned(0);
9455            }
9456            // Write the fields.
9457            self.0.encode(encoder, offset + 0, depth)?;
9458            self.1.encode(encoder, offset + 16, depth)?;
9459            Ok(())
9460        }
9461    }
9462
9463    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9464        for AdvertisedPeripheralOnConnectedRequest
9465    {
9466        #[inline(always)]
9467        fn new_empty() -> Self {
9468            Self {
9469                peer: fidl::new_empty!(Peer, fidl::encoding::DefaultFuchsiaResourceDialect),
9470                connection: fidl::new_empty!(
9471                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
9472                    fidl::encoding::DefaultFuchsiaResourceDialect
9473                ),
9474            }
9475        }
9476
9477        #[inline]
9478        unsafe fn decode(
9479            &mut self,
9480            decoder: &mut fidl::encoding::Decoder<
9481                '_,
9482                fidl::encoding::DefaultFuchsiaResourceDialect,
9483            >,
9484            offset: usize,
9485            _depth: fidl::encoding::Depth,
9486        ) -> fidl::Result<()> {
9487            decoder.debug_check_bounds::<Self>(offset);
9488            // Verify that padding bytes are zero.
9489            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
9490            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9491            let mask = 0xffffffff00000000u64;
9492            let maskedval = padval & mask;
9493            if maskedval != 0 {
9494                return Err(fidl::Error::NonZeroPadding {
9495                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
9496                });
9497            }
9498            fidl::decode!(
9499                Peer,
9500                fidl::encoding::DefaultFuchsiaResourceDialect,
9501                &mut self.peer,
9502                decoder,
9503                offset + 0,
9504                _depth
9505            )?;
9506            fidl::decode!(
9507                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
9508                fidl::encoding::DefaultFuchsiaResourceDialect,
9509                &mut self.connection,
9510                decoder,
9511                offset + 16,
9512                _depth
9513            )?;
9514            Ok(())
9515        }
9516    }
9517
9518    impl fidl::encoding::ResourceTypeMarker for CentralConnectPeripheralRequest {
9519        type Borrowed<'a> = &'a mut Self;
9520        fn take_or_borrow<'a>(
9521            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9522        ) -> Self::Borrowed<'a> {
9523            value
9524        }
9525    }
9526
9527    unsafe impl fidl::encoding::TypeMarker for CentralConnectPeripheralRequest {
9528        type Owned = Self;
9529
9530        #[inline(always)]
9531        fn inline_align(_context: fidl::encoding::Context) -> usize {
9532            8
9533        }
9534
9535        #[inline(always)]
9536        fn inline_size(_context: fidl::encoding::Context) -> usize {
9537            40
9538        }
9539    }
9540
9541    unsafe impl
9542        fidl::encoding::Encode<
9543            CentralConnectPeripheralRequest,
9544            fidl::encoding::DefaultFuchsiaResourceDialect,
9545        > for &mut CentralConnectPeripheralRequest
9546    {
9547        #[inline]
9548        unsafe fn encode(
9549            self,
9550            encoder: &mut fidl::encoding::Encoder<
9551                '_,
9552                fidl::encoding::DefaultFuchsiaResourceDialect,
9553            >,
9554            offset: usize,
9555            _depth: fidl::encoding::Depth,
9556        ) -> fidl::Result<()> {
9557            encoder.debug_check_bounds::<CentralConnectPeripheralRequest>(offset);
9558            // Delegate to tuple encoding.
9559            fidl::encoding::Encode::<
9560                CentralConnectPeripheralRequest,
9561                fidl::encoding::DefaultFuchsiaResourceDialect,
9562            >::encode(
9563                (
9564                    <fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(
9565                        &self.identifier,
9566                    ),
9567                    <ConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
9568                    <fidl::encoding::Endpoint<
9569                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
9570                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9571                        &mut self.gatt_client
9572                    ),
9573                ),
9574                encoder,
9575                offset,
9576                _depth,
9577            )
9578        }
9579    }
9580    unsafe impl<
9581            T0: fidl::encoding::Encode<
9582                fidl::encoding::BoundedString<16>,
9583                fidl::encoding::DefaultFuchsiaResourceDialect,
9584            >,
9585            T1: fidl::encoding::Encode<
9586                ConnectionOptions,
9587                fidl::encoding::DefaultFuchsiaResourceDialect,
9588            >,
9589            T2: fidl::encoding::Encode<
9590                fidl::encoding::Endpoint<
9591                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
9592                >,
9593                fidl::encoding::DefaultFuchsiaResourceDialect,
9594            >,
9595        >
9596        fidl::encoding::Encode<
9597            CentralConnectPeripheralRequest,
9598            fidl::encoding::DefaultFuchsiaResourceDialect,
9599        > for (T0, T1, T2)
9600    {
9601        #[inline]
9602        unsafe fn encode(
9603            self,
9604            encoder: &mut fidl::encoding::Encoder<
9605                '_,
9606                fidl::encoding::DefaultFuchsiaResourceDialect,
9607            >,
9608            offset: usize,
9609            depth: fidl::encoding::Depth,
9610        ) -> fidl::Result<()> {
9611            encoder.debug_check_bounds::<CentralConnectPeripheralRequest>(offset);
9612            // Zero out padding regions. There's no need to apply masks
9613            // because the unmasked parts will be overwritten by fields.
9614            unsafe {
9615                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
9616                (ptr as *mut u64).write_unaligned(0);
9617            }
9618            // Write the fields.
9619            self.0.encode(encoder, offset + 0, depth)?;
9620            self.1.encode(encoder, offset + 16, depth)?;
9621            self.2.encode(encoder, offset + 32, depth)?;
9622            Ok(())
9623        }
9624    }
9625
9626    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9627        for CentralConnectPeripheralRequest
9628    {
9629        #[inline(always)]
9630        fn new_empty() -> Self {
9631            Self {
9632                identifier: fidl::new_empty!(
9633                    fidl::encoding::BoundedString<16>,
9634                    fidl::encoding::DefaultFuchsiaResourceDialect
9635                ),
9636                options: fidl::new_empty!(
9637                    ConnectionOptions,
9638                    fidl::encoding::DefaultFuchsiaResourceDialect
9639                ),
9640                gatt_client: fidl::new_empty!(
9641                    fidl::encoding::Endpoint<
9642                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
9643                    >,
9644                    fidl::encoding::DefaultFuchsiaResourceDialect
9645                ),
9646            }
9647        }
9648
9649        #[inline]
9650        unsafe fn decode(
9651            &mut self,
9652            decoder: &mut fidl::encoding::Decoder<
9653                '_,
9654                fidl::encoding::DefaultFuchsiaResourceDialect,
9655            >,
9656            offset: usize,
9657            _depth: fidl::encoding::Depth,
9658        ) -> fidl::Result<()> {
9659            decoder.debug_check_bounds::<Self>(offset);
9660            // Verify that padding bytes are zero.
9661            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
9662            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9663            let mask = 0xffffffff00000000u64;
9664            let maskedval = padval & mask;
9665            if maskedval != 0 {
9666                return Err(fidl::Error::NonZeroPadding {
9667                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
9668                });
9669            }
9670            fidl::decode!(
9671                fidl::encoding::BoundedString<16>,
9672                fidl::encoding::DefaultFuchsiaResourceDialect,
9673                &mut self.identifier,
9674                decoder,
9675                offset + 0,
9676                _depth
9677            )?;
9678            fidl::decode!(
9679                ConnectionOptions,
9680                fidl::encoding::DefaultFuchsiaResourceDialect,
9681                &mut self.options,
9682                decoder,
9683                offset + 16,
9684                _depth
9685            )?;
9686            fidl::decode!(
9687                fidl::encoding::Endpoint<
9688                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
9689                >,
9690                fidl::encoding::DefaultFuchsiaResourceDialect,
9691                &mut self.gatt_client,
9692                decoder,
9693                offset + 32,
9694                _depth
9695            )?;
9696            Ok(())
9697        }
9698    }
9699
9700    impl fidl::encoding::ResourceTypeMarker for CentralConnectRequest {
9701        type Borrowed<'a> = &'a mut Self;
9702        fn take_or_borrow<'a>(
9703            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9704        ) -> Self::Borrowed<'a> {
9705            value
9706        }
9707    }
9708
9709    unsafe impl fidl::encoding::TypeMarker for CentralConnectRequest {
9710        type Owned = Self;
9711
9712        #[inline(always)]
9713        fn inline_align(_context: fidl::encoding::Context) -> usize {
9714            8
9715        }
9716
9717        #[inline(always)]
9718        fn inline_size(_context: fidl::encoding::Context) -> usize {
9719            32
9720        }
9721    }
9722
9723    unsafe impl
9724        fidl::encoding::Encode<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
9725        for &mut CentralConnectRequest
9726    {
9727        #[inline]
9728        unsafe fn encode(
9729            self,
9730            encoder: &mut fidl::encoding::Encoder<
9731                '_,
9732                fidl::encoding::DefaultFuchsiaResourceDialect,
9733            >,
9734            offset: usize,
9735            _depth: fidl::encoding::Depth,
9736        ) -> fidl::Result<()> {
9737            encoder.debug_check_bounds::<CentralConnectRequest>(offset);
9738            // Delegate to tuple encoding.
9739            fidl::encoding::Encode::<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9740                (
9741                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
9742                    <ConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
9743                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
9744                ),
9745                encoder, offset, _depth
9746            )
9747        }
9748    }
9749    unsafe impl<
9750            T0: fidl::encoding::Encode<
9751                fidl_fuchsia_bluetooth::PeerId,
9752                fidl::encoding::DefaultFuchsiaResourceDialect,
9753            >,
9754            T1: fidl::encoding::Encode<
9755                ConnectionOptions,
9756                fidl::encoding::DefaultFuchsiaResourceDialect,
9757            >,
9758            T2: fidl::encoding::Encode<
9759                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
9760                fidl::encoding::DefaultFuchsiaResourceDialect,
9761            >,
9762        >
9763        fidl::encoding::Encode<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
9764        for (T0, T1, T2)
9765    {
9766        #[inline]
9767        unsafe fn encode(
9768            self,
9769            encoder: &mut fidl::encoding::Encoder<
9770                '_,
9771                fidl::encoding::DefaultFuchsiaResourceDialect,
9772            >,
9773            offset: usize,
9774            depth: fidl::encoding::Depth,
9775        ) -> fidl::Result<()> {
9776            encoder.debug_check_bounds::<CentralConnectRequest>(offset);
9777            // Zero out padding regions. There's no need to apply masks
9778            // because the unmasked parts will be overwritten by fields.
9779            unsafe {
9780                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
9781                (ptr as *mut u64).write_unaligned(0);
9782            }
9783            // Write the fields.
9784            self.0.encode(encoder, offset + 0, depth)?;
9785            self.1.encode(encoder, offset + 8, depth)?;
9786            self.2.encode(encoder, offset + 24, depth)?;
9787            Ok(())
9788        }
9789    }
9790
9791    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9792        for CentralConnectRequest
9793    {
9794        #[inline(always)]
9795        fn new_empty() -> Self {
9796            Self {
9797                id: fidl::new_empty!(
9798                    fidl_fuchsia_bluetooth::PeerId,
9799                    fidl::encoding::DefaultFuchsiaResourceDialect
9800                ),
9801                options: fidl::new_empty!(
9802                    ConnectionOptions,
9803                    fidl::encoding::DefaultFuchsiaResourceDialect
9804                ),
9805                handle: fidl::new_empty!(
9806                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
9807                    fidl::encoding::DefaultFuchsiaResourceDialect
9808                ),
9809            }
9810        }
9811
9812        #[inline]
9813        unsafe fn decode(
9814            &mut self,
9815            decoder: &mut fidl::encoding::Decoder<
9816                '_,
9817                fidl::encoding::DefaultFuchsiaResourceDialect,
9818            >,
9819            offset: usize,
9820            _depth: fidl::encoding::Depth,
9821        ) -> fidl::Result<()> {
9822            decoder.debug_check_bounds::<Self>(offset);
9823            // Verify that padding bytes are zero.
9824            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
9825            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9826            let mask = 0xffffffff00000000u64;
9827            let maskedval = padval & mask;
9828            if maskedval != 0 {
9829                return Err(fidl::Error::NonZeroPadding {
9830                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
9831                });
9832            }
9833            fidl::decode!(
9834                fidl_fuchsia_bluetooth::PeerId,
9835                fidl::encoding::DefaultFuchsiaResourceDialect,
9836                &mut self.id,
9837                decoder,
9838                offset + 0,
9839                _depth
9840            )?;
9841            fidl::decode!(
9842                ConnectionOptions,
9843                fidl::encoding::DefaultFuchsiaResourceDialect,
9844                &mut self.options,
9845                decoder,
9846                offset + 8,
9847                _depth
9848            )?;
9849            fidl::decode!(
9850                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
9851                fidl::encoding::DefaultFuchsiaResourceDialect,
9852                &mut self.handle,
9853                decoder,
9854                offset + 24,
9855                _depth
9856            )?;
9857            Ok(())
9858        }
9859    }
9860
9861    impl fidl::encoding::ResourceTypeMarker for CentralScanRequest {
9862        type Borrowed<'a> = &'a mut Self;
9863        fn take_or_borrow<'a>(
9864            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9865        ) -> Self::Borrowed<'a> {
9866            value
9867        }
9868    }
9869
9870    unsafe impl fidl::encoding::TypeMarker for CentralScanRequest {
9871        type Owned = Self;
9872
9873        #[inline(always)]
9874        fn inline_align(_context: fidl::encoding::Context) -> usize {
9875            8
9876        }
9877
9878        #[inline(always)]
9879        fn inline_size(_context: fidl::encoding::Context) -> usize {
9880            24
9881        }
9882    }
9883
9884    unsafe impl
9885        fidl::encoding::Encode<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
9886        for &mut CentralScanRequest
9887    {
9888        #[inline]
9889        unsafe fn encode(
9890            self,
9891            encoder: &mut fidl::encoding::Encoder<
9892                '_,
9893                fidl::encoding::DefaultFuchsiaResourceDialect,
9894            >,
9895            offset: usize,
9896            _depth: fidl::encoding::Depth,
9897        ) -> fidl::Result<()> {
9898            encoder.debug_check_bounds::<CentralScanRequest>(offset);
9899            // Delegate to tuple encoding.
9900            fidl::encoding::Encode::<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9901                (
9902                    <ScanOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
9903                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.result_watcher),
9904                ),
9905                encoder, offset, _depth
9906            )
9907        }
9908    }
9909    unsafe impl<
9910            T0: fidl::encoding::Encode<ScanOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
9911            T1: fidl::encoding::Encode<
9912                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
9913                fidl::encoding::DefaultFuchsiaResourceDialect,
9914            >,
9915        >
9916        fidl::encoding::Encode<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
9917        for (T0, T1)
9918    {
9919        #[inline]
9920        unsafe fn encode(
9921            self,
9922            encoder: &mut fidl::encoding::Encoder<
9923                '_,
9924                fidl::encoding::DefaultFuchsiaResourceDialect,
9925            >,
9926            offset: usize,
9927            depth: fidl::encoding::Depth,
9928        ) -> fidl::Result<()> {
9929            encoder.debug_check_bounds::<CentralScanRequest>(offset);
9930            // Zero out padding regions. There's no need to apply masks
9931            // because the unmasked parts will be overwritten by fields.
9932            unsafe {
9933                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
9934                (ptr as *mut u64).write_unaligned(0);
9935            }
9936            // Write the fields.
9937            self.0.encode(encoder, offset + 0, depth)?;
9938            self.1.encode(encoder, offset + 16, depth)?;
9939            Ok(())
9940        }
9941    }
9942
9943    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9944        for CentralScanRequest
9945    {
9946        #[inline(always)]
9947        fn new_empty() -> Self {
9948            Self {
9949                options: fidl::new_empty!(
9950                    ScanOptions,
9951                    fidl::encoding::DefaultFuchsiaResourceDialect
9952                ),
9953                result_watcher: fidl::new_empty!(
9954                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
9955                    fidl::encoding::DefaultFuchsiaResourceDialect
9956                ),
9957            }
9958        }
9959
9960        #[inline]
9961        unsafe fn decode(
9962            &mut self,
9963            decoder: &mut fidl::encoding::Decoder<
9964                '_,
9965                fidl::encoding::DefaultFuchsiaResourceDialect,
9966            >,
9967            offset: usize,
9968            _depth: fidl::encoding::Depth,
9969        ) -> fidl::Result<()> {
9970            decoder.debug_check_bounds::<Self>(offset);
9971            // Verify that padding bytes are zero.
9972            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
9973            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9974            let mask = 0xffffffff00000000u64;
9975            let maskedval = padval & mask;
9976            if maskedval != 0 {
9977                return Err(fidl::Error::NonZeroPadding {
9978                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
9979                });
9980            }
9981            fidl::decode!(
9982                ScanOptions,
9983                fidl::encoding::DefaultFuchsiaResourceDialect,
9984                &mut self.options,
9985                decoder,
9986                offset + 0,
9987                _depth
9988            )?;
9989            fidl::decode!(
9990                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
9991                fidl::encoding::DefaultFuchsiaResourceDialect,
9992                &mut self.result_watcher,
9993                decoder,
9994                offset + 16,
9995                _depth
9996            )?;
9997            Ok(())
9998        }
9999    }
10000
10001    impl fidl::encoding::ResourceTypeMarker for ChannelListenerAcceptRequest {
10002        type Borrowed<'a> = &'a mut Self;
10003        fn take_or_borrow<'a>(
10004            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10005        ) -> Self::Borrowed<'a> {
10006            value
10007        }
10008    }
10009
10010    unsafe impl fidl::encoding::TypeMarker for ChannelListenerAcceptRequest {
10011        type Owned = Self;
10012
10013        #[inline(always)]
10014        fn inline_align(_context: fidl::encoding::Context) -> usize {
10015            4
10016        }
10017
10018        #[inline(always)]
10019        fn inline_size(_context: fidl::encoding::Context) -> usize {
10020            4
10021        }
10022    }
10023
10024    unsafe impl
10025        fidl::encoding::Encode<
10026            ChannelListenerAcceptRequest,
10027            fidl::encoding::DefaultFuchsiaResourceDialect,
10028        > for &mut ChannelListenerAcceptRequest
10029    {
10030        #[inline]
10031        unsafe fn encode(
10032            self,
10033            encoder: &mut fidl::encoding::Encoder<
10034                '_,
10035                fidl::encoding::DefaultFuchsiaResourceDialect,
10036            >,
10037            offset: usize,
10038            _depth: fidl::encoding::Depth,
10039        ) -> fidl::Result<()> {
10040            encoder.debug_check_bounds::<ChannelListenerAcceptRequest>(offset);
10041            // Delegate to tuple encoding.
10042            fidl::encoding::Encode::<
10043                ChannelListenerAcceptRequest,
10044                fidl::encoding::DefaultFuchsiaResourceDialect,
10045            >::encode(
10046                (<fidl::encoding::Endpoint<
10047                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
10048                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10049                    &mut self.channel
10050                ),),
10051                encoder,
10052                offset,
10053                _depth,
10054            )
10055        }
10056    }
10057    unsafe impl<
10058            T0: fidl::encoding::Encode<
10059                fidl::encoding::Endpoint<
10060                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
10061                >,
10062                fidl::encoding::DefaultFuchsiaResourceDialect,
10063            >,
10064        >
10065        fidl::encoding::Encode<
10066            ChannelListenerAcceptRequest,
10067            fidl::encoding::DefaultFuchsiaResourceDialect,
10068        > for (T0,)
10069    {
10070        #[inline]
10071        unsafe fn encode(
10072            self,
10073            encoder: &mut fidl::encoding::Encoder<
10074                '_,
10075                fidl::encoding::DefaultFuchsiaResourceDialect,
10076            >,
10077            offset: usize,
10078            depth: fidl::encoding::Depth,
10079        ) -> fidl::Result<()> {
10080            encoder.debug_check_bounds::<ChannelListenerAcceptRequest>(offset);
10081            // Zero out padding regions. There's no need to apply masks
10082            // because the unmasked parts will be overwritten by fields.
10083            // Write the fields.
10084            self.0.encode(encoder, offset + 0, depth)?;
10085            Ok(())
10086        }
10087    }
10088
10089    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10090        for ChannelListenerAcceptRequest
10091    {
10092        #[inline(always)]
10093        fn new_empty() -> Self {
10094            Self {
10095                channel: fidl::new_empty!(
10096                    fidl::encoding::Endpoint<
10097                        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
10098                    >,
10099                    fidl::encoding::DefaultFuchsiaResourceDialect
10100                ),
10101            }
10102        }
10103
10104        #[inline]
10105        unsafe fn decode(
10106            &mut self,
10107            decoder: &mut fidl::encoding::Decoder<
10108                '_,
10109                fidl::encoding::DefaultFuchsiaResourceDialect,
10110            >,
10111            offset: usize,
10112            _depth: fidl::encoding::Depth,
10113        ) -> fidl::Result<()> {
10114            decoder.debug_check_bounds::<Self>(offset);
10115            // Verify that padding bytes are zero.
10116            fidl::decode!(
10117                fidl::encoding::Endpoint<
10118                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
10119                >,
10120                fidl::encoding::DefaultFuchsiaResourceDialect,
10121                &mut self.channel,
10122                decoder,
10123                offset + 0,
10124                _depth
10125            )?;
10126            Ok(())
10127        }
10128    }
10129
10130    impl fidl::encoding::ResourceTypeMarker for ConnectionRequestGattClientRequest {
10131        type Borrowed<'a> = &'a mut Self;
10132        fn take_or_borrow<'a>(
10133            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10134        ) -> Self::Borrowed<'a> {
10135            value
10136        }
10137    }
10138
10139    unsafe impl fidl::encoding::TypeMarker for ConnectionRequestGattClientRequest {
10140        type Owned = Self;
10141
10142        #[inline(always)]
10143        fn inline_align(_context: fidl::encoding::Context) -> usize {
10144            4
10145        }
10146
10147        #[inline(always)]
10148        fn inline_size(_context: fidl::encoding::Context) -> usize {
10149            4
10150        }
10151    }
10152
10153    unsafe impl
10154        fidl::encoding::Encode<
10155            ConnectionRequestGattClientRequest,
10156            fidl::encoding::DefaultFuchsiaResourceDialect,
10157        > for &mut ConnectionRequestGattClientRequest
10158    {
10159        #[inline]
10160        unsafe fn encode(
10161            self,
10162            encoder: &mut fidl::encoding::Encoder<
10163                '_,
10164                fidl::encoding::DefaultFuchsiaResourceDialect,
10165            >,
10166            offset: usize,
10167            _depth: fidl::encoding::Depth,
10168        ) -> fidl::Result<()> {
10169            encoder.debug_check_bounds::<ConnectionRequestGattClientRequest>(offset);
10170            // Delegate to tuple encoding.
10171            fidl::encoding::Encode::<
10172                ConnectionRequestGattClientRequest,
10173                fidl::encoding::DefaultFuchsiaResourceDialect,
10174            >::encode(
10175                (<fidl::encoding::Endpoint<
10176                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
10177                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10178                    &mut self.client
10179                ),),
10180                encoder,
10181                offset,
10182                _depth,
10183            )
10184        }
10185    }
10186    unsafe impl<
10187            T0: fidl::encoding::Encode<
10188                fidl::encoding::Endpoint<
10189                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
10190                >,
10191                fidl::encoding::DefaultFuchsiaResourceDialect,
10192            >,
10193        >
10194        fidl::encoding::Encode<
10195            ConnectionRequestGattClientRequest,
10196            fidl::encoding::DefaultFuchsiaResourceDialect,
10197        > for (T0,)
10198    {
10199        #[inline]
10200        unsafe fn encode(
10201            self,
10202            encoder: &mut fidl::encoding::Encoder<
10203                '_,
10204                fidl::encoding::DefaultFuchsiaResourceDialect,
10205            >,
10206            offset: usize,
10207            depth: fidl::encoding::Depth,
10208        ) -> fidl::Result<()> {
10209            encoder.debug_check_bounds::<ConnectionRequestGattClientRequest>(offset);
10210            // Zero out padding regions. There's no need to apply masks
10211            // because the unmasked parts will be overwritten by fields.
10212            // Write the fields.
10213            self.0.encode(encoder, offset + 0, depth)?;
10214            Ok(())
10215        }
10216    }
10217
10218    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10219        for ConnectionRequestGattClientRequest
10220    {
10221        #[inline(always)]
10222        fn new_empty() -> Self {
10223            Self {
10224                client: fidl::new_empty!(
10225                    fidl::encoding::Endpoint<
10226                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
10227                    >,
10228                    fidl::encoding::DefaultFuchsiaResourceDialect
10229                ),
10230            }
10231        }
10232
10233        #[inline]
10234        unsafe fn decode(
10235            &mut self,
10236            decoder: &mut fidl::encoding::Decoder<
10237                '_,
10238                fidl::encoding::DefaultFuchsiaResourceDialect,
10239            >,
10240            offset: usize,
10241            _depth: fidl::encoding::Depth,
10242        ) -> fidl::Result<()> {
10243            decoder.debug_check_bounds::<Self>(offset);
10244            // Verify that padding bytes are zero.
10245            fidl::decode!(
10246                fidl::encoding::Endpoint<
10247                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
10248                >,
10249                fidl::encoding::DefaultFuchsiaResourceDialect,
10250                &mut self.client,
10251                decoder,
10252                offset + 0,
10253                _depth
10254            )?;
10255            Ok(())
10256        }
10257    }
10258
10259    impl fidl::encoding::ResourceTypeMarker for PeripheralAdvertiseRequest {
10260        type Borrowed<'a> = &'a mut Self;
10261        fn take_or_borrow<'a>(
10262            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10263        ) -> Self::Borrowed<'a> {
10264            value
10265        }
10266    }
10267
10268    unsafe impl fidl::encoding::TypeMarker for PeripheralAdvertiseRequest {
10269        type Owned = Self;
10270
10271        #[inline(always)]
10272        fn inline_align(_context: fidl::encoding::Context) -> usize {
10273            8
10274        }
10275
10276        #[inline(always)]
10277        fn inline_size(_context: fidl::encoding::Context) -> usize {
10278            24
10279        }
10280    }
10281
10282    unsafe impl
10283        fidl::encoding::Encode<
10284            PeripheralAdvertiseRequest,
10285            fidl::encoding::DefaultFuchsiaResourceDialect,
10286        > for &mut PeripheralAdvertiseRequest
10287    {
10288        #[inline]
10289        unsafe fn encode(
10290            self,
10291            encoder: &mut fidl::encoding::Encoder<
10292                '_,
10293                fidl::encoding::DefaultFuchsiaResourceDialect,
10294            >,
10295            offset: usize,
10296            _depth: fidl::encoding::Depth,
10297        ) -> fidl::Result<()> {
10298            encoder.debug_check_bounds::<PeripheralAdvertiseRequest>(offset);
10299            // Delegate to tuple encoding.
10300            fidl::encoding::Encode::<
10301                PeripheralAdvertiseRequest,
10302                fidl::encoding::DefaultFuchsiaResourceDialect,
10303            >::encode(
10304                (
10305                    <AdvertisingParameters as fidl::encoding::ValueTypeMarker>::borrow(
10306                        &self.parameters,
10307                    ),
10308                    <fidl::encoding::Endpoint<
10309                        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
10310                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10311                        &mut self.advertised_peripheral,
10312                    ),
10313                ),
10314                encoder,
10315                offset,
10316                _depth,
10317            )
10318        }
10319    }
10320    unsafe impl<
10321            T0: fidl::encoding::Encode<
10322                AdvertisingParameters,
10323                fidl::encoding::DefaultFuchsiaResourceDialect,
10324            >,
10325            T1: fidl::encoding::Encode<
10326                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>>,
10327                fidl::encoding::DefaultFuchsiaResourceDialect,
10328            >,
10329        >
10330        fidl::encoding::Encode<
10331            PeripheralAdvertiseRequest,
10332            fidl::encoding::DefaultFuchsiaResourceDialect,
10333        > for (T0, T1)
10334    {
10335        #[inline]
10336        unsafe fn encode(
10337            self,
10338            encoder: &mut fidl::encoding::Encoder<
10339                '_,
10340                fidl::encoding::DefaultFuchsiaResourceDialect,
10341            >,
10342            offset: usize,
10343            depth: fidl::encoding::Depth,
10344        ) -> fidl::Result<()> {
10345            encoder.debug_check_bounds::<PeripheralAdvertiseRequest>(offset);
10346            // Zero out padding regions. There's no need to apply masks
10347            // because the unmasked parts will be overwritten by fields.
10348            unsafe {
10349                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
10350                (ptr as *mut u64).write_unaligned(0);
10351            }
10352            // Write the fields.
10353            self.0.encode(encoder, offset + 0, depth)?;
10354            self.1.encode(encoder, offset + 16, depth)?;
10355            Ok(())
10356        }
10357    }
10358
10359    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10360        for PeripheralAdvertiseRequest
10361    {
10362        #[inline(always)]
10363        fn new_empty() -> Self {
10364            Self {
10365                parameters: fidl::new_empty!(
10366                    AdvertisingParameters,
10367                    fidl::encoding::DefaultFuchsiaResourceDialect
10368                ),
10369                advertised_peripheral: fidl::new_empty!(
10370                    fidl::encoding::Endpoint<
10371                        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
10372                    >,
10373                    fidl::encoding::DefaultFuchsiaResourceDialect
10374                ),
10375            }
10376        }
10377
10378        #[inline]
10379        unsafe fn decode(
10380            &mut self,
10381            decoder: &mut fidl::encoding::Decoder<
10382                '_,
10383                fidl::encoding::DefaultFuchsiaResourceDialect,
10384            >,
10385            offset: usize,
10386            _depth: fidl::encoding::Depth,
10387        ) -> fidl::Result<()> {
10388            decoder.debug_check_bounds::<Self>(offset);
10389            // Verify that padding bytes are zero.
10390            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
10391            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10392            let mask = 0xffffffff00000000u64;
10393            let maskedval = padval & mask;
10394            if maskedval != 0 {
10395                return Err(fidl::Error::NonZeroPadding {
10396                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
10397                });
10398            }
10399            fidl::decode!(
10400                AdvertisingParameters,
10401                fidl::encoding::DefaultFuchsiaResourceDialect,
10402                &mut self.parameters,
10403                decoder,
10404                offset + 0,
10405                _depth
10406            )?;
10407            fidl::decode!(
10408                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>>,
10409                fidl::encoding::DefaultFuchsiaResourceDialect,
10410                &mut self.advertised_peripheral,
10411                decoder,
10412                offset + 16,
10413                _depth
10414            )?;
10415            Ok(())
10416        }
10417    }
10418
10419    impl fidl::encoding::ResourceTypeMarker for PeripheralOnPeerConnectedRequest {
10420        type Borrowed<'a> = &'a mut Self;
10421        fn take_or_borrow<'a>(
10422            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10423        ) -> Self::Borrowed<'a> {
10424            value
10425        }
10426    }
10427
10428    unsafe impl fidl::encoding::TypeMarker for PeripheralOnPeerConnectedRequest {
10429        type Owned = Self;
10430
10431        #[inline(always)]
10432        fn inline_align(_context: fidl::encoding::Context) -> usize {
10433            8
10434        }
10435
10436        #[inline(always)]
10437        fn inline_size(_context: fidl::encoding::Context) -> usize {
10438            24
10439        }
10440    }
10441
10442    unsafe impl
10443        fidl::encoding::Encode<
10444            PeripheralOnPeerConnectedRequest,
10445            fidl::encoding::DefaultFuchsiaResourceDialect,
10446        > for &mut PeripheralOnPeerConnectedRequest
10447    {
10448        #[inline]
10449        unsafe fn encode(
10450            self,
10451            encoder: &mut fidl::encoding::Encoder<
10452                '_,
10453                fidl::encoding::DefaultFuchsiaResourceDialect,
10454            >,
10455            offset: usize,
10456            _depth: fidl::encoding::Depth,
10457        ) -> fidl::Result<()> {
10458            encoder.debug_check_bounds::<PeripheralOnPeerConnectedRequest>(offset);
10459            // Delegate to tuple encoding.
10460            fidl::encoding::Encode::<PeripheralOnPeerConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10461                (
10462                    <Peer as fidl::encoding::ValueTypeMarker>::borrow(&self.peer),
10463                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.connection),
10464                ),
10465                encoder, offset, _depth
10466            )
10467        }
10468    }
10469    unsafe impl<
10470            T0: fidl::encoding::Encode<Peer, fidl::encoding::DefaultFuchsiaResourceDialect>,
10471            T1: fidl::encoding::Encode<
10472                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
10473                fidl::encoding::DefaultFuchsiaResourceDialect,
10474            >,
10475        >
10476        fidl::encoding::Encode<
10477            PeripheralOnPeerConnectedRequest,
10478            fidl::encoding::DefaultFuchsiaResourceDialect,
10479        > for (T0, T1)
10480    {
10481        #[inline]
10482        unsafe fn encode(
10483            self,
10484            encoder: &mut fidl::encoding::Encoder<
10485                '_,
10486                fidl::encoding::DefaultFuchsiaResourceDialect,
10487            >,
10488            offset: usize,
10489            depth: fidl::encoding::Depth,
10490        ) -> fidl::Result<()> {
10491            encoder.debug_check_bounds::<PeripheralOnPeerConnectedRequest>(offset);
10492            // Zero out padding regions. There's no need to apply masks
10493            // because the unmasked parts will be overwritten by fields.
10494            unsafe {
10495                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
10496                (ptr as *mut u64).write_unaligned(0);
10497            }
10498            // Write the fields.
10499            self.0.encode(encoder, offset + 0, depth)?;
10500            self.1.encode(encoder, offset + 16, depth)?;
10501            Ok(())
10502        }
10503    }
10504
10505    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10506        for PeripheralOnPeerConnectedRequest
10507    {
10508        #[inline(always)]
10509        fn new_empty() -> Self {
10510            Self {
10511                peer: fidl::new_empty!(Peer, fidl::encoding::DefaultFuchsiaResourceDialect),
10512                connection: fidl::new_empty!(
10513                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
10514                    fidl::encoding::DefaultFuchsiaResourceDialect
10515                ),
10516            }
10517        }
10518
10519        #[inline]
10520        unsafe fn decode(
10521            &mut self,
10522            decoder: &mut fidl::encoding::Decoder<
10523                '_,
10524                fidl::encoding::DefaultFuchsiaResourceDialect,
10525            >,
10526            offset: usize,
10527            _depth: fidl::encoding::Depth,
10528        ) -> fidl::Result<()> {
10529            decoder.debug_check_bounds::<Self>(offset);
10530            // Verify that padding bytes are zero.
10531            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
10532            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10533            let mask = 0xffffffff00000000u64;
10534            let maskedval = padval & mask;
10535            if maskedval != 0 {
10536                return Err(fidl::Error::NonZeroPadding {
10537                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
10538                });
10539            }
10540            fidl::decode!(
10541                Peer,
10542                fidl::encoding::DefaultFuchsiaResourceDialect,
10543                &mut self.peer,
10544                decoder,
10545                offset + 0,
10546                _depth
10547            )?;
10548            fidl::decode!(
10549                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
10550                fidl::encoding::DefaultFuchsiaResourceDialect,
10551                &mut self.connection,
10552                decoder,
10553                offset + 16,
10554                _depth
10555            )?;
10556            Ok(())
10557        }
10558    }
10559
10560    impl fidl::encoding::ResourceTypeMarker for PeripheralStartAdvertisingRequest {
10561        type Borrowed<'a> = &'a mut Self;
10562        fn take_or_borrow<'a>(
10563            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10564        ) -> Self::Borrowed<'a> {
10565            value
10566        }
10567    }
10568
10569    unsafe impl fidl::encoding::TypeMarker for PeripheralStartAdvertisingRequest {
10570        type Owned = Self;
10571
10572        #[inline(always)]
10573        fn inline_align(_context: fidl::encoding::Context) -> usize {
10574            8
10575        }
10576
10577        #[inline(always)]
10578        fn inline_size(_context: fidl::encoding::Context) -> usize {
10579            24
10580        }
10581    }
10582
10583    unsafe impl
10584        fidl::encoding::Encode<
10585            PeripheralStartAdvertisingRequest,
10586            fidl::encoding::DefaultFuchsiaResourceDialect,
10587        > for &mut PeripheralStartAdvertisingRequest
10588    {
10589        #[inline]
10590        unsafe fn encode(
10591            self,
10592            encoder: &mut fidl::encoding::Encoder<
10593                '_,
10594                fidl::encoding::DefaultFuchsiaResourceDialect,
10595            >,
10596            offset: usize,
10597            _depth: fidl::encoding::Depth,
10598        ) -> fidl::Result<()> {
10599            encoder.debug_check_bounds::<PeripheralStartAdvertisingRequest>(offset);
10600            // Delegate to tuple encoding.
10601            fidl::encoding::Encode::<PeripheralStartAdvertisingRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10602                (
10603                    <AdvertisingParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.parameters),
10604                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
10605                ),
10606                encoder, offset, _depth
10607            )
10608        }
10609    }
10610    unsafe impl<
10611            T0: fidl::encoding::Encode<
10612                AdvertisingParameters,
10613                fidl::encoding::DefaultFuchsiaResourceDialect,
10614            >,
10615            T1: fidl::encoding::Encode<
10616                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
10617                fidl::encoding::DefaultFuchsiaResourceDialect,
10618            >,
10619        >
10620        fidl::encoding::Encode<
10621            PeripheralStartAdvertisingRequest,
10622            fidl::encoding::DefaultFuchsiaResourceDialect,
10623        > for (T0, T1)
10624    {
10625        #[inline]
10626        unsafe fn encode(
10627            self,
10628            encoder: &mut fidl::encoding::Encoder<
10629                '_,
10630                fidl::encoding::DefaultFuchsiaResourceDialect,
10631            >,
10632            offset: usize,
10633            depth: fidl::encoding::Depth,
10634        ) -> fidl::Result<()> {
10635            encoder.debug_check_bounds::<PeripheralStartAdvertisingRequest>(offset);
10636            // Zero out padding regions. There's no need to apply masks
10637            // because the unmasked parts will be overwritten by fields.
10638            unsafe {
10639                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
10640                (ptr as *mut u64).write_unaligned(0);
10641            }
10642            // Write the fields.
10643            self.0.encode(encoder, offset + 0, depth)?;
10644            self.1.encode(encoder, offset + 16, depth)?;
10645            Ok(())
10646        }
10647    }
10648
10649    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10650        for PeripheralStartAdvertisingRequest
10651    {
10652        #[inline(always)]
10653        fn new_empty() -> Self {
10654            Self {
10655                parameters: fidl::new_empty!(
10656                    AdvertisingParameters,
10657                    fidl::encoding::DefaultFuchsiaResourceDialect
10658                ),
10659                handle: fidl::new_empty!(
10660                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
10661                    fidl::encoding::DefaultFuchsiaResourceDialect
10662                ),
10663            }
10664        }
10665
10666        #[inline]
10667        unsafe fn decode(
10668            &mut self,
10669            decoder: &mut fidl::encoding::Decoder<
10670                '_,
10671                fidl::encoding::DefaultFuchsiaResourceDialect,
10672            >,
10673            offset: usize,
10674            _depth: fidl::encoding::Depth,
10675        ) -> fidl::Result<()> {
10676            decoder.debug_check_bounds::<Self>(offset);
10677            // Verify that padding bytes are zero.
10678            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
10679            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10680            let mask = 0xffffffff00000000u64;
10681            let maskedval = padval & mask;
10682            if maskedval != 0 {
10683                return Err(fidl::Error::NonZeroPadding {
10684                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
10685                });
10686            }
10687            fidl::decode!(
10688                AdvertisingParameters,
10689                fidl::encoding::DefaultFuchsiaResourceDialect,
10690                &mut self.parameters,
10691                decoder,
10692                offset + 0,
10693                _depth
10694            )?;
10695            fidl::decode!(
10696                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
10697                fidl::encoding::DefaultFuchsiaResourceDialect,
10698                &mut self.handle,
10699                decoder,
10700                offset + 16,
10701                _depth
10702            )?;
10703            Ok(())
10704        }
10705    }
10706
10707    impl CentralCreateConnectedIsochronousGroupRequest {
10708        #[inline(always)]
10709        fn max_ordinal_present(&self) -> u64 {
10710            if let Some(_) = self.cig {
10711                return 3;
10712            }
10713            if let Some(_) = self.cis_requested_parameters {
10714                return 2;
10715            }
10716            if let Some(_) = self.cig_parameters {
10717                return 1;
10718            }
10719            0
10720        }
10721    }
10722
10723    impl fidl::encoding::ResourceTypeMarker for CentralCreateConnectedIsochronousGroupRequest {
10724        type Borrowed<'a> = &'a mut Self;
10725        fn take_or_borrow<'a>(
10726            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10727        ) -> Self::Borrowed<'a> {
10728            value
10729        }
10730    }
10731
10732    unsafe impl fidl::encoding::TypeMarker for CentralCreateConnectedIsochronousGroupRequest {
10733        type Owned = Self;
10734
10735        #[inline(always)]
10736        fn inline_align(_context: fidl::encoding::Context) -> usize {
10737            8
10738        }
10739
10740        #[inline(always)]
10741        fn inline_size(_context: fidl::encoding::Context) -> usize {
10742            16
10743        }
10744    }
10745
10746    unsafe impl
10747        fidl::encoding::Encode<
10748            CentralCreateConnectedIsochronousGroupRequest,
10749            fidl::encoding::DefaultFuchsiaResourceDialect,
10750        > for &mut CentralCreateConnectedIsochronousGroupRequest
10751    {
10752        unsafe fn encode(
10753            self,
10754            encoder: &mut fidl::encoding::Encoder<
10755                '_,
10756                fidl::encoding::DefaultFuchsiaResourceDialect,
10757            >,
10758            offset: usize,
10759            mut depth: fidl::encoding::Depth,
10760        ) -> fidl::Result<()> {
10761            encoder.debug_check_bounds::<CentralCreateConnectedIsochronousGroupRequest>(offset);
10762            // Vector header
10763            let max_ordinal: u64 = self.max_ordinal_present();
10764            encoder.write_num(max_ordinal, offset);
10765            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10766            // Calling encoder.out_of_line_offset(0) is not allowed.
10767            if max_ordinal == 0 {
10768                return Ok(());
10769            }
10770            depth.increment()?;
10771            let envelope_size = 8;
10772            let bytes_len = max_ordinal as usize * envelope_size;
10773            #[allow(unused_variables)]
10774            let offset = encoder.out_of_line_offset(bytes_len);
10775            let mut _prev_end_offset: usize = 0;
10776            if 1 > max_ordinal {
10777                return Ok(());
10778            }
10779
10780            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10781            // are envelope_size bytes.
10782            let cur_offset: usize = (1 - 1) * envelope_size;
10783
10784            // Zero reserved fields.
10785            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10786
10787            // Safety:
10788            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10789            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10790            //   envelope_size bytes, there is always sufficient room.
10791            fidl::encoding::encode_in_envelope_optional::<
10792                CigParameters,
10793                fidl::encoding::DefaultFuchsiaResourceDialect,
10794            >(
10795                self.cig_parameters
10796                    .as_ref()
10797                    .map(<CigParameters as fidl::encoding::ValueTypeMarker>::borrow),
10798                encoder,
10799                offset + cur_offset,
10800                depth,
10801            )?;
10802
10803            _prev_end_offset = cur_offset + envelope_size;
10804            if 2 > max_ordinal {
10805                return Ok(());
10806            }
10807
10808            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10809            // are envelope_size bytes.
10810            let cur_offset: usize = (2 - 1) * envelope_size;
10811
10812            // Zero reserved fields.
10813            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10814
10815            // Safety:
10816            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10817            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10818            //   envelope_size bytes, there is always sufficient room.
10819            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect>(
10820            self.cis_requested_parameters.as_mut().map(<fidl::encoding::Vector<CisRequestedParameters, 31> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
10821            encoder, offset + cur_offset, depth
10822        )?;
10823
10824            _prev_end_offset = cur_offset + envelope_size;
10825            if 3 > max_ordinal {
10826                return Ok(());
10827            }
10828
10829            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10830            // are envelope_size bytes.
10831            let cur_offset: usize = (3 - 1) * envelope_size;
10832
10833            // Zero reserved fields.
10834            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10835
10836            // Safety:
10837            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10838            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10839            //   envelope_size bytes, there is always sufficient room.
10840            fidl::encoding::encode_in_envelope_optional::<
10841                fidl::encoding::Endpoint<
10842                    fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
10843                >,
10844                fidl::encoding::DefaultFuchsiaResourceDialect,
10845            >(
10846                self.cig.as_mut().map(
10847                    <fidl::encoding::Endpoint<
10848                        fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
10849                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10850                ),
10851                encoder,
10852                offset + cur_offset,
10853                depth,
10854            )?;
10855
10856            _prev_end_offset = cur_offset + envelope_size;
10857
10858            Ok(())
10859        }
10860    }
10861
10862    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10863        for CentralCreateConnectedIsochronousGroupRequest
10864    {
10865        #[inline(always)]
10866        fn new_empty() -> Self {
10867            Self::default()
10868        }
10869
10870        unsafe fn decode(
10871            &mut self,
10872            decoder: &mut fidl::encoding::Decoder<
10873                '_,
10874                fidl::encoding::DefaultFuchsiaResourceDialect,
10875            >,
10876            offset: usize,
10877            mut depth: fidl::encoding::Depth,
10878        ) -> fidl::Result<()> {
10879            decoder.debug_check_bounds::<Self>(offset);
10880            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10881                None => return Err(fidl::Error::NotNullable),
10882                Some(len) => len,
10883            };
10884            // Calling decoder.out_of_line_offset(0) is not allowed.
10885            if len == 0 {
10886                return Ok(());
10887            };
10888            depth.increment()?;
10889            let envelope_size = 8;
10890            let bytes_len = len * envelope_size;
10891            let offset = decoder.out_of_line_offset(bytes_len)?;
10892            // Decode the envelope for each type.
10893            let mut _next_ordinal_to_read = 0;
10894            let mut next_offset = offset;
10895            let end_offset = offset + bytes_len;
10896            _next_ordinal_to_read += 1;
10897            if next_offset >= end_offset {
10898                return Ok(());
10899            }
10900
10901            // Decode unknown envelopes for gaps in ordinals.
10902            while _next_ordinal_to_read < 1 {
10903                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10904                _next_ordinal_to_read += 1;
10905                next_offset += envelope_size;
10906            }
10907
10908            let next_out_of_line = decoder.next_out_of_line();
10909            let handles_before = decoder.remaining_handles();
10910            if let Some((inlined, num_bytes, num_handles)) =
10911                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10912            {
10913                let member_inline_size =
10914                    <CigParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10915                if inlined != (member_inline_size <= 4) {
10916                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10917                }
10918                let inner_offset;
10919                let mut inner_depth = depth.clone();
10920                if inlined {
10921                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10922                    inner_offset = next_offset;
10923                } else {
10924                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10925                    inner_depth.increment()?;
10926                }
10927                let val_ref = self.cig_parameters.get_or_insert_with(|| {
10928                    fidl::new_empty!(CigParameters, fidl::encoding::DefaultFuchsiaResourceDialect)
10929                });
10930                fidl::decode!(
10931                    CigParameters,
10932                    fidl::encoding::DefaultFuchsiaResourceDialect,
10933                    val_ref,
10934                    decoder,
10935                    inner_offset,
10936                    inner_depth
10937                )?;
10938                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10939                {
10940                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10941                }
10942                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10943                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10944                }
10945            }
10946
10947            next_offset += envelope_size;
10948            _next_ordinal_to_read += 1;
10949            if next_offset >= end_offset {
10950                return Ok(());
10951            }
10952
10953            // Decode unknown envelopes for gaps in ordinals.
10954            while _next_ordinal_to_read < 2 {
10955                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10956                _next_ordinal_to_read += 1;
10957                next_offset += envelope_size;
10958            }
10959
10960            let next_out_of_line = decoder.next_out_of_line();
10961            let handles_before = decoder.remaining_handles();
10962            if let Some((inlined, num_bytes, num_handles)) =
10963                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10964            {
10965                let member_inline_size = <fidl::encoding::Vector<CisRequestedParameters, 31> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10966                if inlined != (member_inline_size <= 4) {
10967                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10968                }
10969                let inner_offset;
10970                let mut inner_depth = depth.clone();
10971                if inlined {
10972                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10973                    inner_offset = next_offset;
10974                } else {
10975                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10976                    inner_depth.increment()?;
10977                }
10978                let val_ref =
10979                self.cis_requested_parameters.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect));
10980                fidl::decode!(fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10981                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10982                {
10983                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10984                }
10985                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10986                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10987                }
10988            }
10989
10990            next_offset += envelope_size;
10991            _next_ordinal_to_read += 1;
10992            if next_offset >= end_offset {
10993                return Ok(());
10994            }
10995
10996            // Decode unknown envelopes for gaps in ordinals.
10997            while _next_ordinal_to_read < 3 {
10998                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10999                _next_ordinal_to_read += 1;
11000                next_offset += envelope_size;
11001            }
11002
11003            let next_out_of_line = decoder.next_out_of_line();
11004            let handles_before = decoder.remaining_handles();
11005            if let Some((inlined, num_bytes, num_handles)) =
11006                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11007            {
11008                let member_inline_size = <fidl::encoding::Endpoint<
11009                    fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
11010                > as fidl::encoding::TypeMarker>::inline_size(
11011                    decoder.context
11012                );
11013                if inlined != (member_inline_size <= 4) {
11014                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11015                }
11016                let inner_offset;
11017                let mut inner_depth = depth.clone();
11018                if inlined {
11019                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11020                    inner_offset = next_offset;
11021                } else {
11022                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11023                    inner_depth.increment()?;
11024                }
11025                let val_ref = self.cig.get_or_insert_with(|| {
11026                    fidl::new_empty!(
11027                        fidl::encoding::Endpoint<
11028                            fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
11029                        >,
11030                        fidl::encoding::DefaultFuchsiaResourceDialect
11031                    )
11032                });
11033                fidl::decode!(
11034                    fidl::encoding::Endpoint<
11035                        fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
11036                    >,
11037                    fidl::encoding::DefaultFuchsiaResourceDialect,
11038                    val_ref,
11039                    decoder,
11040                    inner_offset,
11041                    inner_depth
11042                )?;
11043                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11044                {
11045                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11046                }
11047                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11048                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11049                }
11050            }
11051
11052            next_offset += envelope_size;
11053
11054            // Decode the remaining unknown envelopes.
11055            while next_offset < end_offset {
11056                _next_ordinal_to_read += 1;
11057                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11058                next_offset += envelope_size;
11059            }
11060
11061            Ok(())
11062        }
11063    }
11064
11065    impl ChannelListenerRegistryListenL2capRequest {
11066        #[inline(always)]
11067        fn max_ordinal_present(&self) -> u64 {
11068            if let Some(_) = self.listener {
11069                return 2;
11070            }
11071            if let Some(_) = self.parameters {
11072                return 1;
11073            }
11074            0
11075        }
11076    }
11077
11078    impl fidl::encoding::ResourceTypeMarker for ChannelListenerRegistryListenL2capRequest {
11079        type Borrowed<'a> = &'a mut Self;
11080        fn take_or_borrow<'a>(
11081            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11082        ) -> Self::Borrowed<'a> {
11083            value
11084        }
11085    }
11086
11087    unsafe impl fidl::encoding::TypeMarker for ChannelListenerRegistryListenL2capRequest {
11088        type Owned = Self;
11089
11090        #[inline(always)]
11091        fn inline_align(_context: fidl::encoding::Context) -> usize {
11092            8
11093        }
11094
11095        #[inline(always)]
11096        fn inline_size(_context: fidl::encoding::Context) -> usize {
11097            16
11098        }
11099    }
11100
11101    unsafe impl
11102        fidl::encoding::Encode<
11103            ChannelListenerRegistryListenL2capRequest,
11104            fidl::encoding::DefaultFuchsiaResourceDialect,
11105        > for &mut ChannelListenerRegistryListenL2capRequest
11106    {
11107        unsafe fn encode(
11108            self,
11109            encoder: &mut fidl::encoding::Encoder<
11110                '_,
11111                fidl::encoding::DefaultFuchsiaResourceDialect,
11112            >,
11113            offset: usize,
11114            mut depth: fidl::encoding::Depth,
11115        ) -> fidl::Result<()> {
11116            encoder.debug_check_bounds::<ChannelListenerRegistryListenL2capRequest>(offset);
11117            // Vector header
11118            let max_ordinal: u64 = self.max_ordinal_present();
11119            encoder.write_num(max_ordinal, offset);
11120            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11121            // Calling encoder.out_of_line_offset(0) is not allowed.
11122            if max_ordinal == 0 {
11123                return Ok(());
11124            }
11125            depth.increment()?;
11126            let envelope_size = 8;
11127            let bytes_len = max_ordinal as usize * envelope_size;
11128            #[allow(unused_variables)]
11129            let offset = encoder.out_of_line_offset(bytes_len);
11130            let mut _prev_end_offset: usize = 0;
11131            if 1 > max_ordinal {
11132                return Ok(());
11133            }
11134
11135            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11136            // are envelope_size bytes.
11137            let cur_offset: usize = (1 - 1) * envelope_size;
11138
11139            // Zero reserved fields.
11140            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11141
11142            // Safety:
11143            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11144            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11145            //   envelope_size bytes, there is always sufficient room.
11146            fidl::encoding::encode_in_envelope_optional::<
11147                AcceptedChannelParameters,
11148                fidl::encoding::DefaultFuchsiaResourceDialect,
11149            >(
11150                self.parameters
11151                    .as_ref()
11152                    .map(<AcceptedChannelParameters as fidl::encoding::ValueTypeMarker>::borrow),
11153                encoder,
11154                offset + cur_offset,
11155                depth,
11156            )?;
11157
11158            _prev_end_offset = cur_offset + envelope_size;
11159            if 2 > max_ordinal {
11160                return Ok(());
11161            }
11162
11163            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11164            // are envelope_size bytes.
11165            let cur_offset: usize = (2 - 1) * envelope_size;
11166
11167            // Zero reserved fields.
11168            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11169
11170            // Safety:
11171            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11172            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11173            //   envelope_size bytes, there is always sufficient room.
11174            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11175            self.listener.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11176            encoder, offset + cur_offset, depth
11177        )?;
11178
11179            _prev_end_offset = cur_offset + envelope_size;
11180
11181            Ok(())
11182        }
11183    }
11184
11185    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11186        for ChannelListenerRegistryListenL2capRequest
11187    {
11188        #[inline(always)]
11189        fn new_empty() -> Self {
11190            Self::default()
11191        }
11192
11193        unsafe fn decode(
11194            &mut self,
11195            decoder: &mut fidl::encoding::Decoder<
11196                '_,
11197                fidl::encoding::DefaultFuchsiaResourceDialect,
11198            >,
11199            offset: usize,
11200            mut depth: fidl::encoding::Depth,
11201        ) -> fidl::Result<()> {
11202            decoder.debug_check_bounds::<Self>(offset);
11203            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11204                None => return Err(fidl::Error::NotNullable),
11205                Some(len) => len,
11206            };
11207            // Calling decoder.out_of_line_offset(0) is not allowed.
11208            if len == 0 {
11209                return Ok(());
11210            };
11211            depth.increment()?;
11212            let envelope_size = 8;
11213            let bytes_len = len * envelope_size;
11214            let offset = decoder.out_of_line_offset(bytes_len)?;
11215            // Decode the envelope for each type.
11216            let mut _next_ordinal_to_read = 0;
11217            let mut next_offset = offset;
11218            let end_offset = offset + bytes_len;
11219            _next_ordinal_to_read += 1;
11220            if next_offset >= end_offset {
11221                return Ok(());
11222            }
11223
11224            // Decode unknown envelopes for gaps in ordinals.
11225            while _next_ordinal_to_read < 1 {
11226                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11227                _next_ordinal_to_read += 1;
11228                next_offset += envelope_size;
11229            }
11230
11231            let next_out_of_line = decoder.next_out_of_line();
11232            let handles_before = decoder.remaining_handles();
11233            if let Some((inlined, num_bytes, num_handles)) =
11234                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11235            {
11236                let member_inline_size =
11237                    <AcceptedChannelParameters as fidl::encoding::TypeMarker>::inline_size(
11238                        decoder.context,
11239                    );
11240                if inlined != (member_inline_size <= 4) {
11241                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11242                }
11243                let inner_offset;
11244                let mut inner_depth = depth.clone();
11245                if inlined {
11246                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11247                    inner_offset = next_offset;
11248                } else {
11249                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11250                    inner_depth.increment()?;
11251                }
11252                let val_ref = self.parameters.get_or_insert_with(|| {
11253                    fidl::new_empty!(
11254                        AcceptedChannelParameters,
11255                        fidl::encoding::DefaultFuchsiaResourceDialect
11256                    )
11257                });
11258                fidl::decode!(
11259                    AcceptedChannelParameters,
11260                    fidl::encoding::DefaultFuchsiaResourceDialect,
11261                    val_ref,
11262                    decoder,
11263                    inner_offset,
11264                    inner_depth
11265                )?;
11266                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11267                {
11268                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11269                }
11270                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11271                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11272                }
11273            }
11274
11275            next_offset += envelope_size;
11276            _next_ordinal_to_read += 1;
11277            if next_offset >= end_offset {
11278                return Ok(());
11279            }
11280
11281            // Decode unknown envelopes for gaps in ordinals.
11282            while _next_ordinal_to_read < 2 {
11283                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11284                _next_ordinal_to_read += 1;
11285                next_offset += envelope_size;
11286            }
11287
11288            let next_out_of_line = decoder.next_out_of_line();
11289            let handles_before = decoder.remaining_handles();
11290            if let Some((inlined, num_bytes, num_handles)) =
11291                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11292            {
11293                let member_inline_size = <fidl::encoding::Endpoint<
11294                    fidl::endpoints::ClientEnd<ChannelListenerMarker>,
11295                > as fidl::encoding::TypeMarker>::inline_size(
11296                    decoder.context
11297                );
11298                if inlined != (member_inline_size <= 4) {
11299                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11300                }
11301                let inner_offset;
11302                let mut inner_depth = depth.clone();
11303                if inlined {
11304                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11305                    inner_offset = next_offset;
11306                } else {
11307                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11308                    inner_depth.increment()?;
11309                }
11310                let val_ref = self.listener.get_or_insert_with(|| {
11311                    fidl::new_empty!(
11312                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
11313                        fidl::encoding::DefaultFuchsiaResourceDialect
11314                    )
11315                });
11316                fidl::decode!(
11317                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
11318                    fidl::encoding::DefaultFuchsiaResourceDialect,
11319                    val_ref,
11320                    decoder,
11321                    inner_offset,
11322                    inner_depth
11323                )?;
11324                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11325                {
11326                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11327                }
11328                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11329                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11330                }
11331            }
11332
11333            next_offset += envelope_size;
11334
11335            // Decode the remaining unknown envelopes.
11336            while next_offset < end_offset {
11337                _next_ordinal_to_read += 1;
11338                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11339                next_offset += envelope_size;
11340            }
11341
11342            Ok(())
11343        }
11344    }
11345
11346    impl CisRequestedParameters {
11347        #[inline(always)]
11348        fn max_ordinal_present(&self) -> u64 {
11349            if let Some(_) = self.max_sdu_size_incoming {
11350                return 4;
11351            }
11352            if let Some(_) = self.max_sdu_size_outgoing {
11353                return 3;
11354            }
11355            if let Some(_) = self.connection_stream {
11356                return 2;
11357            }
11358            if let Some(_) = self.cis_id {
11359                return 1;
11360            }
11361            0
11362        }
11363    }
11364
11365    impl fidl::encoding::ResourceTypeMarker for CisRequestedParameters {
11366        type Borrowed<'a> = &'a mut Self;
11367        fn take_or_borrow<'a>(
11368            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11369        ) -> Self::Borrowed<'a> {
11370            value
11371        }
11372    }
11373
11374    unsafe impl fidl::encoding::TypeMarker for CisRequestedParameters {
11375        type Owned = Self;
11376
11377        #[inline(always)]
11378        fn inline_align(_context: fidl::encoding::Context) -> usize {
11379            8
11380        }
11381
11382        #[inline(always)]
11383        fn inline_size(_context: fidl::encoding::Context) -> usize {
11384            16
11385        }
11386    }
11387
11388    unsafe impl
11389        fidl::encoding::Encode<
11390            CisRequestedParameters,
11391            fidl::encoding::DefaultFuchsiaResourceDialect,
11392        > for &mut CisRequestedParameters
11393    {
11394        unsafe fn encode(
11395            self,
11396            encoder: &mut fidl::encoding::Encoder<
11397                '_,
11398                fidl::encoding::DefaultFuchsiaResourceDialect,
11399            >,
11400            offset: usize,
11401            mut depth: fidl::encoding::Depth,
11402        ) -> fidl::Result<()> {
11403            encoder.debug_check_bounds::<CisRequestedParameters>(offset);
11404            // Vector header
11405            let max_ordinal: u64 = self.max_ordinal_present();
11406            encoder.write_num(max_ordinal, offset);
11407            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11408            // Calling encoder.out_of_line_offset(0) is not allowed.
11409            if max_ordinal == 0 {
11410                return Ok(());
11411            }
11412            depth.increment()?;
11413            let envelope_size = 8;
11414            let bytes_len = max_ordinal as usize * envelope_size;
11415            #[allow(unused_variables)]
11416            let offset = encoder.out_of_line_offset(bytes_len);
11417            let mut _prev_end_offset: usize = 0;
11418            if 1 > max_ordinal {
11419                return Ok(());
11420            }
11421
11422            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11423            // are envelope_size bytes.
11424            let cur_offset: usize = (1 - 1) * envelope_size;
11425
11426            // Zero reserved fields.
11427            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11428
11429            // Safety:
11430            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11431            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11432            //   envelope_size bytes, there is always sufficient room.
11433            fidl::encoding::encode_in_envelope_optional::<
11434                u8,
11435                fidl::encoding::DefaultFuchsiaResourceDialect,
11436            >(
11437                self.cis_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
11438                encoder,
11439                offset + cur_offset,
11440                depth,
11441            )?;
11442
11443            _prev_end_offset = cur_offset + envelope_size;
11444            if 2 > max_ordinal {
11445                return Ok(());
11446            }
11447
11448            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11449            // are envelope_size bytes.
11450            let cur_offset: usize = (2 - 1) * envelope_size;
11451
11452            // Zero reserved fields.
11453            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11454
11455            // Safety:
11456            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11457            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11458            //   envelope_size bytes, there is always sufficient room.
11459            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11460            self.connection_stream.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11461            encoder, offset + cur_offset, depth
11462        )?;
11463
11464            _prev_end_offset = cur_offset + envelope_size;
11465            if 3 > max_ordinal {
11466                return Ok(());
11467            }
11468
11469            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11470            // are envelope_size bytes.
11471            let cur_offset: usize = (3 - 1) * envelope_size;
11472
11473            // Zero reserved fields.
11474            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11475
11476            // Safety:
11477            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11478            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11479            //   envelope_size bytes, there is always sufficient room.
11480            fidl::encoding::encode_in_envelope_optional::<
11481                u16,
11482                fidl::encoding::DefaultFuchsiaResourceDialect,
11483            >(
11484                self.max_sdu_size_outgoing
11485                    .as_ref()
11486                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
11487                encoder,
11488                offset + cur_offset,
11489                depth,
11490            )?;
11491
11492            _prev_end_offset = cur_offset + envelope_size;
11493            if 4 > max_ordinal {
11494                return Ok(());
11495            }
11496
11497            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11498            // are envelope_size bytes.
11499            let cur_offset: usize = (4 - 1) * envelope_size;
11500
11501            // Zero reserved fields.
11502            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11503
11504            // Safety:
11505            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11506            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11507            //   envelope_size bytes, there is always sufficient room.
11508            fidl::encoding::encode_in_envelope_optional::<
11509                u16,
11510                fidl::encoding::DefaultFuchsiaResourceDialect,
11511            >(
11512                self.max_sdu_size_incoming
11513                    .as_ref()
11514                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
11515                encoder,
11516                offset + cur_offset,
11517                depth,
11518            )?;
11519
11520            _prev_end_offset = cur_offset + envelope_size;
11521
11522            Ok(())
11523        }
11524    }
11525
11526    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11527        for CisRequestedParameters
11528    {
11529        #[inline(always)]
11530        fn new_empty() -> Self {
11531            Self::default()
11532        }
11533
11534        unsafe fn decode(
11535            &mut self,
11536            decoder: &mut fidl::encoding::Decoder<
11537                '_,
11538                fidl::encoding::DefaultFuchsiaResourceDialect,
11539            >,
11540            offset: usize,
11541            mut depth: fidl::encoding::Depth,
11542        ) -> fidl::Result<()> {
11543            decoder.debug_check_bounds::<Self>(offset);
11544            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11545                None => return Err(fidl::Error::NotNullable),
11546                Some(len) => len,
11547            };
11548            // Calling decoder.out_of_line_offset(0) is not allowed.
11549            if len == 0 {
11550                return Ok(());
11551            };
11552            depth.increment()?;
11553            let envelope_size = 8;
11554            let bytes_len = len * envelope_size;
11555            let offset = decoder.out_of_line_offset(bytes_len)?;
11556            // Decode the envelope for each type.
11557            let mut _next_ordinal_to_read = 0;
11558            let mut next_offset = offset;
11559            let end_offset = offset + bytes_len;
11560            _next_ordinal_to_read += 1;
11561            if next_offset >= end_offset {
11562                return Ok(());
11563            }
11564
11565            // Decode unknown envelopes for gaps in ordinals.
11566            while _next_ordinal_to_read < 1 {
11567                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11568                _next_ordinal_to_read += 1;
11569                next_offset += envelope_size;
11570            }
11571
11572            let next_out_of_line = decoder.next_out_of_line();
11573            let handles_before = decoder.remaining_handles();
11574            if let Some((inlined, num_bytes, num_handles)) =
11575                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11576            {
11577                let member_inline_size =
11578                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11579                if inlined != (member_inline_size <= 4) {
11580                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11581                }
11582                let inner_offset;
11583                let mut inner_depth = depth.clone();
11584                if inlined {
11585                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11586                    inner_offset = next_offset;
11587                } else {
11588                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11589                    inner_depth.increment()?;
11590                }
11591                let val_ref = self.cis_id.get_or_insert_with(|| {
11592                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
11593                });
11594                fidl::decode!(
11595                    u8,
11596                    fidl::encoding::DefaultFuchsiaResourceDialect,
11597                    val_ref,
11598                    decoder,
11599                    inner_offset,
11600                    inner_depth
11601                )?;
11602                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11603                {
11604                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11605                }
11606                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11607                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11608                }
11609            }
11610
11611            next_offset += envelope_size;
11612            _next_ordinal_to_read += 1;
11613            if next_offset >= end_offset {
11614                return Ok(());
11615            }
11616
11617            // Decode unknown envelopes for gaps in ordinals.
11618            while _next_ordinal_to_read < 2 {
11619                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11620                _next_ordinal_to_read += 1;
11621                next_offset += envelope_size;
11622            }
11623
11624            let next_out_of_line = decoder.next_out_of_line();
11625            let handles_before = decoder.remaining_handles();
11626            if let Some((inlined, num_bytes, num_handles)) =
11627                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11628            {
11629                let member_inline_size = <fidl::encoding::Endpoint<
11630                    fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
11631                > as fidl::encoding::TypeMarker>::inline_size(
11632                    decoder.context
11633                );
11634                if inlined != (member_inline_size <= 4) {
11635                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11636                }
11637                let inner_offset;
11638                let mut inner_depth = depth.clone();
11639                if inlined {
11640                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11641                    inner_offset = next_offset;
11642                } else {
11643                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11644                    inner_depth.increment()?;
11645                }
11646                let val_ref = self.connection_stream.get_or_insert_with(|| {
11647                    fidl::new_empty!(
11648                        fidl::encoding::Endpoint<
11649                            fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
11650                        >,
11651                        fidl::encoding::DefaultFuchsiaResourceDialect
11652                    )
11653                });
11654                fidl::decode!(
11655                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
11656                    fidl::encoding::DefaultFuchsiaResourceDialect,
11657                    val_ref,
11658                    decoder,
11659                    inner_offset,
11660                    inner_depth
11661                )?;
11662                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11663                {
11664                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11665                }
11666                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11667                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11668                }
11669            }
11670
11671            next_offset += envelope_size;
11672            _next_ordinal_to_read += 1;
11673            if next_offset >= end_offset {
11674                return Ok(());
11675            }
11676
11677            // Decode unknown envelopes for gaps in ordinals.
11678            while _next_ordinal_to_read < 3 {
11679                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11680                _next_ordinal_to_read += 1;
11681                next_offset += envelope_size;
11682            }
11683
11684            let next_out_of_line = decoder.next_out_of_line();
11685            let handles_before = decoder.remaining_handles();
11686            if let Some((inlined, num_bytes, num_handles)) =
11687                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11688            {
11689                let member_inline_size =
11690                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11691                if inlined != (member_inline_size <= 4) {
11692                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11693                }
11694                let inner_offset;
11695                let mut inner_depth = depth.clone();
11696                if inlined {
11697                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11698                    inner_offset = next_offset;
11699                } else {
11700                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11701                    inner_depth.increment()?;
11702                }
11703                let val_ref = self.max_sdu_size_outgoing.get_or_insert_with(|| {
11704                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
11705                });
11706                fidl::decode!(
11707                    u16,
11708                    fidl::encoding::DefaultFuchsiaResourceDialect,
11709                    val_ref,
11710                    decoder,
11711                    inner_offset,
11712                    inner_depth
11713                )?;
11714                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11715                {
11716                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11717                }
11718                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11719                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11720                }
11721            }
11722
11723            next_offset += envelope_size;
11724            _next_ordinal_to_read += 1;
11725            if next_offset >= end_offset {
11726                return Ok(());
11727            }
11728
11729            // Decode unknown envelopes for gaps in ordinals.
11730            while _next_ordinal_to_read < 4 {
11731                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11732                _next_ordinal_to_read += 1;
11733                next_offset += envelope_size;
11734            }
11735
11736            let next_out_of_line = decoder.next_out_of_line();
11737            let handles_before = decoder.remaining_handles();
11738            if let Some((inlined, num_bytes, num_handles)) =
11739                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11740            {
11741                let member_inline_size =
11742                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11743                if inlined != (member_inline_size <= 4) {
11744                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11745                }
11746                let inner_offset;
11747                let mut inner_depth = depth.clone();
11748                if inlined {
11749                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11750                    inner_offset = next_offset;
11751                } else {
11752                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11753                    inner_depth.increment()?;
11754                }
11755                let val_ref = self.max_sdu_size_incoming.get_or_insert_with(|| {
11756                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
11757                });
11758                fidl::decode!(
11759                    u16,
11760                    fidl::encoding::DefaultFuchsiaResourceDialect,
11761                    val_ref,
11762                    decoder,
11763                    inner_offset,
11764                    inner_depth
11765                )?;
11766                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11767                {
11768                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11769                }
11770                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11771                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11772                }
11773            }
11774
11775            next_offset += envelope_size;
11776
11777            // Decode the remaining unknown envelopes.
11778            while next_offset < end_offset {
11779                _next_ordinal_to_read += 1;
11780                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11781                next_offset += envelope_size;
11782            }
11783
11784            Ok(())
11785        }
11786    }
11787
11788    impl ConnectionAcceptCisRequest {
11789        #[inline(always)]
11790        fn max_ordinal_present(&self) -> u64 {
11791            if let Some(_) = self.connection_stream {
11792                return 3;
11793            }
11794            if let Some(_) = self.cis_id {
11795                return 2;
11796            }
11797            if let Some(_) = self.cig_id {
11798                return 1;
11799            }
11800            0
11801        }
11802    }
11803
11804    impl fidl::encoding::ResourceTypeMarker for ConnectionAcceptCisRequest {
11805        type Borrowed<'a> = &'a mut Self;
11806        fn take_or_borrow<'a>(
11807            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11808        ) -> Self::Borrowed<'a> {
11809            value
11810        }
11811    }
11812
11813    unsafe impl fidl::encoding::TypeMarker for ConnectionAcceptCisRequest {
11814        type Owned = Self;
11815
11816        #[inline(always)]
11817        fn inline_align(_context: fidl::encoding::Context) -> usize {
11818            8
11819        }
11820
11821        #[inline(always)]
11822        fn inline_size(_context: fidl::encoding::Context) -> usize {
11823            16
11824        }
11825    }
11826
11827    unsafe impl
11828        fidl::encoding::Encode<
11829            ConnectionAcceptCisRequest,
11830            fidl::encoding::DefaultFuchsiaResourceDialect,
11831        > for &mut ConnectionAcceptCisRequest
11832    {
11833        unsafe fn encode(
11834            self,
11835            encoder: &mut fidl::encoding::Encoder<
11836                '_,
11837                fidl::encoding::DefaultFuchsiaResourceDialect,
11838            >,
11839            offset: usize,
11840            mut depth: fidl::encoding::Depth,
11841        ) -> fidl::Result<()> {
11842            encoder.debug_check_bounds::<ConnectionAcceptCisRequest>(offset);
11843            // Vector header
11844            let max_ordinal: u64 = self.max_ordinal_present();
11845            encoder.write_num(max_ordinal, offset);
11846            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11847            // Calling encoder.out_of_line_offset(0) is not allowed.
11848            if max_ordinal == 0 {
11849                return Ok(());
11850            }
11851            depth.increment()?;
11852            let envelope_size = 8;
11853            let bytes_len = max_ordinal as usize * envelope_size;
11854            #[allow(unused_variables)]
11855            let offset = encoder.out_of_line_offset(bytes_len);
11856            let mut _prev_end_offset: usize = 0;
11857            if 1 > max_ordinal {
11858                return Ok(());
11859            }
11860
11861            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11862            // are envelope_size bytes.
11863            let cur_offset: usize = (1 - 1) * envelope_size;
11864
11865            // Zero reserved fields.
11866            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11867
11868            // Safety:
11869            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11870            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11871            //   envelope_size bytes, there is always sufficient room.
11872            fidl::encoding::encode_in_envelope_optional::<
11873                u8,
11874                fidl::encoding::DefaultFuchsiaResourceDialect,
11875            >(
11876                self.cig_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
11877                encoder,
11878                offset + cur_offset,
11879                depth,
11880            )?;
11881
11882            _prev_end_offset = cur_offset + envelope_size;
11883            if 2 > max_ordinal {
11884                return Ok(());
11885            }
11886
11887            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11888            // are envelope_size bytes.
11889            let cur_offset: usize = (2 - 1) * envelope_size;
11890
11891            // Zero reserved fields.
11892            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11893
11894            // Safety:
11895            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11896            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11897            //   envelope_size bytes, there is always sufficient room.
11898            fidl::encoding::encode_in_envelope_optional::<
11899                u8,
11900                fidl::encoding::DefaultFuchsiaResourceDialect,
11901            >(
11902                self.cis_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
11903                encoder,
11904                offset + cur_offset,
11905                depth,
11906            )?;
11907
11908            _prev_end_offset = cur_offset + envelope_size;
11909            if 3 > max_ordinal {
11910                return Ok(());
11911            }
11912
11913            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11914            // are envelope_size bytes.
11915            let cur_offset: usize = (3 - 1) * envelope_size;
11916
11917            // Zero reserved fields.
11918            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11919
11920            // Safety:
11921            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11922            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11923            //   envelope_size bytes, there is always sufficient room.
11924            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11925            self.connection_stream.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11926            encoder, offset + cur_offset, depth
11927        )?;
11928
11929            _prev_end_offset = cur_offset + envelope_size;
11930
11931            Ok(())
11932        }
11933    }
11934
11935    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11936        for ConnectionAcceptCisRequest
11937    {
11938        #[inline(always)]
11939        fn new_empty() -> Self {
11940            Self::default()
11941        }
11942
11943        unsafe fn decode(
11944            &mut self,
11945            decoder: &mut fidl::encoding::Decoder<
11946                '_,
11947                fidl::encoding::DefaultFuchsiaResourceDialect,
11948            >,
11949            offset: usize,
11950            mut depth: fidl::encoding::Depth,
11951        ) -> fidl::Result<()> {
11952            decoder.debug_check_bounds::<Self>(offset);
11953            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11954                None => return Err(fidl::Error::NotNullable),
11955                Some(len) => len,
11956            };
11957            // Calling decoder.out_of_line_offset(0) is not allowed.
11958            if len == 0 {
11959                return Ok(());
11960            };
11961            depth.increment()?;
11962            let envelope_size = 8;
11963            let bytes_len = len * envelope_size;
11964            let offset = decoder.out_of_line_offset(bytes_len)?;
11965            // Decode the envelope for each type.
11966            let mut _next_ordinal_to_read = 0;
11967            let mut next_offset = offset;
11968            let end_offset = offset + bytes_len;
11969            _next_ordinal_to_read += 1;
11970            if next_offset >= end_offset {
11971                return Ok(());
11972            }
11973
11974            // Decode unknown envelopes for gaps in ordinals.
11975            while _next_ordinal_to_read < 1 {
11976                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11977                _next_ordinal_to_read += 1;
11978                next_offset += envelope_size;
11979            }
11980
11981            let next_out_of_line = decoder.next_out_of_line();
11982            let handles_before = decoder.remaining_handles();
11983            if let Some((inlined, num_bytes, num_handles)) =
11984                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11985            {
11986                let member_inline_size =
11987                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11988                if inlined != (member_inline_size <= 4) {
11989                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11990                }
11991                let inner_offset;
11992                let mut inner_depth = depth.clone();
11993                if inlined {
11994                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11995                    inner_offset = next_offset;
11996                } else {
11997                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11998                    inner_depth.increment()?;
11999                }
12000                let val_ref = self.cig_id.get_or_insert_with(|| {
12001                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
12002                });
12003                fidl::decode!(
12004                    u8,
12005                    fidl::encoding::DefaultFuchsiaResourceDialect,
12006                    val_ref,
12007                    decoder,
12008                    inner_offset,
12009                    inner_depth
12010                )?;
12011                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12012                {
12013                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12014                }
12015                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12016                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12017                }
12018            }
12019
12020            next_offset += envelope_size;
12021            _next_ordinal_to_read += 1;
12022            if next_offset >= end_offset {
12023                return Ok(());
12024            }
12025
12026            // Decode unknown envelopes for gaps in ordinals.
12027            while _next_ordinal_to_read < 2 {
12028                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12029                _next_ordinal_to_read += 1;
12030                next_offset += envelope_size;
12031            }
12032
12033            let next_out_of_line = decoder.next_out_of_line();
12034            let handles_before = decoder.remaining_handles();
12035            if let Some((inlined, num_bytes, num_handles)) =
12036                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12037            {
12038                let member_inline_size =
12039                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12040                if inlined != (member_inline_size <= 4) {
12041                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12042                }
12043                let inner_offset;
12044                let mut inner_depth = depth.clone();
12045                if inlined {
12046                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12047                    inner_offset = next_offset;
12048                } else {
12049                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12050                    inner_depth.increment()?;
12051                }
12052                let val_ref = self.cis_id.get_or_insert_with(|| {
12053                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
12054                });
12055                fidl::decode!(
12056                    u8,
12057                    fidl::encoding::DefaultFuchsiaResourceDialect,
12058                    val_ref,
12059                    decoder,
12060                    inner_offset,
12061                    inner_depth
12062                )?;
12063                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12064                {
12065                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12066                }
12067                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12068                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12069                }
12070            }
12071
12072            next_offset += envelope_size;
12073            _next_ordinal_to_read += 1;
12074            if next_offset >= end_offset {
12075                return Ok(());
12076            }
12077
12078            // Decode unknown envelopes for gaps in ordinals.
12079            while _next_ordinal_to_read < 3 {
12080                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12081                _next_ordinal_to_read += 1;
12082                next_offset += envelope_size;
12083            }
12084
12085            let next_out_of_line = decoder.next_out_of_line();
12086            let handles_before = decoder.remaining_handles();
12087            if let Some((inlined, num_bytes, num_handles)) =
12088                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12089            {
12090                let member_inline_size = <fidl::encoding::Endpoint<
12091                    fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
12092                > as fidl::encoding::TypeMarker>::inline_size(
12093                    decoder.context
12094                );
12095                if inlined != (member_inline_size <= 4) {
12096                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12097                }
12098                let inner_offset;
12099                let mut inner_depth = depth.clone();
12100                if inlined {
12101                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12102                    inner_offset = next_offset;
12103                } else {
12104                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12105                    inner_depth.increment()?;
12106                }
12107                let val_ref = self.connection_stream.get_or_insert_with(|| {
12108                    fidl::new_empty!(
12109                        fidl::encoding::Endpoint<
12110                            fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
12111                        >,
12112                        fidl::encoding::DefaultFuchsiaResourceDialect
12113                    )
12114                });
12115                fidl::decode!(
12116                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
12117                    fidl::encoding::DefaultFuchsiaResourceDialect,
12118                    val_ref,
12119                    decoder,
12120                    inner_offset,
12121                    inner_depth
12122                )?;
12123                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12124                {
12125                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12126                }
12127                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12128                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12129                }
12130            }
12131
12132            next_offset += envelope_size;
12133
12134            // Decode the remaining unknown envelopes.
12135            while next_offset < end_offset {
12136                _next_ordinal_to_read += 1;
12137                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12138                next_offset += envelope_size;
12139            }
12140
12141            Ok(())
12142        }
12143    }
12144
12145    impl ConnectionConnectL2capRequest {
12146        #[inline(always)]
12147        fn max_ordinal_present(&self) -> u64 {
12148            if let Some(_) = self.psm {
12149                return 3;
12150            }
12151            if let Some(_) = self.channel {
12152                return 2;
12153            }
12154            if let Some(_) = self.parameters {
12155                return 1;
12156            }
12157            0
12158        }
12159    }
12160
12161    impl fidl::encoding::ResourceTypeMarker for ConnectionConnectL2capRequest {
12162        type Borrowed<'a> = &'a mut Self;
12163        fn take_or_borrow<'a>(
12164            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12165        ) -> Self::Borrowed<'a> {
12166            value
12167        }
12168    }
12169
12170    unsafe impl fidl::encoding::TypeMarker for ConnectionConnectL2capRequest {
12171        type Owned = Self;
12172
12173        #[inline(always)]
12174        fn inline_align(_context: fidl::encoding::Context) -> usize {
12175            8
12176        }
12177
12178        #[inline(always)]
12179        fn inline_size(_context: fidl::encoding::Context) -> usize {
12180            16
12181        }
12182    }
12183
12184    unsafe impl
12185        fidl::encoding::Encode<
12186            ConnectionConnectL2capRequest,
12187            fidl::encoding::DefaultFuchsiaResourceDialect,
12188        > for &mut ConnectionConnectL2capRequest
12189    {
12190        unsafe fn encode(
12191            self,
12192            encoder: &mut fidl::encoding::Encoder<
12193                '_,
12194                fidl::encoding::DefaultFuchsiaResourceDialect,
12195            >,
12196            offset: usize,
12197            mut depth: fidl::encoding::Depth,
12198        ) -> fidl::Result<()> {
12199            encoder.debug_check_bounds::<ConnectionConnectL2capRequest>(offset);
12200            // Vector header
12201            let max_ordinal: u64 = self.max_ordinal_present();
12202            encoder.write_num(max_ordinal, offset);
12203            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12204            // Calling encoder.out_of_line_offset(0) is not allowed.
12205            if max_ordinal == 0 {
12206                return Ok(());
12207            }
12208            depth.increment()?;
12209            let envelope_size = 8;
12210            let bytes_len = max_ordinal as usize * envelope_size;
12211            #[allow(unused_variables)]
12212            let offset = encoder.out_of_line_offset(bytes_len);
12213            let mut _prev_end_offset: usize = 0;
12214            if 1 > max_ordinal {
12215                return Ok(());
12216            }
12217
12218            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12219            // are envelope_size bytes.
12220            let cur_offset: usize = (1 - 1) * envelope_size;
12221
12222            // Zero reserved fields.
12223            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12224
12225            // Safety:
12226            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12227            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12228            //   envelope_size bytes, there is always sufficient room.
12229            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth::ChannelParameters, fidl::encoding::DefaultFuchsiaResourceDialect>(
12230            self.parameters.as_ref().map(<fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::ValueTypeMarker>::borrow),
12231            encoder, offset + cur_offset, depth
12232        )?;
12233
12234            _prev_end_offset = cur_offset + envelope_size;
12235            if 2 > max_ordinal {
12236                return Ok(());
12237            }
12238
12239            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12240            // are envelope_size bytes.
12241            let cur_offset: usize = (2 - 1) * envelope_size;
12242
12243            // Zero reserved fields.
12244            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12245
12246            // Safety:
12247            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12248            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12249            //   envelope_size bytes, there is always sufficient room.
12250            fidl::encoding::encode_in_envelope_optional::<
12251                fidl::encoding::Endpoint<
12252                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
12253                >,
12254                fidl::encoding::DefaultFuchsiaResourceDialect,
12255            >(
12256                self.channel.as_mut().map(
12257                    <fidl::encoding::Endpoint<
12258                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
12259                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12260                ),
12261                encoder,
12262                offset + cur_offset,
12263                depth,
12264            )?;
12265
12266            _prev_end_offset = cur_offset + envelope_size;
12267            if 3 > max_ordinal {
12268                return Ok(());
12269            }
12270
12271            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12272            // are envelope_size bytes.
12273            let cur_offset: usize = (3 - 1) * envelope_size;
12274
12275            // Zero reserved fields.
12276            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12277
12278            // Safety:
12279            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12280            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12281            //   envelope_size bytes, there is always sufficient room.
12282            fidl::encoding::encode_in_envelope_optional::<
12283                u16,
12284                fidl::encoding::DefaultFuchsiaResourceDialect,
12285            >(
12286                self.psm.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
12287                encoder,
12288                offset + cur_offset,
12289                depth,
12290            )?;
12291
12292            _prev_end_offset = cur_offset + envelope_size;
12293
12294            Ok(())
12295        }
12296    }
12297
12298    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12299        for ConnectionConnectL2capRequest
12300    {
12301        #[inline(always)]
12302        fn new_empty() -> Self {
12303            Self::default()
12304        }
12305
12306        unsafe fn decode(
12307            &mut self,
12308            decoder: &mut fidl::encoding::Decoder<
12309                '_,
12310                fidl::encoding::DefaultFuchsiaResourceDialect,
12311            >,
12312            offset: usize,
12313            mut depth: fidl::encoding::Depth,
12314        ) -> fidl::Result<()> {
12315            decoder.debug_check_bounds::<Self>(offset);
12316            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12317                None => return Err(fidl::Error::NotNullable),
12318                Some(len) => len,
12319            };
12320            // Calling decoder.out_of_line_offset(0) is not allowed.
12321            if len == 0 {
12322                return Ok(());
12323            };
12324            depth.increment()?;
12325            let envelope_size = 8;
12326            let bytes_len = len * envelope_size;
12327            let offset = decoder.out_of_line_offset(bytes_len)?;
12328            // Decode the envelope for each type.
12329            let mut _next_ordinal_to_read = 0;
12330            let mut next_offset = offset;
12331            let end_offset = offset + bytes_len;
12332            _next_ordinal_to_read += 1;
12333            if next_offset >= end_offset {
12334                return Ok(());
12335            }
12336
12337            // Decode unknown envelopes for gaps in ordinals.
12338            while _next_ordinal_to_read < 1 {
12339                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12340                _next_ordinal_to_read += 1;
12341                next_offset += envelope_size;
12342            }
12343
12344            let next_out_of_line = decoder.next_out_of_line();
12345            let handles_before = decoder.remaining_handles();
12346            if let Some((inlined, num_bytes, num_handles)) =
12347                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12348            {
12349                let member_inline_size = <fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12350                if inlined != (member_inline_size <= 4) {
12351                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12352                }
12353                let inner_offset;
12354                let mut inner_depth = depth.clone();
12355                if inlined {
12356                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12357                    inner_offset = next_offset;
12358                } else {
12359                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12360                    inner_depth.increment()?;
12361                }
12362                let val_ref = self.parameters.get_or_insert_with(|| {
12363                    fidl::new_empty!(
12364                        fidl_fuchsia_bluetooth::ChannelParameters,
12365                        fidl::encoding::DefaultFuchsiaResourceDialect
12366                    )
12367                });
12368                fidl::decode!(
12369                    fidl_fuchsia_bluetooth::ChannelParameters,
12370                    fidl::encoding::DefaultFuchsiaResourceDialect,
12371                    val_ref,
12372                    decoder,
12373                    inner_offset,
12374                    inner_depth
12375                )?;
12376                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12377                {
12378                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12379                }
12380                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12381                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12382                }
12383            }
12384
12385            next_offset += envelope_size;
12386            _next_ordinal_to_read += 1;
12387            if next_offset >= end_offset {
12388                return Ok(());
12389            }
12390
12391            // Decode unknown envelopes for gaps in ordinals.
12392            while _next_ordinal_to_read < 2 {
12393                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12394                _next_ordinal_to_read += 1;
12395                next_offset += envelope_size;
12396            }
12397
12398            let next_out_of_line = decoder.next_out_of_line();
12399            let handles_before = decoder.remaining_handles();
12400            if let Some((inlined, num_bytes, num_handles)) =
12401                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12402            {
12403                let member_inline_size = <fidl::encoding::Endpoint<
12404                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
12405                > as fidl::encoding::TypeMarker>::inline_size(
12406                    decoder.context
12407                );
12408                if inlined != (member_inline_size <= 4) {
12409                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12410                }
12411                let inner_offset;
12412                let mut inner_depth = depth.clone();
12413                if inlined {
12414                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12415                    inner_offset = next_offset;
12416                } else {
12417                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12418                    inner_depth.increment()?;
12419                }
12420                let val_ref = self.channel.get_or_insert_with(|| {
12421                    fidl::new_empty!(
12422                        fidl::encoding::Endpoint<
12423                            fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
12424                        >,
12425                        fidl::encoding::DefaultFuchsiaResourceDialect
12426                    )
12427                });
12428                fidl::decode!(
12429                    fidl::encoding::Endpoint<
12430                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
12431                    >,
12432                    fidl::encoding::DefaultFuchsiaResourceDialect,
12433                    val_ref,
12434                    decoder,
12435                    inner_offset,
12436                    inner_depth
12437                )?;
12438                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12439                {
12440                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12441                }
12442                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12443                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12444                }
12445            }
12446
12447            next_offset += envelope_size;
12448            _next_ordinal_to_read += 1;
12449            if next_offset >= end_offset {
12450                return Ok(());
12451            }
12452
12453            // Decode unknown envelopes for gaps in ordinals.
12454            while _next_ordinal_to_read < 3 {
12455                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12456                _next_ordinal_to_read += 1;
12457                next_offset += envelope_size;
12458            }
12459
12460            let next_out_of_line = decoder.next_out_of_line();
12461            let handles_before = decoder.remaining_handles();
12462            if let Some((inlined, num_bytes, num_handles)) =
12463                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12464            {
12465                let member_inline_size =
12466                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12467                if inlined != (member_inline_size <= 4) {
12468                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12469                }
12470                let inner_offset;
12471                let mut inner_depth = depth.clone();
12472                if inlined {
12473                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12474                    inner_offset = next_offset;
12475                } else {
12476                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12477                    inner_depth.increment()?;
12478                }
12479                let val_ref = self.psm.get_or_insert_with(|| {
12480                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
12481                });
12482                fidl::decode!(
12483                    u16,
12484                    fidl::encoding::DefaultFuchsiaResourceDialect,
12485                    val_ref,
12486                    decoder,
12487                    inner_offset,
12488                    inner_depth
12489                )?;
12490                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12491                {
12492                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12493                }
12494                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12495                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12496                }
12497            }
12498
12499            next_offset += envelope_size;
12500
12501            // Decode the remaining unknown envelopes.
12502            while next_offset < end_offset {
12503                _next_ordinal_to_read += 1;
12504                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12505                next_offset += envelope_size;
12506            }
12507
12508            Ok(())
12509        }
12510    }
12511}