fidl_fuchsia_bluetooth_bredr/
fidl_fuchsia_bluetooth_bredr.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_bredr_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct AudioOffloadExtStartAudioOffloadRequest {
16    pub configuration: AudioOffloadConfiguration,
17    pub controller: fidl::endpoints::ServerEnd<AudioOffloadControllerMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for AudioOffloadExtStartAudioOffloadRequest
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct ConnectionReceiverConnectedRequest {
27    pub peer_id: fidl_fuchsia_bluetooth::PeerId,
28    pub channel: Channel,
29    pub protocol: Vec<ProtocolDescriptor>,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for ConnectionReceiverConnectedRequest
34{
35}
36
37#[derive(Debug, PartialEq)]
38pub struct ProfileConnectResponse {
39    pub channel: Channel,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProfileConnectResponse {}
43
44/// A channel opened to a peer.
45#[derive(Debug, Default, PartialEq)]
46pub struct Channel {
47    /// Deprecated.
48    /// Socket interface for sending/receiving SDUs on the channel.
49    /// The channel will be closed if both this socket and the Connection are closed.
50    /// Always present.
51    pub socket: Option<fidl::Socket>,
52    /// Channel mode accepted by the peer.
53    /// Always present.
54    pub channel_mode: Option<fidl_fuchsia_bluetooth::ChannelMode>,
55    /// Maximum SDU size the peer is capable of accepting.
56    /// Always present.
57    pub max_tx_sdu_size: Option<u16>,
58    /// Audio Direction priority extension. See `AudioDirectionExt`.
59    /// Present only if supported.
60    pub ext_direction: Option<fidl::endpoints::ClientEnd<AudioDirectionExtMarker>>,
61    pub flush_timeout: Option<i64>,
62    /// L2CAP parameter extension. See `L2capParametersExt`.
63    /// Always present for L2CAP Channels, never present for other Channels.
64    pub ext_l2cap: Option<fidl::endpoints::ClientEnd<L2capParametersExtMarker>>,
65    /// Audio offload extension. See `AudioOffloadExt`.
66    /// Present only if supported.
67    pub ext_audio_offload: Option<fidl::endpoints::ClientEnd<AudioOffloadExtMarker>>,
68    /// Protocol for sending/receiving SDUs on the channel.
69    /// If present, closing this and `socket` will close the channel.
70    pub connection: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>>,
71    #[doc(hidden)]
72    pub __source_breaking: fidl::marker::SourceBreaking,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Channel {}
76
77#[derive(Debug, Default, PartialEq)]
78pub struct ProfileAdvertiseRequest {
79    /// The set of definitions describing the services that will be registered.
80    /// Required.
81    pub services: Option<Vec<ServiceDefinition>>,
82    /// Receives connections made to the advertised services.
83    /// Required.
84    pub receiver: Option<fidl::endpoints::ClientEnd<ConnectionReceiverMarker>>,
85    /// The default parameters used to configure L2CAP connections on the `receiver`.
86    /// Optional. See `ChannelParameters` for defaults.
87    pub parameters: Option<fidl_fuchsia_bluetooth::ChannelParameters>,
88    #[doc(hidden)]
89    pub __source_breaking: fidl::marker::SourceBreaking,
90}
91
92impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProfileAdvertiseRequest {}
93
94#[derive(Debug, Default, PartialEq)]
95pub struct ProfileConnectScoRequest {
96    /// Required.
97    pub peer_id: Option<fidl_fuchsia_bluetooth::PeerId>,
98    /// Required.
99    pub initiator: Option<bool>,
100    /// Required.
101    pub params: Option<Vec<ScoConnectionParameters>>,
102    /// Required.
103    pub connection: Option<fidl::endpoints::ServerEnd<ScoConnectionMarker>>,
104    #[doc(hidden)]
105    pub __source_breaking: fidl::marker::SourceBreaking,
106}
107
108impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProfileConnectScoRequest {}
109
110#[derive(Debug, Default, PartialEq)]
111pub struct ProfileSearchRequest {
112    /// Required - only one of `service_uuid` or `full_uuid` should be present.
113    pub service_uuid: Option<ServiceClassProfileIdentifier>,
114    /// Optional.
115    pub attr_ids: Option<Vec<u16>>,
116    /// Required.
117    pub results: Option<fidl::endpoints::ClientEnd<SearchResultsMarker>>,
118    /// Required - only one of `full_uuid` or `service_uuid` should be present.
119    pub full_uuid: Option<fidl_fuchsia_bluetooth::Uuid>,
120    #[doc(hidden)]
121    pub __source_breaking: fidl::marker::SourceBreaking,
122}
123
124impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProfileSearchRequest {}
125
126#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
127pub struct AudioDirectionExtMarker;
128
129impl fidl::endpoints::ProtocolMarker for AudioDirectionExtMarker {
130    type Proxy = AudioDirectionExtProxy;
131    type RequestStream = AudioDirectionExtRequestStream;
132    #[cfg(target_os = "fuchsia")]
133    type SynchronousProxy = AudioDirectionExtSynchronousProxy;
134
135    const DEBUG_NAME: &'static str = "(anonymous) AudioDirectionExt";
136}
137pub type AudioDirectionExtSetPriorityResult = Result<(), fidl_fuchsia_bluetooth::ErrorCode>;
138
139pub trait AudioDirectionExtProxyInterface: Send + Sync {
140    type SetPriorityResponseFut: std::future::Future<Output = Result<AudioDirectionExtSetPriorityResult, fidl::Error>>
141        + Send;
142    fn r#set_priority(&self, priority: A2dpDirectionPriority) -> Self::SetPriorityResponseFut;
143}
144#[derive(Debug)]
145#[cfg(target_os = "fuchsia")]
146pub struct AudioDirectionExtSynchronousProxy {
147    client: fidl::client::sync::Client,
148}
149
150#[cfg(target_os = "fuchsia")]
151impl fidl::endpoints::SynchronousProxy for AudioDirectionExtSynchronousProxy {
152    type Proxy = AudioDirectionExtProxy;
153    type Protocol = AudioDirectionExtMarker;
154
155    fn from_channel(inner: fidl::Channel) -> Self {
156        Self::new(inner)
157    }
158
159    fn into_channel(self) -> fidl::Channel {
160        self.client.into_channel()
161    }
162
163    fn as_channel(&self) -> &fidl::Channel {
164        self.client.as_channel()
165    }
166}
167
168#[cfg(target_os = "fuchsia")]
169impl AudioDirectionExtSynchronousProxy {
170    pub fn new(channel: fidl::Channel) -> Self {
171        let protocol_name =
172            <AudioDirectionExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
173        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
174    }
175
176    pub fn into_channel(self) -> fidl::Channel {
177        self.client.into_channel()
178    }
179
180    /// Waits until an event arrives and returns it. It is safe for other
181    /// threads to make concurrent requests while waiting for an event.
182    pub fn wait_for_event(
183        &self,
184        deadline: zx::MonotonicInstant,
185    ) -> Result<AudioDirectionExtEvent, fidl::Error> {
186        AudioDirectionExtEvent::decode(self.client.wait_for_event(deadline)?)
187    }
188
189    pub fn r#set_priority(
190        &self,
191        mut priority: A2dpDirectionPriority,
192        ___deadline: zx::MonotonicInstant,
193    ) -> Result<AudioDirectionExtSetPriorityResult, fidl::Error> {
194        let _response = self
195            .client
196            .send_query::<AudioDirectionExtSetPriorityRequest, fidl::encoding::FlexibleResultType<
197                fidl::encoding::EmptyStruct,
198                fidl_fuchsia_bluetooth::ErrorCode,
199            >>(
200                (priority,),
201                0x792713ef3b2bc38a,
202                fidl::encoding::DynamicFlags::FLEXIBLE,
203                ___deadline,
204            )?
205            .into_result::<AudioDirectionExtMarker>("set_priority")?;
206        Ok(_response.map(|x| x))
207    }
208}
209
210#[cfg(target_os = "fuchsia")]
211impl From<AudioDirectionExtSynchronousProxy> for zx::Handle {
212    fn from(value: AudioDirectionExtSynchronousProxy) -> Self {
213        value.into_channel().into()
214    }
215}
216
217#[cfg(target_os = "fuchsia")]
218impl From<fidl::Channel> for AudioDirectionExtSynchronousProxy {
219    fn from(value: fidl::Channel) -> Self {
220        Self::new(value)
221    }
222}
223
224#[derive(Debug, Clone)]
225pub struct AudioDirectionExtProxy {
226    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
227}
228
229impl fidl::endpoints::Proxy for AudioDirectionExtProxy {
230    type Protocol = AudioDirectionExtMarker;
231
232    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
233        Self::new(inner)
234    }
235
236    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
237        self.client.into_channel().map_err(|client| Self { client })
238    }
239
240    fn as_channel(&self) -> &::fidl::AsyncChannel {
241        self.client.as_channel()
242    }
243}
244
245impl AudioDirectionExtProxy {
246    /// Create a new Proxy for fuchsia.bluetooth.bredr/AudioDirectionExt.
247    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
248        let protocol_name =
249            <AudioDirectionExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
250        Self { client: fidl::client::Client::new(channel, protocol_name) }
251    }
252
253    /// Get a Stream of events from the remote end of the protocol.
254    ///
255    /// # Panics
256    ///
257    /// Panics if the event stream was already taken.
258    pub fn take_event_stream(&self) -> AudioDirectionExtEventStream {
259        AudioDirectionExtEventStream { event_receiver: self.client.take_event_receiver() }
260    }
261
262    pub fn r#set_priority(
263        &self,
264        mut priority: A2dpDirectionPriority,
265    ) -> fidl::client::QueryResponseFut<
266        AudioDirectionExtSetPriorityResult,
267        fidl::encoding::DefaultFuchsiaResourceDialect,
268    > {
269        AudioDirectionExtProxyInterface::r#set_priority(self, priority)
270    }
271}
272
273impl AudioDirectionExtProxyInterface for AudioDirectionExtProxy {
274    type SetPriorityResponseFut = fidl::client::QueryResponseFut<
275        AudioDirectionExtSetPriorityResult,
276        fidl::encoding::DefaultFuchsiaResourceDialect,
277    >;
278    fn r#set_priority(&self, mut priority: A2dpDirectionPriority) -> Self::SetPriorityResponseFut {
279        fn _decode(
280            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
281        ) -> Result<AudioDirectionExtSetPriorityResult, fidl::Error> {
282            let _response = fidl::client::decode_transaction_body::<
283                fidl::encoding::FlexibleResultType<
284                    fidl::encoding::EmptyStruct,
285                    fidl_fuchsia_bluetooth::ErrorCode,
286                >,
287                fidl::encoding::DefaultFuchsiaResourceDialect,
288                0x792713ef3b2bc38a,
289            >(_buf?)?
290            .into_result::<AudioDirectionExtMarker>("set_priority")?;
291            Ok(_response.map(|x| x))
292        }
293        self.client.send_query_and_decode::<
294            AudioDirectionExtSetPriorityRequest,
295            AudioDirectionExtSetPriorityResult,
296        >(
297            (priority,),
298            0x792713ef3b2bc38a,
299            fidl::encoding::DynamicFlags::FLEXIBLE,
300            _decode,
301        )
302    }
303}
304
305pub struct AudioDirectionExtEventStream {
306    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
307}
308
309impl std::marker::Unpin for AudioDirectionExtEventStream {}
310
311impl futures::stream::FusedStream for AudioDirectionExtEventStream {
312    fn is_terminated(&self) -> bool {
313        self.event_receiver.is_terminated()
314    }
315}
316
317impl futures::Stream for AudioDirectionExtEventStream {
318    type Item = Result<AudioDirectionExtEvent, fidl::Error>;
319
320    fn poll_next(
321        mut self: std::pin::Pin<&mut Self>,
322        cx: &mut std::task::Context<'_>,
323    ) -> std::task::Poll<Option<Self::Item>> {
324        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
325            &mut self.event_receiver,
326            cx
327        )?) {
328            Some(buf) => std::task::Poll::Ready(Some(AudioDirectionExtEvent::decode(buf))),
329            None => std::task::Poll::Ready(None),
330        }
331    }
332}
333
334#[derive(Debug)]
335pub enum AudioDirectionExtEvent {
336    #[non_exhaustive]
337    _UnknownEvent {
338        /// Ordinal of the event that was sent.
339        ordinal: u64,
340    },
341}
342
343impl AudioDirectionExtEvent {
344    /// Decodes a message buffer as a [`AudioDirectionExtEvent`].
345    fn decode(
346        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
347    ) -> Result<AudioDirectionExtEvent, fidl::Error> {
348        let (bytes, _handles) = buf.split_mut();
349        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
350        debug_assert_eq!(tx_header.tx_id, 0);
351        match tx_header.ordinal {
352            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
353                Ok(AudioDirectionExtEvent::_UnknownEvent { ordinal: tx_header.ordinal })
354            }
355            _ => Err(fidl::Error::UnknownOrdinal {
356                ordinal: tx_header.ordinal,
357                protocol_name:
358                    <AudioDirectionExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
359            }),
360        }
361    }
362}
363
364/// A Stream of incoming requests for fuchsia.bluetooth.bredr/AudioDirectionExt.
365pub struct AudioDirectionExtRequestStream {
366    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
367    is_terminated: bool,
368}
369
370impl std::marker::Unpin for AudioDirectionExtRequestStream {}
371
372impl futures::stream::FusedStream for AudioDirectionExtRequestStream {
373    fn is_terminated(&self) -> bool {
374        self.is_terminated
375    }
376}
377
378impl fidl::endpoints::RequestStream for AudioDirectionExtRequestStream {
379    type Protocol = AudioDirectionExtMarker;
380    type ControlHandle = AudioDirectionExtControlHandle;
381
382    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
383        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
384    }
385
386    fn control_handle(&self) -> Self::ControlHandle {
387        AudioDirectionExtControlHandle { inner: self.inner.clone() }
388    }
389
390    fn into_inner(
391        self,
392    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
393    {
394        (self.inner, self.is_terminated)
395    }
396
397    fn from_inner(
398        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
399        is_terminated: bool,
400    ) -> Self {
401        Self { inner, is_terminated }
402    }
403}
404
405impl futures::Stream for AudioDirectionExtRequestStream {
406    type Item = Result<AudioDirectionExtRequest, fidl::Error>;
407
408    fn poll_next(
409        mut self: std::pin::Pin<&mut Self>,
410        cx: &mut std::task::Context<'_>,
411    ) -> std::task::Poll<Option<Self::Item>> {
412        let this = &mut *self;
413        if this.inner.check_shutdown(cx) {
414            this.is_terminated = true;
415            return std::task::Poll::Ready(None);
416        }
417        if this.is_terminated {
418            panic!("polled AudioDirectionExtRequestStream after completion");
419        }
420        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
421            |bytes, handles| {
422                match this.inner.channel().read_etc(cx, bytes, handles) {
423                    std::task::Poll::Ready(Ok(())) => {}
424                    std::task::Poll::Pending => return std::task::Poll::Pending,
425                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
426                        this.is_terminated = true;
427                        return std::task::Poll::Ready(None);
428                    }
429                    std::task::Poll::Ready(Err(e)) => {
430                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
431                            e.into(),
432                        ))))
433                    }
434                }
435
436                // A message has been received from the channel
437                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
438
439                std::task::Poll::Ready(Some(match header.ordinal {
440                    0x792713ef3b2bc38a => {
441                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
442                        let mut req = fidl::new_empty!(
443                            AudioDirectionExtSetPriorityRequest,
444                            fidl::encoding::DefaultFuchsiaResourceDialect
445                        );
446                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDirectionExtSetPriorityRequest>(&header, _body_bytes, handles, &mut req)?;
447                        let control_handle =
448                            AudioDirectionExtControlHandle { inner: this.inner.clone() };
449                        Ok(AudioDirectionExtRequest::SetPriority {
450                            priority: req.priority,
451
452                            responder: AudioDirectionExtSetPriorityResponder {
453                                control_handle: std::mem::ManuallyDrop::new(control_handle),
454                                tx_id: header.tx_id,
455                            },
456                        })
457                    }
458                    _ if header.tx_id == 0
459                        && header
460                            .dynamic_flags()
461                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
462                    {
463                        Ok(AudioDirectionExtRequest::_UnknownMethod {
464                            ordinal: header.ordinal,
465                            control_handle: AudioDirectionExtControlHandle {
466                                inner: this.inner.clone(),
467                            },
468                            method_type: fidl::MethodType::OneWay,
469                        })
470                    }
471                    _ if header
472                        .dynamic_flags()
473                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
474                    {
475                        this.inner.send_framework_err(
476                            fidl::encoding::FrameworkErr::UnknownMethod,
477                            header.tx_id,
478                            header.ordinal,
479                            header.dynamic_flags(),
480                            (bytes, handles),
481                        )?;
482                        Ok(AudioDirectionExtRequest::_UnknownMethod {
483                            ordinal: header.ordinal,
484                            control_handle: AudioDirectionExtControlHandle {
485                                inner: this.inner.clone(),
486                            },
487                            method_type: fidl::MethodType::TwoWay,
488                        })
489                    }
490                    _ => Err(fidl::Error::UnknownOrdinal {
491                        ordinal: header.ordinal,
492                        protocol_name:
493                            <AudioDirectionExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
494                    }),
495                }))
496            },
497        )
498    }
499}
500
501/// Audio Priority Direction extension. Used to put the channel in a mode where A2DP packets are
502/// prioritized over other packets in the source or sink direction.
503#[derive(Debug)]
504pub enum AudioDirectionExtRequest {
505    SetPriority {
506        priority: A2dpDirectionPriority,
507        responder: AudioDirectionExtSetPriorityResponder,
508    },
509    /// An interaction was received which does not match any known method.
510    #[non_exhaustive]
511    _UnknownMethod {
512        /// Ordinal of the method that was called.
513        ordinal: u64,
514        control_handle: AudioDirectionExtControlHandle,
515        method_type: fidl::MethodType,
516    },
517}
518
519impl AudioDirectionExtRequest {
520    #[allow(irrefutable_let_patterns)]
521    pub fn into_set_priority(
522        self,
523    ) -> Option<(A2dpDirectionPriority, AudioDirectionExtSetPriorityResponder)> {
524        if let AudioDirectionExtRequest::SetPriority { priority, responder } = self {
525            Some((priority, responder))
526        } else {
527            None
528        }
529    }
530
531    /// Name of the method defined in FIDL
532    pub fn method_name(&self) -> &'static str {
533        match *self {
534            AudioDirectionExtRequest::SetPriority { .. } => "set_priority",
535            AudioDirectionExtRequest::_UnknownMethod {
536                method_type: fidl::MethodType::OneWay,
537                ..
538            } => "unknown one-way method",
539            AudioDirectionExtRequest::_UnknownMethod {
540                method_type: fidl::MethodType::TwoWay,
541                ..
542            } => "unknown two-way method",
543        }
544    }
545}
546
547#[derive(Debug, Clone)]
548pub struct AudioDirectionExtControlHandle {
549    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
550}
551
552impl fidl::endpoints::ControlHandle for AudioDirectionExtControlHandle {
553    fn shutdown(&self) {
554        self.inner.shutdown()
555    }
556    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
557        self.inner.shutdown_with_epitaph(status)
558    }
559
560    fn is_closed(&self) -> bool {
561        self.inner.channel().is_closed()
562    }
563    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
564        self.inner.channel().on_closed()
565    }
566
567    #[cfg(target_os = "fuchsia")]
568    fn signal_peer(
569        &self,
570        clear_mask: zx::Signals,
571        set_mask: zx::Signals,
572    ) -> Result<(), zx_status::Status> {
573        use fidl::Peered;
574        self.inner.channel().signal_peer(clear_mask, set_mask)
575    }
576}
577
578impl AudioDirectionExtControlHandle {}
579
580#[must_use = "FIDL methods require a response to be sent"]
581#[derive(Debug)]
582pub struct AudioDirectionExtSetPriorityResponder {
583    control_handle: std::mem::ManuallyDrop<AudioDirectionExtControlHandle>,
584    tx_id: u32,
585}
586
587/// Set the the channel to be shutdown (see [`AudioDirectionExtControlHandle::shutdown`])
588/// if the responder is dropped without sending a response, so that the client
589/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
590impl std::ops::Drop for AudioDirectionExtSetPriorityResponder {
591    fn drop(&mut self) {
592        self.control_handle.shutdown();
593        // Safety: drops once, never accessed again
594        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
595    }
596}
597
598impl fidl::endpoints::Responder for AudioDirectionExtSetPriorityResponder {
599    type ControlHandle = AudioDirectionExtControlHandle;
600
601    fn control_handle(&self) -> &AudioDirectionExtControlHandle {
602        &self.control_handle
603    }
604
605    fn drop_without_shutdown(mut self) {
606        // Safety: drops once, never accessed again due to mem::forget
607        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
608        // Prevent Drop from running (which would shut down the channel)
609        std::mem::forget(self);
610    }
611}
612
613impl AudioDirectionExtSetPriorityResponder {
614    /// Sends a response to the FIDL transaction.
615    ///
616    /// Sets the channel to shutdown if an error occurs.
617    pub fn send(
618        self,
619        mut result: Result<(), fidl_fuchsia_bluetooth::ErrorCode>,
620    ) -> Result<(), fidl::Error> {
621        let _result = self.send_raw(result);
622        if _result.is_err() {
623            self.control_handle.shutdown();
624        }
625        self.drop_without_shutdown();
626        _result
627    }
628
629    /// Similar to "send" but does not shutdown the channel if an error occurs.
630    pub fn send_no_shutdown_on_err(
631        self,
632        mut result: Result<(), fidl_fuchsia_bluetooth::ErrorCode>,
633    ) -> Result<(), fidl::Error> {
634        let _result = self.send_raw(result);
635        self.drop_without_shutdown();
636        _result
637    }
638
639    fn send_raw(
640        &self,
641        mut result: Result<(), fidl_fuchsia_bluetooth::ErrorCode>,
642    ) -> Result<(), fidl::Error> {
643        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
644            fidl::encoding::EmptyStruct,
645            fidl_fuchsia_bluetooth::ErrorCode,
646        >>(
647            fidl::encoding::FlexibleResult::new(result),
648            self.tx_id,
649            0x792713ef3b2bc38a,
650            fidl::encoding::DynamicFlags::FLEXIBLE,
651        )
652    }
653}
654
655#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
656pub struct AudioOffloadControllerMarker;
657
658impl fidl::endpoints::ProtocolMarker for AudioOffloadControllerMarker {
659    type Proxy = AudioOffloadControllerProxy;
660    type RequestStream = AudioOffloadControllerRequestStream;
661    #[cfg(target_os = "fuchsia")]
662    type SynchronousProxy = AudioOffloadControllerSynchronousProxy;
663
664    const DEBUG_NAME: &'static str = "(anonymous) AudioOffloadController";
665}
666
667pub trait AudioOffloadControllerProxyInterface: Send + Sync {
668    type StopResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
669    fn r#stop(&self) -> Self::StopResponseFut;
670}
671#[derive(Debug)]
672#[cfg(target_os = "fuchsia")]
673pub struct AudioOffloadControllerSynchronousProxy {
674    client: fidl::client::sync::Client,
675}
676
677#[cfg(target_os = "fuchsia")]
678impl fidl::endpoints::SynchronousProxy for AudioOffloadControllerSynchronousProxy {
679    type Proxy = AudioOffloadControllerProxy;
680    type Protocol = AudioOffloadControllerMarker;
681
682    fn from_channel(inner: fidl::Channel) -> Self {
683        Self::new(inner)
684    }
685
686    fn into_channel(self) -> fidl::Channel {
687        self.client.into_channel()
688    }
689
690    fn as_channel(&self) -> &fidl::Channel {
691        self.client.as_channel()
692    }
693}
694
695#[cfg(target_os = "fuchsia")]
696impl AudioOffloadControllerSynchronousProxy {
697    pub fn new(channel: fidl::Channel) -> Self {
698        let protocol_name =
699            <AudioOffloadControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
700        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
701    }
702
703    pub fn into_channel(self) -> fidl::Channel {
704        self.client.into_channel()
705    }
706
707    /// Waits until an event arrives and returns it. It is safe for other
708    /// threads to make concurrent requests while waiting for an event.
709    pub fn wait_for_event(
710        &self,
711        deadline: zx::MonotonicInstant,
712    ) -> Result<AudioOffloadControllerEvent, fidl::Error> {
713        AudioOffloadControllerEvent::decode(self.client.wait_for_event(deadline)?)
714    }
715
716    /// Request the audio offloading be stopped.
717    /// This call will be responded to before the protocol is closed on the server side.
718    pub fn r#stop(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
719        let _response = self.client.send_query::<
720            fidl::encoding::EmptyPayload,
721            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
722        >(
723            (),
724            0x37845d5a47ce5e39,
725            fidl::encoding::DynamicFlags::FLEXIBLE,
726            ___deadline,
727        )?
728        .into_result::<AudioOffloadControllerMarker>("stop")?;
729        Ok(_response)
730    }
731}
732
733#[cfg(target_os = "fuchsia")]
734impl From<AudioOffloadControllerSynchronousProxy> for zx::Handle {
735    fn from(value: AudioOffloadControllerSynchronousProxy) -> Self {
736        value.into_channel().into()
737    }
738}
739
740#[cfg(target_os = "fuchsia")]
741impl From<fidl::Channel> for AudioOffloadControllerSynchronousProxy {
742    fn from(value: fidl::Channel) -> Self {
743        Self::new(value)
744    }
745}
746
747#[derive(Debug, Clone)]
748pub struct AudioOffloadControllerProxy {
749    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
750}
751
752impl fidl::endpoints::Proxy for AudioOffloadControllerProxy {
753    type Protocol = AudioOffloadControllerMarker;
754
755    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
756        Self::new(inner)
757    }
758
759    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
760        self.client.into_channel().map_err(|client| Self { client })
761    }
762
763    fn as_channel(&self) -> &::fidl::AsyncChannel {
764        self.client.as_channel()
765    }
766}
767
768impl AudioOffloadControllerProxy {
769    /// Create a new Proxy for fuchsia.bluetooth.bredr/AudioOffloadController.
770    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
771        let protocol_name =
772            <AudioOffloadControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
773        Self { client: fidl::client::Client::new(channel, protocol_name) }
774    }
775
776    /// Get a Stream of events from the remote end of the protocol.
777    ///
778    /// # Panics
779    ///
780    /// Panics if the event stream was already taken.
781    pub fn take_event_stream(&self) -> AudioOffloadControllerEventStream {
782        AudioOffloadControllerEventStream { event_receiver: self.client.take_event_receiver() }
783    }
784
785    /// Request the audio offloading be stopped.
786    /// This call will be responded to before the protocol is closed on the server side.
787    pub fn r#stop(
788        &self,
789    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
790        AudioOffloadControllerProxyInterface::r#stop(self)
791    }
792}
793
794impl AudioOffloadControllerProxyInterface for AudioOffloadControllerProxy {
795    type StopResponseFut =
796        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
797    fn r#stop(&self) -> Self::StopResponseFut {
798        fn _decode(
799            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
800        ) -> Result<(), fidl::Error> {
801            let _response = fidl::client::decode_transaction_body::<
802                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
803                fidl::encoding::DefaultFuchsiaResourceDialect,
804                0x37845d5a47ce5e39,
805            >(_buf?)?
806            .into_result::<AudioOffloadControllerMarker>("stop")?;
807            Ok(_response)
808        }
809        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
810            (),
811            0x37845d5a47ce5e39,
812            fidl::encoding::DynamicFlags::FLEXIBLE,
813            _decode,
814        )
815    }
816}
817
818pub struct AudioOffloadControllerEventStream {
819    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
820}
821
822impl std::marker::Unpin for AudioOffloadControllerEventStream {}
823
824impl futures::stream::FusedStream for AudioOffloadControllerEventStream {
825    fn is_terminated(&self) -> bool {
826        self.event_receiver.is_terminated()
827    }
828}
829
830impl futures::Stream for AudioOffloadControllerEventStream {
831    type Item = Result<AudioOffloadControllerEvent, fidl::Error>;
832
833    fn poll_next(
834        mut self: std::pin::Pin<&mut Self>,
835        cx: &mut std::task::Context<'_>,
836    ) -> std::task::Poll<Option<Self::Item>> {
837        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
838            &mut self.event_receiver,
839            cx
840        )?) {
841            Some(buf) => std::task::Poll::Ready(Some(AudioOffloadControllerEvent::decode(buf))),
842            None => std::task::Poll::Ready(None),
843        }
844    }
845}
846
847#[derive(Debug)]
848pub enum AudioOffloadControllerEvent {
849    OnStarted {},
850    #[non_exhaustive]
851    _UnknownEvent {
852        /// Ordinal of the event that was sent.
853        ordinal: u64,
854    },
855}
856
857impl AudioOffloadControllerEvent {
858    #[allow(irrefutable_let_patterns)]
859    pub fn into_on_started(self) -> Option<()> {
860        if let AudioOffloadControllerEvent::OnStarted {} = self {
861            Some(())
862        } else {
863            None
864        }
865    }
866
867    /// Decodes a message buffer as a [`AudioOffloadControllerEvent`].
868    fn decode(
869        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
870    ) -> Result<AudioOffloadControllerEvent, fidl::Error> {
871        let (bytes, _handles) = buf.split_mut();
872        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
873        debug_assert_eq!(tx_header.tx_id, 0);
874        match tx_header.ordinal {
875            0x7b624f210570fc30 => {
876                let mut out = fidl::new_empty!(
877                    fidl::encoding::EmptyPayload,
878                    fidl::encoding::DefaultFuchsiaResourceDialect
879                );
880                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
881                Ok((AudioOffloadControllerEvent::OnStarted {}))
882            }
883            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
884                Ok(AudioOffloadControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
885            }
886            _ => Err(fidl::Error::UnknownOrdinal {
887                ordinal: tx_header.ordinal,
888                protocol_name:
889                    <AudioOffloadControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
890            }),
891        }
892    }
893}
894
895/// A Stream of incoming requests for fuchsia.bluetooth.bredr/AudioOffloadController.
896pub struct AudioOffloadControllerRequestStream {
897    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
898    is_terminated: bool,
899}
900
901impl std::marker::Unpin for AudioOffloadControllerRequestStream {}
902
903impl futures::stream::FusedStream for AudioOffloadControllerRequestStream {
904    fn is_terminated(&self) -> bool {
905        self.is_terminated
906    }
907}
908
909impl fidl::endpoints::RequestStream for AudioOffloadControllerRequestStream {
910    type Protocol = AudioOffloadControllerMarker;
911    type ControlHandle = AudioOffloadControllerControlHandle;
912
913    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
914        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
915    }
916
917    fn control_handle(&self) -> Self::ControlHandle {
918        AudioOffloadControllerControlHandle { inner: self.inner.clone() }
919    }
920
921    fn into_inner(
922        self,
923    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
924    {
925        (self.inner, self.is_terminated)
926    }
927
928    fn from_inner(
929        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
930        is_terminated: bool,
931    ) -> Self {
932        Self { inner, is_terminated }
933    }
934}
935
936impl futures::Stream for AudioOffloadControllerRequestStream {
937    type Item = Result<AudioOffloadControllerRequest, fidl::Error>;
938
939    fn poll_next(
940        mut self: std::pin::Pin<&mut Self>,
941        cx: &mut std::task::Context<'_>,
942    ) -> std::task::Poll<Option<Self::Item>> {
943        let this = &mut *self;
944        if this.inner.check_shutdown(cx) {
945            this.is_terminated = true;
946            return std::task::Poll::Ready(None);
947        }
948        if this.is_terminated {
949            panic!("polled AudioOffloadControllerRequestStream after completion");
950        }
951        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
952            |bytes, handles| {
953                match this.inner.channel().read_etc(cx, bytes, handles) {
954                    std::task::Poll::Ready(Ok(())) => {}
955                    std::task::Poll::Pending => return std::task::Poll::Pending,
956                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
957                        this.is_terminated = true;
958                        return std::task::Poll::Ready(None);
959                    }
960                    std::task::Poll::Ready(Err(e)) => {
961                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
962                            e.into(),
963                        ))))
964                    }
965                }
966
967                // A message has been received from the channel
968                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
969
970                std::task::Poll::Ready(Some(match header.ordinal {
971                0x37845d5a47ce5e39 => {
972                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
973                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
974                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
975                    let control_handle = AudioOffloadControllerControlHandle {
976                        inner: this.inner.clone(),
977                    };
978                    Ok(AudioOffloadControllerRequest::Stop {
979                        responder: AudioOffloadControllerStopResponder {
980                            control_handle: std::mem::ManuallyDrop::new(control_handle),
981                            tx_id: header.tx_id,
982                        },
983                    })
984                }
985                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
986                    Ok(AudioOffloadControllerRequest::_UnknownMethod {
987                        ordinal: header.ordinal,
988                        control_handle: AudioOffloadControllerControlHandle { inner: this.inner.clone() },
989                        method_type: fidl::MethodType::OneWay,
990                    })
991                }
992                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
993                    this.inner.send_framework_err(
994                        fidl::encoding::FrameworkErr::UnknownMethod,
995                        header.tx_id,
996                        header.ordinal,
997                        header.dynamic_flags(),
998                        (bytes, handles),
999                    )?;
1000                    Ok(AudioOffloadControllerRequest::_UnknownMethod {
1001                        ordinal: header.ordinal,
1002                        control_handle: AudioOffloadControllerControlHandle { inner: this.inner.clone() },
1003                        method_type: fidl::MethodType::TwoWay,
1004                    })
1005                }
1006                _ => Err(fidl::Error::UnknownOrdinal {
1007                    ordinal: header.ordinal,
1008                    protocol_name: <AudioOffloadControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1009                }),
1010            }))
1011            },
1012        )
1013    }
1014}
1015
1016/// Protocol representing the controller actively encoding offloaded audio to or from this channel.
1017/// Closing the protocol will stop the encoding, which can also be done using the Stop() if
1018/// synchronization is required. If the controller fails to start audio offloading, an epitaph will
1019/// be sent when this is closed.
1020///
1021/// This channel will be closed with a `ZX_ERR_NOT_SUPPORTED` epitaph if the audio offload
1022/// configuration for the controller is not supported.
1023///
1024/// This channel will be closed with a `ZX_ERR_UNAVAILABLE` epitaph if the controller sends an
1025/// error.
1026///
1027/// This channel will be closed with a `ZX_ERR_ALREADY_BOUND` epitaph if audio offloading starting
1028/// or stopping is already in progress/complete on another channel.
1029///
1030/// This channel will be closed with a `ZX_ERR_INTERNAL` epitaph if commands are issued when audio
1031/// offloading is not started.
1032#[derive(Debug)]
1033pub enum AudioOffloadControllerRequest {
1034    /// Request the audio offloading be stopped.
1035    /// This call will be responded to before the protocol is closed on the server side.
1036    Stop { responder: AudioOffloadControllerStopResponder },
1037    /// An interaction was received which does not match any known method.
1038    #[non_exhaustive]
1039    _UnknownMethod {
1040        /// Ordinal of the method that was called.
1041        ordinal: u64,
1042        control_handle: AudioOffloadControllerControlHandle,
1043        method_type: fidl::MethodType,
1044    },
1045}
1046
1047impl AudioOffloadControllerRequest {
1048    #[allow(irrefutable_let_patterns)]
1049    pub fn into_stop(self) -> Option<(AudioOffloadControllerStopResponder)> {
1050        if let AudioOffloadControllerRequest::Stop { responder } = self {
1051            Some((responder))
1052        } else {
1053            None
1054        }
1055    }
1056
1057    /// Name of the method defined in FIDL
1058    pub fn method_name(&self) -> &'static str {
1059        match *self {
1060            AudioOffloadControllerRequest::Stop { .. } => "stop",
1061            AudioOffloadControllerRequest::_UnknownMethod {
1062                method_type: fidl::MethodType::OneWay,
1063                ..
1064            } => "unknown one-way method",
1065            AudioOffloadControllerRequest::_UnknownMethod {
1066                method_type: fidl::MethodType::TwoWay,
1067                ..
1068            } => "unknown two-way method",
1069        }
1070    }
1071}
1072
1073#[derive(Debug, Clone)]
1074pub struct AudioOffloadControllerControlHandle {
1075    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1076}
1077
1078impl fidl::endpoints::ControlHandle for AudioOffloadControllerControlHandle {
1079    fn shutdown(&self) {
1080        self.inner.shutdown()
1081    }
1082    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1083        self.inner.shutdown_with_epitaph(status)
1084    }
1085
1086    fn is_closed(&self) -> bool {
1087        self.inner.channel().is_closed()
1088    }
1089    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1090        self.inner.channel().on_closed()
1091    }
1092
1093    #[cfg(target_os = "fuchsia")]
1094    fn signal_peer(
1095        &self,
1096        clear_mask: zx::Signals,
1097        set_mask: zx::Signals,
1098    ) -> Result<(), zx_status::Status> {
1099        use fidl::Peered;
1100        self.inner.channel().signal_peer(clear_mask, set_mask)
1101    }
1102}
1103
1104impl AudioOffloadControllerControlHandle {
1105    pub fn send_on_started(&self) -> Result<(), fidl::Error> {
1106        self.inner.send::<fidl::encoding::EmptyPayload>(
1107            (),
1108            0,
1109            0x7b624f210570fc30,
1110            fidl::encoding::DynamicFlags::FLEXIBLE,
1111        )
1112    }
1113}
1114
1115#[must_use = "FIDL methods require a response to be sent"]
1116#[derive(Debug)]
1117pub struct AudioOffloadControllerStopResponder {
1118    control_handle: std::mem::ManuallyDrop<AudioOffloadControllerControlHandle>,
1119    tx_id: u32,
1120}
1121
1122/// Set the the channel to be shutdown (see [`AudioOffloadControllerControlHandle::shutdown`])
1123/// if the responder is dropped without sending a response, so that the client
1124/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1125impl std::ops::Drop for AudioOffloadControllerStopResponder {
1126    fn drop(&mut self) {
1127        self.control_handle.shutdown();
1128        // Safety: drops once, never accessed again
1129        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1130    }
1131}
1132
1133impl fidl::endpoints::Responder for AudioOffloadControllerStopResponder {
1134    type ControlHandle = AudioOffloadControllerControlHandle;
1135
1136    fn control_handle(&self) -> &AudioOffloadControllerControlHandle {
1137        &self.control_handle
1138    }
1139
1140    fn drop_without_shutdown(mut self) {
1141        // Safety: drops once, never accessed again due to mem::forget
1142        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1143        // Prevent Drop from running (which would shut down the channel)
1144        std::mem::forget(self);
1145    }
1146}
1147
1148impl AudioOffloadControllerStopResponder {
1149    /// Sends a response to the FIDL transaction.
1150    ///
1151    /// Sets the channel to shutdown if an error occurs.
1152    pub fn send(self) -> Result<(), fidl::Error> {
1153        let _result = self.send_raw();
1154        if _result.is_err() {
1155            self.control_handle.shutdown();
1156        }
1157        self.drop_without_shutdown();
1158        _result
1159    }
1160
1161    /// Similar to "send" but does not shutdown the channel if an error occurs.
1162    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1163        let _result = self.send_raw();
1164        self.drop_without_shutdown();
1165        _result
1166    }
1167
1168    fn send_raw(&self) -> Result<(), fidl::Error> {
1169        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
1170            fidl::encoding::Flexible::new(()),
1171            self.tx_id,
1172            0x37845d5a47ce5e39,
1173            fidl::encoding::DynamicFlags::FLEXIBLE,
1174        )
1175    }
1176}
1177
1178#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1179pub struct AudioOffloadExtMarker;
1180
1181impl fidl::endpoints::ProtocolMarker for AudioOffloadExtMarker {
1182    type Proxy = AudioOffloadExtProxy;
1183    type RequestStream = AudioOffloadExtRequestStream;
1184    #[cfg(target_os = "fuchsia")]
1185    type SynchronousProxy = AudioOffloadExtSynchronousProxy;
1186
1187    const DEBUG_NAME: &'static str = "(anonymous) AudioOffloadExt";
1188}
1189
1190pub trait AudioOffloadExtProxyInterface: Send + Sync {
1191    type GetSupportedFeaturesResponseFut: std::future::Future<
1192            Output = Result<AudioOffloadExtGetSupportedFeaturesResponse, fidl::Error>,
1193        > + Send;
1194    fn r#get_supported_features(&self) -> Self::GetSupportedFeaturesResponseFut;
1195    fn r#start_audio_offload(
1196        &self,
1197        configuration: &AudioOffloadConfiguration,
1198        controller: fidl::endpoints::ServerEnd<AudioOffloadControllerMarker>,
1199    ) -> Result<(), fidl::Error>;
1200}
1201#[derive(Debug)]
1202#[cfg(target_os = "fuchsia")]
1203pub struct AudioOffloadExtSynchronousProxy {
1204    client: fidl::client::sync::Client,
1205}
1206
1207#[cfg(target_os = "fuchsia")]
1208impl fidl::endpoints::SynchronousProxy for AudioOffloadExtSynchronousProxy {
1209    type Proxy = AudioOffloadExtProxy;
1210    type Protocol = AudioOffloadExtMarker;
1211
1212    fn from_channel(inner: fidl::Channel) -> Self {
1213        Self::new(inner)
1214    }
1215
1216    fn into_channel(self) -> fidl::Channel {
1217        self.client.into_channel()
1218    }
1219
1220    fn as_channel(&self) -> &fidl::Channel {
1221        self.client.as_channel()
1222    }
1223}
1224
1225#[cfg(target_os = "fuchsia")]
1226impl AudioOffloadExtSynchronousProxy {
1227    pub fn new(channel: fidl::Channel) -> Self {
1228        let protocol_name = <AudioOffloadExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1229        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1230    }
1231
1232    pub fn into_channel(self) -> fidl::Channel {
1233        self.client.into_channel()
1234    }
1235
1236    /// Waits until an event arrives and returns it. It is safe for other
1237    /// threads to make concurrent requests while waiting for an event.
1238    pub fn wait_for_event(
1239        &self,
1240        deadline: zx::MonotonicInstant,
1241    ) -> Result<AudioOffloadExtEvent, fidl::Error> {
1242        AudioOffloadExtEvent::decode(self.client.wait_for_event(deadline)?)
1243    }
1244
1245    /// Returns the vendor features supported on this chipset
1246    pub fn r#get_supported_features(
1247        &self,
1248        ___deadline: zx::MonotonicInstant,
1249    ) -> Result<AudioOffloadExtGetSupportedFeaturesResponse, fidl::Error> {
1250        let _response = self.client.send_query::<
1251            fidl::encoding::EmptyPayload,
1252            fidl::encoding::FlexibleType<AudioOffloadExtGetSupportedFeaturesResponse>,
1253        >(
1254            (),
1255            0x44ab0b88dde41f94,
1256            fidl::encoding::DynamicFlags::FLEXIBLE,
1257            ___deadline,
1258        )?
1259        .into_result::<AudioOffloadExtMarker>("get_supported_features")?;
1260        Ok(_response)
1261    }
1262
1263    /// Begin the audio encoding hardware offloading process
1264    pub fn r#start_audio_offload(
1265        &self,
1266        mut configuration: &AudioOffloadConfiguration,
1267        mut controller: fidl::endpoints::ServerEnd<AudioOffloadControllerMarker>,
1268    ) -> Result<(), fidl::Error> {
1269        self.client.send::<AudioOffloadExtStartAudioOffloadRequest>(
1270            (configuration, controller),
1271            0x2172ac626202c1c9,
1272            fidl::encoding::DynamicFlags::FLEXIBLE,
1273        )
1274    }
1275}
1276
1277#[cfg(target_os = "fuchsia")]
1278impl From<AudioOffloadExtSynchronousProxy> for zx::Handle {
1279    fn from(value: AudioOffloadExtSynchronousProxy) -> Self {
1280        value.into_channel().into()
1281    }
1282}
1283
1284#[cfg(target_os = "fuchsia")]
1285impl From<fidl::Channel> for AudioOffloadExtSynchronousProxy {
1286    fn from(value: fidl::Channel) -> Self {
1287        Self::new(value)
1288    }
1289}
1290
1291#[derive(Debug, Clone)]
1292pub struct AudioOffloadExtProxy {
1293    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1294}
1295
1296impl fidl::endpoints::Proxy for AudioOffloadExtProxy {
1297    type Protocol = AudioOffloadExtMarker;
1298
1299    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1300        Self::new(inner)
1301    }
1302
1303    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1304        self.client.into_channel().map_err(|client| Self { client })
1305    }
1306
1307    fn as_channel(&self) -> &::fidl::AsyncChannel {
1308        self.client.as_channel()
1309    }
1310}
1311
1312impl AudioOffloadExtProxy {
1313    /// Create a new Proxy for fuchsia.bluetooth.bredr/AudioOffloadExt.
1314    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1315        let protocol_name = <AudioOffloadExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1316        Self { client: fidl::client::Client::new(channel, protocol_name) }
1317    }
1318
1319    /// Get a Stream of events from the remote end of the protocol.
1320    ///
1321    /// # Panics
1322    ///
1323    /// Panics if the event stream was already taken.
1324    pub fn take_event_stream(&self) -> AudioOffloadExtEventStream {
1325        AudioOffloadExtEventStream { event_receiver: self.client.take_event_receiver() }
1326    }
1327
1328    /// Returns the vendor features supported on this chipset
1329    pub fn r#get_supported_features(
1330        &self,
1331    ) -> fidl::client::QueryResponseFut<
1332        AudioOffloadExtGetSupportedFeaturesResponse,
1333        fidl::encoding::DefaultFuchsiaResourceDialect,
1334    > {
1335        AudioOffloadExtProxyInterface::r#get_supported_features(self)
1336    }
1337
1338    /// Begin the audio encoding hardware offloading process
1339    pub fn r#start_audio_offload(
1340        &self,
1341        mut configuration: &AudioOffloadConfiguration,
1342        mut controller: fidl::endpoints::ServerEnd<AudioOffloadControllerMarker>,
1343    ) -> Result<(), fidl::Error> {
1344        AudioOffloadExtProxyInterface::r#start_audio_offload(self, configuration, controller)
1345    }
1346}
1347
1348impl AudioOffloadExtProxyInterface for AudioOffloadExtProxy {
1349    type GetSupportedFeaturesResponseFut = fidl::client::QueryResponseFut<
1350        AudioOffloadExtGetSupportedFeaturesResponse,
1351        fidl::encoding::DefaultFuchsiaResourceDialect,
1352    >;
1353    fn r#get_supported_features(&self) -> Self::GetSupportedFeaturesResponseFut {
1354        fn _decode(
1355            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1356        ) -> Result<AudioOffloadExtGetSupportedFeaturesResponse, fidl::Error> {
1357            let _response = fidl::client::decode_transaction_body::<
1358                fidl::encoding::FlexibleType<AudioOffloadExtGetSupportedFeaturesResponse>,
1359                fidl::encoding::DefaultFuchsiaResourceDialect,
1360                0x44ab0b88dde41f94,
1361            >(_buf?)?
1362            .into_result::<AudioOffloadExtMarker>("get_supported_features")?;
1363            Ok(_response)
1364        }
1365        self.client.send_query_and_decode::<
1366            fidl::encoding::EmptyPayload,
1367            AudioOffloadExtGetSupportedFeaturesResponse,
1368        >(
1369            (),
1370            0x44ab0b88dde41f94,
1371            fidl::encoding::DynamicFlags::FLEXIBLE,
1372            _decode,
1373        )
1374    }
1375
1376    fn r#start_audio_offload(
1377        &self,
1378        mut configuration: &AudioOffloadConfiguration,
1379        mut controller: fidl::endpoints::ServerEnd<AudioOffloadControllerMarker>,
1380    ) -> Result<(), fidl::Error> {
1381        self.client.send::<AudioOffloadExtStartAudioOffloadRequest>(
1382            (configuration, controller),
1383            0x2172ac626202c1c9,
1384            fidl::encoding::DynamicFlags::FLEXIBLE,
1385        )
1386    }
1387}
1388
1389pub struct AudioOffloadExtEventStream {
1390    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1391}
1392
1393impl std::marker::Unpin for AudioOffloadExtEventStream {}
1394
1395impl futures::stream::FusedStream for AudioOffloadExtEventStream {
1396    fn is_terminated(&self) -> bool {
1397        self.event_receiver.is_terminated()
1398    }
1399}
1400
1401impl futures::Stream for AudioOffloadExtEventStream {
1402    type Item = Result<AudioOffloadExtEvent, fidl::Error>;
1403
1404    fn poll_next(
1405        mut self: std::pin::Pin<&mut Self>,
1406        cx: &mut std::task::Context<'_>,
1407    ) -> std::task::Poll<Option<Self::Item>> {
1408        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1409            &mut self.event_receiver,
1410            cx
1411        )?) {
1412            Some(buf) => std::task::Poll::Ready(Some(AudioOffloadExtEvent::decode(buf))),
1413            None => std::task::Poll::Ready(None),
1414        }
1415    }
1416}
1417
1418#[derive(Debug)]
1419pub enum AudioOffloadExtEvent {
1420    #[non_exhaustive]
1421    _UnknownEvent {
1422        /// Ordinal of the event that was sent.
1423        ordinal: u64,
1424    },
1425}
1426
1427impl AudioOffloadExtEvent {
1428    /// Decodes a message buffer as a [`AudioOffloadExtEvent`].
1429    fn decode(
1430        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1431    ) -> Result<AudioOffloadExtEvent, fidl::Error> {
1432        let (bytes, _handles) = buf.split_mut();
1433        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1434        debug_assert_eq!(tx_header.tx_id, 0);
1435        match tx_header.ordinal {
1436            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1437                Ok(AudioOffloadExtEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1438            }
1439            _ => Err(fidl::Error::UnknownOrdinal {
1440                ordinal: tx_header.ordinal,
1441                protocol_name:
1442                    <AudioOffloadExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1443            }),
1444        }
1445    }
1446}
1447
1448/// A Stream of incoming requests for fuchsia.bluetooth.bredr/AudioOffloadExt.
1449pub struct AudioOffloadExtRequestStream {
1450    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1451    is_terminated: bool,
1452}
1453
1454impl std::marker::Unpin for AudioOffloadExtRequestStream {}
1455
1456impl futures::stream::FusedStream for AudioOffloadExtRequestStream {
1457    fn is_terminated(&self) -> bool {
1458        self.is_terminated
1459    }
1460}
1461
1462impl fidl::endpoints::RequestStream for AudioOffloadExtRequestStream {
1463    type Protocol = AudioOffloadExtMarker;
1464    type ControlHandle = AudioOffloadExtControlHandle;
1465
1466    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1467        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1468    }
1469
1470    fn control_handle(&self) -> Self::ControlHandle {
1471        AudioOffloadExtControlHandle { inner: self.inner.clone() }
1472    }
1473
1474    fn into_inner(
1475        self,
1476    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1477    {
1478        (self.inner, self.is_terminated)
1479    }
1480
1481    fn from_inner(
1482        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1483        is_terminated: bool,
1484    ) -> Self {
1485        Self { inner, is_terminated }
1486    }
1487}
1488
1489impl futures::Stream for AudioOffloadExtRequestStream {
1490    type Item = Result<AudioOffloadExtRequest, fidl::Error>;
1491
1492    fn poll_next(
1493        mut self: std::pin::Pin<&mut Self>,
1494        cx: &mut std::task::Context<'_>,
1495    ) -> std::task::Poll<Option<Self::Item>> {
1496        let this = &mut *self;
1497        if this.inner.check_shutdown(cx) {
1498            this.is_terminated = true;
1499            return std::task::Poll::Ready(None);
1500        }
1501        if this.is_terminated {
1502            panic!("polled AudioOffloadExtRequestStream after completion");
1503        }
1504        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1505            |bytes, handles| {
1506                match this.inner.channel().read_etc(cx, bytes, handles) {
1507                    std::task::Poll::Ready(Ok(())) => {}
1508                    std::task::Poll::Pending => return std::task::Poll::Pending,
1509                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1510                        this.is_terminated = true;
1511                        return std::task::Poll::Ready(None);
1512                    }
1513                    std::task::Poll::Ready(Err(e)) => {
1514                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1515                            e.into(),
1516                        ))))
1517                    }
1518                }
1519
1520                // A message has been received from the channel
1521                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1522
1523                std::task::Poll::Ready(Some(match header.ordinal {
1524                    0x44ab0b88dde41f94 => {
1525                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1526                        let mut req = fidl::new_empty!(
1527                            fidl::encoding::EmptyPayload,
1528                            fidl::encoding::DefaultFuchsiaResourceDialect
1529                        );
1530                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1531                        let control_handle =
1532                            AudioOffloadExtControlHandle { inner: this.inner.clone() };
1533                        Ok(AudioOffloadExtRequest::GetSupportedFeatures {
1534                            responder: AudioOffloadExtGetSupportedFeaturesResponder {
1535                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1536                                tx_id: header.tx_id,
1537                            },
1538                        })
1539                    }
1540                    0x2172ac626202c1c9 => {
1541                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1542                        let mut req = fidl::new_empty!(
1543                            AudioOffloadExtStartAudioOffloadRequest,
1544                            fidl::encoding::DefaultFuchsiaResourceDialect
1545                        );
1546                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioOffloadExtStartAudioOffloadRequest>(&header, _body_bytes, handles, &mut req)?;
1547                        let control_handle =
1548                            AudioOffloadExtControlHandle { inner: this.inner.clone() };
1549                        Ok(AudioOffloadExtRequest::StartAudioOffload {
1550                            configuration: req.configuration,
1551                            controller: req.controller,
1552
1553                            control_handle,
1554                        })
1555                    }
1556                    _ if header.tx_id == 0
1557                        && header
1558                            .dynamic_flags()
1559                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1560                    {
1561                        Ok(AudioOffloadExtRequest::_UnknownMethod {
1562                            ordinal: header.ordinal,
1563                            control_handle: AudioOffloadExtControlHandle {
1564                                inner: this.inner.clone(),
1565                            },
1566                            method_type: fidl::MethodType::OneWay,
1567                        })
1568                    }
1569                    _ if header
1570                        .dynamic_flags()
1571                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1572                    {
1573                        this.inner.send_framework_err(
1574                            fidl::encoding::FrameworkErr::UnknownMethod,
1575                            header.tx_id,
1576                            header.ordinal,
1577                            header.dynamic_flags(),
1578                            (bytes, handles),
1579                        )?;
1580                        Ok(AudioOffloadExtRequest::_UnknownMethod {
1581                            ordinal: header.ordinal,
1582                            control_handle: AudioOffloadExtControlHandle {
1583                                inner: this.inner.clone(),
1584                            },
1585                            method_type: fidl::MethodType::TwoWay,
1586                        })
1587                    }
1588                    _ => Err(fidl::Error::UnknownOrdinal {
1589                        ordinal: header.ordinal,
1590                        protocol_name:
1591                            <AudioOffloadExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1592                    }),
1593                }))
1594            },
1595        )
1596    }
1597}
1598
1599/// Audio Offload Extension. Used to retrieve offloading capability and supported features.
1600#[derive(Debug)]
1601pub enum AudioOffloadExtRequest {
1602    /// Returns the vendor features supported on this chipset
1603    GetSupportedFeatures { responder: AudioOffloadExtGetSupportedFeaturesResponder },
1604    /// Begin the audio encoding hardware offloading process
1605    StartAudioOffload {
1606        configuration: AudioOffloadConfiguration,
1607        controller: fidl::endpoints::ServerEnd<AudioOffloadControllerMarker>,
1608        control_handle: AudioOffloadExtControlHandle,
1609    },
1610    /// An interaction was received which does not match any known method.
1611    #[non_exhaustive]
1612    _UnknownMethod {
1613        /// Ordinal of the method that was called.
1614        ordinal: u64,
1615        control_handle: AudioOffloadExtControlHandle,
1616        method_type: fidl::MethodType,
1617    },
1618}
1619
1620impl AudioOffloadExtRequest {
1621    #[allow(irrefutable_let_patterns)]
1622    pub fn into_get_supported_features(
1623        self,
1624    ) -> Option<(AudioOffloadExtGetSupportedFeaturesResponder)> {
1625        if let AudioOffloadExtRequest::GetSupportedFeatures { responder } = self {
1626            Some((responder))
1627        } else {
1628            None
1629        }
1630    }
1631
1632    #[allow(irrefutable_let_patterns)]
1633    pub fn into_start_audio_offload(
1634        self,
1635    ) -> Option<(
1636        AudioOffloadConfiguration,
1637        fidl::endpoints::ServerEnd<AudioOffloadControllerMarker>,
1638        AudioOffloadExtControlHandle,
1639    )> {
1640        if let AudioOffloadExtRequest::StartAudioOffload {
1641            configuration,
1642            controller,
1643            control_handle,
1644        } = self
1645        {
1646            Some((configuration, controller, control_handle))
1647        } else {
1648            None
1649        }
1650    }
1651
1652    /// Name of the method defined in FIDL
1653    pub fn method_name(&self) -> &'static str {
1654        match *self {
1655            AudioOffloadExtRequest::GetSupportedFeatures { .. } => "get_supported_features",
1656            AudioOffloadExtRequest::StartAudioOffload { .. } => "start_audio_offload",
1657            AudioOffloadExtRequest::_UnknownMethod {
1658                method_type: fidl::MethodType::OneWay,
1659                ..
1660            } => "unknown one-way method",
1661            AudioOffloadExtRequest::_UnknownMethod {
1662                method_type: fidl::MethodType::TwoWay,
1663                ..
1664            } => "unknown two-way method",
1665        }
1666    }
1667}
1668
1669#[derive(Debug, Clone)]
1670pub struct AudioOffloadExtControlHandle {
1671    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1672}
1673
1674impl fidl::endpoints::ControlHandle for AudioOffloadExtControlHandle {
1675    fn shutdown(&self) {
1676        self.inner.shutdown()
1677    }
1678    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1679        self.inner.shutdown_with_epitaph(status)
1680    }
1681
1682    fn is_closed(&self) -> bool {
1683        self.inner.channel().is_closed()
1684    }
1685    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1686        self.inner.channel().on_closed()
1687    }
1688
1689    #[cfg(target_os = "fuchsia")]
1690    fn signal_peer(
1691        &self,
1692        clear_mask: zx::Signals,
1693        set_mask: zx::Signals,
1694    ) -> Result<(), zx_status::Status> {
1695        use fidl::Peered;
1696        self.inner.channel().signal_peer(clear_mask, set_mask)
1697    }
1698}
1699
1700impl AudioOffloadExtControlHandle {}
1701
1702#[must_use = "FIDL methods require a response to be sent"]
1703#[derive(Debug)]
1704pub struct AudioOffloadExtGetSupportedFeaturesResponder {
1705    control_handle: std::mem::ManuallyDrop<AudioOffloadExtControlHandle>,
1706    tx_id: u32,
1707}
1708
1709/// Set the the channel to be shutdown (see [`AudioOffloadExtControlHandle::shutdown`])
1710/// if the responder is dropped without sending a response, so that the client
1711/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1712impl std::ops::Drop for AudioOffloadExtGetSupportedFeaturesResponder {
1713    fn drop(&mut self) {
1714        self.control_handle.shutdown();
1715        // Safety: drops once, never accessed again
1716        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1717    }
1718}
1719
1720impl fidl::endpoints::Responder for AudioOffloadExtGetSupportedFeaturesResponder {
1721    type ControlHandle = AudioOffloadExtControlHandle;
1722
1723    fn control_handle(&self) -> &AudioOffloadExtControlHandle {
1724        &self.control_handle
1725    }
1726
1727    fn drop_without_shutdown(mut self) {
1728        // Safety: drops once, never accessed again due to mem::forget
1729        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1730        // Prevent Drop from running (which would shut down the channel)
1731        std::mem::forget(self);
1732    }
1733}
1734
1735impl AudioOffloadExtGetSupportedFeaturesResponder {
1736    /// Sends a response to the FIDL transaction.
1737    ///
1738    /// Sets the channel to shutdown if an error occurs.
1739    pub fn send(
1740        self,
1741        mut payload: &AudioOffloadExtGetSupportedFeaturesResponse,
1742    ) -> Result<(), fidl::Error> {
1743        let _result = self.send_raw(payload);
1744        if _result.is_err() {
1745            self.control_handle.shutdown();
1746        }
1747        self.drop_without_shutdown();
1748        _result
1749    }
1750
1751    /// Similar to "send" but does not shutdown the channel if an error occurs.
1752    pub fn send_no_shutdown_on_err(
1753        self,
1754        mut payload: &AudioOffloadExtGetSupportedFeaturesResponse,
1755    ) -> Result<(), fidl::Error> {
1756        let _result = self.send_raw(payload);
1757        self.drop_without_shutdown();
1758        _result
1759    }
1760
1761    fn send_raw(
1762        &self,
1763        mut payload: &AudioOffloadExtGetSupportedFeaturesResponse,
1764    ) -> Result<(), fidl::Error> {
1765        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1766            AudioOffloadExtGetSupportedFeaturesResponse,
1767        >>(
1768            fidl::encoding::Flexible::new(payload),
1769            self.tx_id,
1770            0x44ab0b88dde41f94,
1771            fidl::encoding::DynamicFlags::FLEXIBLE,
1772        )
1773    }
1774}
1775
1776#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1777pub struct ConnectionReceiverMarker;
1778
1779impl fidl::endpoints::ProtocolMarker for ConnectionReceiverMarker {
1780    type Proxy = ConnectionReceiverProxy;
1781    type RequestStream = ConnectionReceiverRequestStream;
1782    #[cfg(target_os = "fuchsia")]
1783    type SynchronousProxy = ConnectionReceiverSynchronousProxy;
1784
1785    const DEBUG_NAME: &'static str = "(anonymous) ConnectionReceiver";
1786}
1787
1788pub trait ConnectionReceiverProxyInterface: Send + Sync {
1789    fn r#connected(
1790        &self,
1791        peer_id: &fidl_fuchsia_bluetooth::PeerId,
1792        channel: Channel,
1793        protocol: &[ProtocolDescriptor],
1794    ) -> Result<(), fidl::Error>;
1795}
1796#[derive(Debug)]
1797#[cfg(target_os = "fuchsia")]
1798pub struct ConnectionReceiverSynchronousProxy {
1799    client: fidl::client::sync::Client,
1800}
1801
1802#[cfg(target_os = "fuchsia")]
1803impl fidl::endpoints::SynchronousProxy for ConnectionReceiverSynchronousProxy {
1804    type Proxy = ConnectionReceiverProxy;
1805    type Protocol = ConnectionReceiverMarker;
1806
1807    fn from_channel(inner: fidl::Channel) -> Self {
1808        Self::new(inner)
1809    }
1810
1811    fn into_channel(self) -> fidl::Channel {
1812        self.client.into_channel()
1813    }
1814
1815    fn as_channel(&self) -> &fidl::Channel {
1816        self.client.as_channel()
1817    }
1818}
1819
1820#[cfg(target_os = "fuchsia")]
1821impl ConnectionReceiverSynchronousProxy {
1822    pub fn new(channel: fidl::Channel) -> Self {
1823        let protocol_name =
1824            <ConnectionReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1825        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1826    }
1827
1828    pub fn into_channel(self) -> fidl::Channel {
1829        self.client.into_channel()
1830    }
1831
1832    /// Waits until an event arrives and returns it. It is safe for other
1833    /// threads to make concurrent requests while waiting for an event.
1834    pub fn wait_for_event(
1835        &self,
1836        deadline: zx::MonotonicInstant,
1837    ) -> Result<ConnectionReceiverEvent, fidl::Error> {
1838        ConnectionReceiverEvent::decode(self.client.wait_for_event(deadline)?)
1839    }
1840
1841    /// Called when a peer connects to this service.  The channel connected is delivered
1842    /// with parameters in `channel`.
1843    /// `protocol` will contain a protocol list up to the point connected (for example, if
1844    /// L2CAP is connected, it will contain the L2CAP protocol and specify the PSM connected)
1845    pub fn r#connected(
1846        &self,
1847        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1848        mut channel: Channel,
1849        mut protocol: &[ProtocolDescriptor],
1850    ) -> Result<(), fidl::Error> {
1851        self.client.send::<ConnectionReceiverConnectedRequest>(
1852            (peer_id, &mut channel, protocol),
1853            0xa5251eebbccf928,
1854            fidl::encoding::DynamicFlags::FLEXIBLE,
1855        )
1856    }
1857}
1858
1859#[cfg(target_os = "fuchsia")]
1860impl From<ConnectionReceiverSynchronousProxy> for zx::Handle {
1861    fn from(value: ConnectionReceiverSynchronousProxy) -> Self {
1862        value.into_channel().into()
1863    }
1864}
1865
1866#[cfg(target_os = "fuchsia")]
1867impl From<fidl::Channel> for ConnectionReceiverSynchronousProxy {
1868    fn from(value: fidl::Channel) -> Self {
1869        Self::new(value)
1870    }
1871}
1872
1873#[derive(Debug, Clone)]
1874pub struct ConnectionReceiverProxy {
1875    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1876}
1877
1878impl fidl::endpoints::Proxy for ConnectionReceiverProxy {
1879    type Protocol = ConnectionReceiverMarker;
1880
1881    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1882        Self::new(inner)
1883    }
1884
1885    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1886        self.client.into_channel().map_err(|client| Self { client })
1887    }
1888
1889    fn as_channel(&self) -> &::fidl::AsyncChannel {
1890        self.client.as_channel()
1891    }
1892}
1893
1894impl ConnectionReceiverProxy {
1895    /// Create a new Proxy for fuchsia.bluetooth.bredr/ConnectionReceiver.
1896    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1897        let protocol_name =
1898            <ConnectionReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1899        Self { client: fidl::client::Client::new(channel, protocol_name) }
1900    }
1901
1902    /// Get a Stream of events from the remote end of the protocol.
1903    ///
1904    /// # Panics
1905    ///
1906    /// Panics if the event stream was already taken.
1907    pub fn take_event_stream(&self) -> ConnectionReceiverEventStream {
1908        ConnectionReceiverEventStream { event_receiver: self.client.take_event_receiver() }
1909    }
1910
1911    /// Called when a peer connects to this service.  The channel connected is delivered
1912    /// with parameters in `channel`.
1913    /// `protocol` will contain a protocol list up to the point connected (for example, if
1914    /// L2CAP is connected, it will contain the L2CAP protocol and specify the PSM connected)
1915    pub fn r#connected(
1916        &self,
1917        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1918        mut channel: Channel,
1919        mut protocol: &[ProtocolDescriptor],
1920    ) -> Result<(), fidl::Error> {
1921        ConnectionReceiverProxyInterface::r#connected(self, peer_id, channel, protocol)
1922    }
1923}
1924
1925impl ConnectionReceiverProxyInterface for ConnectionReceiverProxy {
1926    fn r#connected(
1927        &self,
1928        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1929        mut channel: Channel,
1930        mut protocol: &[ProtocolDescriptor],
1931    ) -> Result<(), fidl::Error> {
1932        self.client.send::<ConnectionReceiverConnectedRequest>(
1933            (peer_id, &mut channel, protocol),
1934            0xa5251eebbccf928,
1935            fidl::encoding::DynamicFlags::FLEXIBLE,
1936        )
1937    }
1938}
1939
1940pub struct ConnectionReceiverEventStream {
1941    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1942}
1943
1944impl std::marker::Unpin for ConnectionReceiverEventStream {}
1945
1946impl futures::stream::FusedStream for ConnectionReceiverEventStream {
1947    fn is_terminated(&self) -> bool {
1948        self.event_receiver.is_terminated()
1949    }
1950}
1951
1952impl futures::Stream for ConnectionReceiverEventStream {
1953    type Item = Result<ConnectionReceiverEvent, fidl::Error>;
1954
1955    fn poll_next(
1956        mut self: std::pin::Pin<&mut Self>,
1957        cx: &mut std::task::Context<'_>,
1958    ) -> std::task::Poll<Option<Self::Item>> {
1959        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1960            &mut self.event_receiver,
1961            cx
1962        )?) {
1963            Some(buf) => std::task::Poll::Ready(Some(ConnectionReceiverEvent::decode(buf))),
1964            None => std::task::Poll::Ready(None),
1965        }
1966    }
1967}
1968
1969#[derive(Debug)]
1970pub enum ConnectionReceiverEvent {
1971    OnRevoke {},
1972    #[non_exhaustive]
1973    _UnknownEvent {
1974        /// Ordinal of the event that was sent.
1975        ordinal: u64,
1976    },
1977}
1978
1979impl ConnectionReceiverEvent {
1980    #[allow(irrefutable_let_patterns)]
1981    pub fn into_on_revoke(self) -> Option<()> {
1982        if let ConnectionReceiverEvent::OnRevoke {} = self {
1983            Some(())
1984        } else {
1985            None
1986        }
1987    }
1988
1989    /// Decodes a message buffer as a [`ConnectionReceiverEvent`].
1990    fn decode(
1991        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1992    ) -> Result<ConnectionReceiverEvent, fidl::Error> {
1993        let (bytes, _handles) = buf.split_mut();
1994        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1995        debug_assert_eq!(tx_header.tx_id, 0);
1996        match tx_header.ordinal {
1997            0x9b35c093a0468d1 => {
1998                let mut out = fidl::new_empty!(
1999                    fidl::encoding::EmptyPayload,
2000                    fidl::encoding::DefaultFuchsiaResourceDialect
2001                );
2002                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
2003                Ok((ConnectionReceiverEvent::OnRevoke {}))
2004            }
2005            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2006                Ok(ConnectionReceiverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2007            }
2008            _ => Err(fidl::Error::UnknownOrdinal {
2009                ordinal: tx_header.ordinal,
2010                protocol_name:
2011                    <ConnectionReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2012            }),
2013        }
2014    }
2015}
2016
2017/// A Stream of incoming requests for fuchsia.bluetooth.bredr/ConnectionReceiver.
2018pub struct ConnectionReceiverRequestStream {
2019    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2020    is_terminated: bool,
2021}
2022
2023impl std::marker::Unpin for ConnectionReceiverRequestStream {}
2024
2025impl futures::stream::FusedStream for ConnectionReceiverRequestStream {
2026    fn is_terminated(&self) -> bool {
2027        self.is_terminated
2028    }
2029}
2030
2031impl fidl::endpoints::RequestStream for ConnectionReceiverRequestStream {
2032    type Protocol = ConnectionReceiverMarker;
2033    type ControlHandle = ConnectionReceiverControlHandle;
2034
2035    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2036        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2037    }
2038
2039    fn control_handle(&self) -> Self::ControlHandle {
2040        ConnectionReceiverControlHandle { inner: self.inner.clone() }
2041    }
2042
2043    fn into_inner(
2044        self,
2045    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2046    {
2047        (self.inner, self.is_terminated)
2048    }
2049
2050    fn from_inner(
2051        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2052        is_terminated: bool,
2053    ) -> Self {
2054        Self { inner, is_terminated }
2055    }
2056}
2057
2058impl futures::Stream for ConnectionReceiverRequestStream {
2059    type Item = Result<ConnectionReceiverRequest, fidl::Error>;
2060
2061    fn poll_next(
2062        mut self: std::pin::Pin<&mut Self>,
2063        cx: &mut std::task::Context<'_>,
2064    ) -> std::task::Poll<Option<Self::Item>> {
2065        let this = &mut *self;
2066        if this.inner.check_shutdown(cx) {
2067            this.is_terminated = true;
2068            return std::task::Poll::Ready(None);
2069        }
2070        if this.is_terminated {
2071            panic!("polled ConnectionReceiverRequestStream after completion");
2072        }
2073        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2074            |bytes, handles| {
2075                match this.inner.channel().read_etc(cx, bytes, handles) {
2076                    std::task::Poll::Ready(Ok(())) => {}
2077                    std::task::Poll::Pending => return std::task::Poll::Pending,
2078                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2079                        this.is_terminated = true;
2080                        return std::task::Poll::Ready(None);
2081                    }
2082                    std::task::Poll::Ready(Err(e)) => {
2083                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2084                            e.into(),
2085                        ))))
2086                    }
2087                }
2088
2089                // A message has been received from the channel
2090                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2091
2092                std::task::Poll::Ready(Some(match header.ordinal {
2093                0xa5251eebbccf928 => {
2094                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2095                    let mut req = fidl::new_empty!(ConnectionReceiverConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2096                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionReceiverConnectedRequest>(&header, _body_bytes, handles, &mut req)?;
2097                    let control_handle = ConnectionReceiverControlHandle {
2098                        inner: this.inner.clone(),
2099                    };
2100                    Ok(ConnectionReceiverRequest::Connected {peer_id: req.peer_id,
2101channel: req.channel,
2102protocol: req.protocol,
2103
2104                        control_handle,
2105                    })
2106                }
2107                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2108                    Ok(ConnectionReceiverRequest::_UnknownMethod {
2109                        ordinal: header.ordinal,
2110                        control_handle: ConnectionReceiverControlHandle { inner: this.inner.clone() },
2111                        method_type: fidl::MethodType::OneWay,
2112                    })
2113                }
2114                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2115                    this.inner.send_framework_err(
2116                        fidl::encoding::FrameworkErr::UnknownMethod,
2117                        header.tx_id,
2118                        header.ordinal,
2119                        header.dynamic_flags(),
2120                        (bytes, handles),
2121                    )?;
2122                    Ok(ConnectionReceiverRequest::_UnknownMethod {
2123                        ordinal: header.ordinal,
2124                        control_handle: ConnectionReceiverControlHandle { inner: this.inner.clone() },
2125                        method_type: fidl::MethodType::TwoWay,
2126                    })
2127                }
2128                _ => Err(fidl::Error::UnknownOrdinal {
2129                    ordinal: header.ordinal,
2130                    protocol_name: <ConnectionReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2131                }),
2132            }))
2133            },
2134        )
2135    }
2136}
2137
2138/// Represents a service which is registered by this profile. Closing this protocol will remove the
2139/// service registration.
2140#[derive(Debug)]
2141pub enum ConnectionReceiverRequest {
2142    /// Called when a peer connects to this service.  The channel connected is delivered
2143    /// with parameters in `channel`.
2144    /// `protocol` will contain a protocol list up to the point connected (for example, if
2145    /// L2CAP is connected, it will contain the L2CAP protocol and specify the PSM connected)
2146    Connected {
2147        peer_id: fidl_fuchsia_bluetooth::PeerId,
2148        channel: Channel,
2149        protocol: Vec<ProtocolDescriptor>,
2150        control_handle: ConnectionReceiverControlHandle,
2151    },
2152    /// An interaction was received which does not match any known method.
2153    #[non_exhaustive]
2154    _UnknownMethod {
2155        /// Ordinal of the method that was called.
2156        ordinal: u64,
2157        control_handle: ConnectionReceiverControlHandle,
2158        method_type: fidl::MethodType,
2159    },
2160}
2161
2162impl ConnectionReceiverRequest {
2163    #[allow(irrefutable_let_patterns)]
2164    pub fn into_connected(
2165        self,
2166    ) -> Option<(
2167        fidl_fuchsia_bluetooth::PeerId,
2168        Channel,
2169        Vec<ProtocolDescriptor>,
2170        ConnectionReceiverControlHandle,
2171    )> {
2172        if let ConnectionReceiverRequest::Connected { peer_id, channel, protocol, control_handle } =
2173            self
2174        {
2175            Some((peer_id, channel, protocol, control_handle))
2176        } else {
2177            None
2178        }
2179    }
2180
2181    /// Name of the method defined in FIDL
2182    pub fn method_name(&self) -> &'static str {
2183        match *self {
2184            ConnectionReceiverRequest::Connected { .. } => "connected",
2185            ConnectionReceiverRequest::_UnknownMethod {
2186                method_type: fidl::MethodType::OneWay,
2187                ..
2188            } => "unknown one-way method",
2189            ConnectionReceiverRequest::_UnknownMethod {
2190                method_type: fidl::MethodType::TwoWay,
2191                ..
2192            } => "unknown two-way method",
2193        }
2194    }
2195}
2196
2197#[derive(Debug, Clone)]
2198pub struct ConnectionReceiverControlHandle {
2199    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2200}
2201
2202impl fidl::endpoints::ControlHandle for ConnectionReceiverControlHandle {
2203    fn shutdown(&self) {
2204        self.inner.shutdown()
2205    }
2206    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2207        self.inner.shutdown_with_epitaph(status)
2208    }
2209
2210    fn is_closed(&self) -> bool {
2211        self.inner.channel().is_closed()
2212    }
2213    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2214        self.inner.channel().on_closed()
2215    }
2216
2217    #[cfg(target_os = "fuchsia")]
2218    fn signal_peer(
2219        &self,
2220        clear_mask: zx::Signals,
2221        set_mask: zx::Signals,
2222    ) -> Result<(), zx_status::Status> {
2223        use fidl::Peered;
2224        self.inner.channel().signal_peer(clear_mask, set_mask)
2225    }
2226}
2227
2228impl ConnectionReceiverControlHandle {
2229    pub fn send_on_revoke(&self) -> Result<(), fidl::Error> {
2230        self.inner.send::<fidl::encoding::EmptyPayload>(
2231            (),
2232            0,
2233            0x9b35c093a0468d1,
2234            fidl::encoding::DynamicFlags::FLEXIBLE,
2235        )
2236    }
2237}
2238
2239#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2240pub struct L2capParametersExtMarker;
2241
2242impl fidl::endpoints::ProtocolMarker for L2capParametersExtMarker {
2243    type Proxy = L2capParametersExtProxy;
2244    type RequestStream = L2capParametersExtRequestStream;
2245    #[cfg(target_os = "fuchsia")]
2246    type SynchronousProxy = L2capParametersExtSynchronousProxy;
2247
2248    const DEBUG_NAME: &'static str = "(anonymous) L2capParametersExt";
2249}
2250
2251pub trait L2capParametersExtProxyInterface: Send + Sync {
2252    type RequestParametersResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::ChannelParameters, fidl::Error>>
2253        + Send;
2254    fn r#request_parameters(
2255        &self,
2256        request: &fidl_fuchsia_bluetooth::ChannelParameters,
2257    ) -> Self::RequestParametersResponseFut;
2258}
2259#[derive(Debug)]
2260#[cfg(target_os = "fuchsia")]
2261pub struct L2capParametersExtSynchronousProxy {
2262    client: fidl::client::sync::Client,
2263}
2264
2265#[cfg(target_os = "fuchsia")]
2266impl fidl::endpoints::SynchronousProxy for L2capParametersExtSynchronousProxy {
2267    type Proxy = L2capParametersExtProxy;
2268    type Protocol = L2capParametersExtMarker;
2269
2270    fn from_channel(inner: fidl::Channel) -> Self {
2271        Self::new(inner)
2272    }
2273
2274    fn into_channel(self) -> fidl::Channel {
2275        self.client.into_channel()
2276    }
2277
2278    fn as_channel(&self) -> &fidl::Channel {
2279        self.client.as_channel()
2280    }
2281}
2282
2283#[cfg(target_os = "fuchsia")]
2284impl L2capParametersExtSynchronousProxy {
2285    pub fn new(channel: fidl::Channel) -> Self {
2286        let protocol_name =
2287            <L2capParametersExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2288        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2289    }
2290
2291    pub fn into_channel(self) -> fidl::Channel {
2292        self.client.into_channel()
2293    }
2294
2295    /// Waits until an event arrives and returns it. It is safe for other
2296    /// threads to make concurrent requests while waiting for an event.
2297    pub fn wait_for_event(
2298        &self,
2299        deadline: zx::MonotonicInstant,
2300    ) -> Result<L2capParametersExtEvent, fidl::Error> {
2301        L2capParametersExtEvent::decode(self.client.wait_for_event(deadline)?)
2302    }
2303
2304    /// Request a L2CAP channel parameter update. `request` indicates the
2305    /// desired parameters, and `new` indicates the new parameters
2306    /// (which may differ from the requested parameters if they are
2307    /// rejected/modified).
2308    /// Currently only the following parameters can be changed:
2309    /// - flush_timeout
2310    pub fn r#request_parameters(
2311        &self,
2312        mut request: &fidl_fuchsia_bluetooth::ChannelParameters,
2313        ___deadline: zx::MonotonicInstant,
2314    ) -> Result<fidl_fuchsia_bluetooth::ChannelParameters, fidl::Error> {
2315        let _response = self.client.send_query::<
2316            L2capParametersExtRequestParametersRequest,
2317            fidl::encoding::FlexibleType<L2capParametersExtRequestParametersResponse>,
2318        >(
2319            (request,),
2320            0x1da4d8f268e2e918,
2321            fidl::encoding::DynamicFlags::FLEXIBLE,
2322            ___deadline,
2323        )?
2324        .into_result::<L2capParametersExtMarker>("request_parameters")?;
2325        Ok(_response.new)
2326    }
2327}
2328
2329#[cfg(target_os = "fuchsia")]
2330impl From<L2capParametersExtSynchronousProxy> for zx::Handle {
2331    fn from(value: L2capParametersExtSynchronousProxy) -> Self {
2332        value.into_channel().into()
2333    }
2334}
2335
2336#[cfg(target_os = "fuchsia")]
2337impl From<fidl::Channel> for L2capParametersExtSynchronousProxy {
2338    fn from(value: fidl::Channel) -> Self {
2339        Self::new(value)
2340    }
2341}
2342
2343#[derive(Debug, Clone)]
2344pub struct L2capParametersExtProxy {
2345    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2346}
2347
2348impl fidl::endpoints::Proxy for L2capParametersExtProxy {
2349    type Protocol = L2capParametersExtMarker;
2350
2351    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2352        Self::new(inner)
2353    }
2354
2355    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2356        self.client.into_channel().map_err(|client| Self { client })
2357    }
2358
2359    fn as_channel(&self) -> &::fidl::AsyncChannel {
2360        self.client.as_channel()
2361    }
2362}
2363
2364impl L2capParametersExtProxy {
2365    /// Create a new Proxy for fuchsia.bluetooth.bredr/L2capParametersExt.
2366    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2367        let protocol_name =
2368            <L2capParametersExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2369        Self { client: fidl::client::Client::new(channel, protocol_name) }
2370    }
2371
2372    /// Get a Stream of events from the remote end of the protocol.
2373    ///
2374    /// # Panics
2375    ///
2376    /// Panics if the event stream was already taken.
2377    pub fn take_event_stream(&self) -> L2capParametersExtEventStream {
2378        L2capParametersExtEventStream { event_receiver: self.client.take_event_receiver() }
2379    }
2380
2381    /// Request a L2CAP channel parameter update. `request` indicates the
2382    /// desired parameters, and `new` indicates the new parameters
2383    /// (which may differ from the requested parameters if they are
2384    /// rejected/modified).
2385    /// Currently only the following parameters can be changed:
2386    /// - flush_timeout
2387    pub fn r#request_parameters(
2388        &self,
2389        mut request: &fidl_fuchsia_bluetooth::ChannelParameters,
2390    ) -> fidl::client::QueryResponseFut<
2391        fidl_fuchsia_bluetooth::ChannelParameters,
2392        fidl::encoding::DefaultFuchsiaResourceDialect,
2393    > {
2394        L2capParametersExtProxyInterface::r#request_parameters(self, request)
2395    }
2396}
2397
2398impl L2capParametersExtProxyInterface for L2capParametersExtProxy {
2399    type RequestParametersResponseFut = fidl::client::QueryResponseFut<
2400        fidl_fuchsia_bluetooth::ChannelParameters,
2401        fidl::encoding::DefaultFuchsiaResourceDialect,
2402    >;
2403    fn r#request_parameters(
2404        &self,
2405        mut request: &fidl_fuchsia_bluetooth::ChannelParameters,
2406    ) -> Self::RequestParametersResponseFut {
2407        fn _decode(
2408            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2409        ) -> Result<fidl_fuchsia_bluetooth::ChannelParameters, fidl::Error> {
2410            let _response = fidl::client::decode_transaction_body::<
2411                fidl::encoding::FlexibleType<L2capParametersExtRequestParametersResponse>,
2412                fidl::encoding::DefaultFuchsiaResourceDialect,
2413                0x1da4d8f268e2e918,
2414            >(_buf?)?
2415            .into_result::<L2capParametersExtMarker>("request_parameters")?;
2416            Ok(_response.new)
2417        }
2418        self.client.send_query_and_decode::<
2419            L2capParametersExtRequestParametersRequest,
2420            fidl_fuchsia_bluetooth::ChannelParameters,
2421        >(
2422            (request,),
2423            0x1da4d8f268e2e918,
2424            fidl::encoding::DynamicFlags::FLEXIBLE,
2425            _decode,
2426        )
2427    }
2428}
2429
2430pub struct L2capParametersExtEventStream {
2431    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2432}
2433
2434impl std::marker::Unpin for L2capParametersExtEventStream {}
2435
2436impl futures::stream::FusedStream for L2capParametersExtEventStream {
2437    fn is_terminated(&self) -> bool {
2438        self.event_receiver.is_terminated()
2439    }
2440}
2441
2442impl futures::Stream for L2capParametersExtEventStream {
2443    type Item = Result<L2capParametersExtEvent, fidl::Error>;
2444
2445    fn poll_next(
2446        mut self: std::pin::Pin<&mut Self>,
2447        cx: &mut std::task::Context<'_>,
2448    ) -> std::task::Poll<Option<Self::Item>> {
2449        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2450            &mut self.event_receiver,
2451            cx
2452        )?) {
2453            Some(buf) => std::task::Poll::Ready(Some(L2capParametersExtEvent::decode(buf))),
2454            None => std::task::Poll::Ready(None),
2455        }
2456    }
2457}
2458
2459#[derive(Debug)]
2460pub enum L2capParametersExtEvent {
2461    #[non_exhaustive]
2462    _UnknownEvent {
2463        /// Ordinal of the event that was sent.
2464        ordinal: u64,
2465    },
2466}
2467
2468impl L2capParametersExtEvent {
2469    /// Decodes a message buffer as a [`L2capParametersExtEvent`].
2470    fn decode(
2471        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2472    ) -> Result<L2capParametersExtEvent, fidl::Error> {
2473        let (bytes, _handles) = buf.split_mut();
2474        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2475        debug_assert_eq!(tx_header.tx_id, 0);
2476        match tx_header.ordinal {
2477            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2478                Ok(L2capParametersExtEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2479            }
2480            _ => Err(fidl::Error::UnknownOrdinal {
2481                ordinal: tx_header.ordinal,
2482                protocol_name:
2483                    <L2capParametersExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2484            }),
2485        }
2486    }
2487}
2488
2489/// A Stream of incoming requests for fuchsia.bluetooth.bredr/L2capParametersExt.
2490pub struct L2capParametersExtRequestStream {
2491    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2492    is_terminated: bool,
2493}
2494
2495impl std::marker::Unpin for L2capParametersExtRequestStream {}
2496
2497impl futures::stream::FusedStream for L2capParametersExtRequestStream {
2498    fn is_terminated(&self) -> bool {
2499        self.is_terminated
2500    }
2501}
2502
2503impl fidl::endpoints::RequestStream for L2capParametersExtRequestStream {
2504    type Protocol = L2capParametersExtMarker;
2505    type ControlHandle = L2capParametersExtControlHandle;
2506
2507    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2508        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2509    }
2510
2511    fn control_handle(&self) -> Self::ControlHandle {
2512        L2capParametersExtControlHandle { inner: self.inner.clone() }
2513    }
2514
2515    fn into_inner(
2516        self,
2517    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2518    {
2519        (self.inner, self.is_terminated)
2520    }
2521
2522    fn from_inner(
2523        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2524        is_terminated: bool,
2525    ) -> Self {
2526        Self { inner, is_terminated }
2527    }
2528}
2529
2530impl futures::Stream for L2capParametersExtRequestStream {
2531    type Item = Result<L2capParametersExtRequest, fidl::Error>;
2532
2533    fn poll_next(
2534        mut self: std::pin::Pin<&mut Self>,
2535        cx: &mut std::task::Context<'_>,
2536    ) -> std::task::Poll<Option<Self::Item>> {
2537        let this = &mut *self;
2538        if this.inner.check_shutdown(cx) {
2539            this.is_terminated = true;
2540            return std::task::Poll::Ready(None);
2541        }
2542        if this.is_terminated {
2543            panic!("polled L2capParametersExtRequestStream after completion");
2544        }
2545        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2546            |bytes, handles| {
2547                match this.inner.channel().read_etc(cx, bytes, handles) {
2548                    std::task::Poll::Ready(Ok(())) => {}
2549                    std::task::Poll::Pending => return std::task::Poll::Pending,
2550                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2551                        this.is_terminated = true;
2552                        return std::task::Poll::Ready(None);
2553                    }
2554                    std::task::Poll::Ready(Err(e)) => {
2555                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2556                            e.into(),
2557                        ))))
2558                    }
2559                }
2560
2561                // A message has been received from the channel
2562                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2563
2564                std::task::Poll::Ready(Some(match header.ordinal {
2565                0x1da4d8f268e2e918 => {
2566                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2567                    let mut req = fidl::new_empty!(L2capParametersExtRequestParametersRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2568                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<L2capParametersExtRequestParametersRequest>(&header, _body_bytes, handles, &mut req)?;
2569                    let control_handle = L2capParametersExtControlHandle {
2570                        inner: this.inner.clone(),
2571                    };
2572                    Ok(L2capParametersExtRequest::RequestParameters {request: req.request,
2573
2574                        responder: L2capParametersExtRequestParametersResponder {
2575                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2576                            tx_id: header.tx_id,
2577                        },
2578                    })
2579                }
2580                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2581                    Ok(L2capParametersExtRequest::_UnknownMethod {
2582                        ordinal: header.ordinal,
2583                        control_handle: L2capParametersExtControlHandle { inner: this.inner.clone() },
2584                        method_type: fidl::MethodType::OneWay,
2585                    })
2586                }
2587                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2588                    this.inner.send_framework_err(
2589                        fidl::encoding::FrameworkErr::UnknownMethod,
2590                        header.tx_id,
2591                        header.ordinal,
2592                        header.dynamic_flags(),
2593                        (bytes, handles),
2594                    )?;
2595                    Ok(L2capParametersExtRequest::_UnknownMethod {
2596                        ordinal: header.ordinal,
2597                        control_handle: L2capParametersExtControlHandle { inner: this.inner.clone() },
2598                        method_type: fidl::MethodType::TwoWay,
2599                    })
2600                }
2601                _ => Err(fidl::Error::UnknownOrdinal {
2602                    ordinal: header.ordinal,
2603                    protocol_name: <L2capParametersExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2604                }),
2605            }))
2606            },
2607        )
2608    }
2609}
2610
2611/// L2CAP Parameters Extension. Used to configure L2CAP channel parameters on an open channel.
2612#[derive(Debug)]
2613pub enum L2capParametersExtRequest {
2614    /// Request a L2CAP channel parameter update. `request` indicates the
2615    /// desired parameters, and `new` indicates the new parameters
2616    /// (which may differ from the requested parameters if they are
2617    /// rejected/modified).
2618    /// Currently only the following parameters can be changed:
2619    /// - flush_timeout
2620    RequestParameters {
2621        request: fidl_fuchsia_bluetooth::ChannelParameters,
2622        responder: L2capParametersExtRequestParametersResponder,
2623    },
2624    /// An interaction was received which does not match any known method.
2625    #[non_exhaustive]
2626    _UnknownMethod {
2627        /// Ordinal of the method that was called.
2628        ordinal: u64,
2629        control_handle: L2capParametersExtControlHandle,
2630        method_type: fidl::MethodType,
2631    },
2632}
2633
2634impl L2capParametersExtRequest {
2635    #[allow(irrefutable_let_patterns)]
2636    pub fn into_request_parameters(
2637        self,
2638    ) -> Option<(
2639        fidl_fuchsia_bluetooth::ChannelParameters,
2640        L2capParametersExtRequestParametersResponder,
2641    )> {
2642        if let L2capParametersExtRequest::RequestParameters { request, responder } = self {
2643            Some((request, responder))
2644        } else {
2645            None
2646        }
2647    }
2648
2649    /// Name of the method defined in FIDL
2650    pub fn method_name(&self) -> &'static str {
2651        match *self {
2652            L2capParametersExtRequest::RequestParameters { .. } => "request_parameters",
2653            L2capParametersExtRequest::_UnknownMethod {
2654                method_type: fidl::MethodType::OneWay,
2655                ..
2656            } => "unknown one-way method",
2657            L2capParametersExtRequest::_UnknownMethod {
2658                method_type: fidl::MethodType::TwoWay,
2659                ..
2660            } => "unknown two-way method",
2661        }
2662    }
2663}
2664
2665#[derive(Debug, Clone)]
2666pub struct L2capParametersExtControlHandle {
2667    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2668}
2669
2670impl fidl::endpoints::ControlHandle for L2capParametersExtControlHandle {
2671    fn shutdown(&self) {
2672        self.inner.shutdown()
2673    }
2674    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2675        self.inner.shutdown_with_epitaph(status)
2676    }
2677
2678    fn is_closed(&self) -> bool {
2679        self.inner.channel().is_closed()
2680    }
2681    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2682        self.inner.channel().on_closed()
2683    }
2684
2685    #[cfg(target_os = "fuchsia")]
2686    fn signal_peer(
2687        &self,
2688        clear_mask: zx::Signals,
2689        set_mask: zx::Signals,
2690    ) -> Result<(), zx_status::Status> {
2691        use fidl::Peered;
2692        self.inner.channel().signal_peer(clear_mask, set_mask)
2693    }
2694}
2695
2696impl L2capParametersExtControlHandle {}
2697
2698#[must_use = "FIDL methods require a response to be sent"]
2699#[derive(Debug)]
2700pub struct L2capParametersExtRequestParametersResponder {
2701    control_handle: std::mem::ManuallyDrop<L2capParametersExtControlHandle>,
2702    tx_id: u32,
2703}
2704
2705/// Set the the channel to be shutdown (see [`L2capParametersExtControlHandle::shutdown`])
2706/// if the responder is dropped without sending a response, so that the client
2707/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2708impl std::ops::Drop for L2capParametersExtRequestParametersResponder {
2709    fn drop(&mut self) {
2710        self.control_handle.shutdown();
2711        // Safety: drops once, never accessed again
2712        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2713    }
2714}
2715
2716impl fidl::endpoints::Responder for L2capParametersExtRequestParametersResponder {
2717    type ControlHandle = L2capParametersExtControlHandle;
2718
2719    fn control_handle(&self) -> &L2capParametersExtControlHandle {
2720        &self.control_handle
2721    }
2722
2723    fn drop_without_shutdown(mut self) {
2724        // Safety: drops once, never accessed again due to mem::forget
2725        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2726        // Prevent Drop from running (which would shut down the channel)
2727        std::mem::forget(self);
2728    }
2729}
2730
2731impl L2capParametersExtRequestParametersResponder {
2732    /// Sends a response to the FIDL transaction.
2733    ///
2734    /// Sets the channel to shutdown if an error occurs.
2735    pub fn send(
2736        self,
2737        mut new: &fidl_fuchsia_bluetooth::ChannelParameters,
2738    ) -> Result<(), fidl::Error> {
2739        let _result = self.send_raw(new);
2740        if _result.is_err() {
2741            self.control_handle.shutdown();
2742        }
2743        self.drop_without_shutdown();
2744        _result
2745    }
2746
2747    /// Similar to "send" but does not shutdown the channel if an error occurs.
2748    pub fn send_no_shutdown_on_err(
2749        self,
2750        mut new: &fidl_fuchsia_bluetooth::ChannelParameters,
2751    ) -> Result<(), fidl::Error> {
2752        let _result = self.send_raw(new);
2753        self.drop_without_shutdown();
2754        _result
2755    }
2756
2757    fn send_raw(
2758        &self,
2759        mut new: &fidl_fuchsia_bluetooth::ChannelParameters,
2760    ) -> Result<(), fidl::Error> {
2761        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
2762            L2capParametersExtRequestParametersResponse,
2763        >>(
2764            fidl::encoding::Flexible::new((new,)),
2765            self.tx_id,
2766            0x1da4d8f268e2e918,
2767            fidl::encoding::DynamicFlags::FLEXIBLE,
2768        )
2769    }
2770}
2771
2772#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2773pub struct ProfileMarker;
2774
2775impl fidl::endpoints::ProtocolMarker for ProfileMarker {
2776    type Proxy = ProfileProxy;
2777    type RequestStream = ProfileRequestStream;
2778    #[cfg(target_os = "fuchsia")]
2779    type SynchronousProxy = ProfileSynchronousProxy;
2780
2781    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.bredr.Profile";
2782}
2783impl fidl::endpoints::DiscoverableProtocolMarker for ProfileMarker {}
2784pub type ProfileAdvertiseResult =
2785    Result<ProfileAdvertiseResponse, fidl_fuchsia_bluetooth::ErrorCode>;
2786pub type ProfileConnectResult = Result<Channel, fidl_fuchsia_bluetooth::ErrorCode>;
2787
2788pub trait ProfileProxyInterface: Send + Sync {
2789    type AdvertiseResponseFut: std::future::Future<Output = Result<ProfileAdvertiseResult, fidl::Error>>
2790        + Send;
2791    fn r#advertise(&self, payload: ProfileAdvertiseRequest) -> Self::AdvertiseResponseFut;
2792    fn r#search(&self, payload: ProfileSearchRequest) -> Result<(), fidl::Error>;
2793    type ConnectResponseFut: std::future::Future<Output = Result<ProfileConnectResult, fidl::Error>>
2794        + Send;
2795    fn r#connect(
2796        &self,
2797        peer_id: &fidl_fuchsia_bluetooth::PeerId,
2798        connection: &ConnectParameters,
2799    ) -> Self::ConnectResponseFut;
2800    fn r#connect_sco(&self, payload: ProfileConnectScoRequest) -> Result<(), fidl::Error>;
2801}
2802#[derive(Debug)]
2803#[cfg(target_os = "fuchsia")]
2804pub struct ProfileSynchronousProxy {
2805    client: fidl::client::sync::Client,
2806}
2807
2808#[cfg(target_os = "fuchsia")]
2809impl fidl::endpoints::SynchronousProxy for ProfileSynchronousProxy {
2810    type Proxy = ProfileProxy;
2811    type Protocol = ProfileMarker;
2812
2813    fn from_channel(inner: fidl::Channel) -> Self {
2814        Self::new(inner)
2815    }
2816
2817    fn into_channel(self) -> fidl::Channel {
2818        self.client.into_channel()
2819    }
2820
2821    fn as_channel(&self) -> &fidl::Channel {
2822        self.client.as_channel()
2823    }
2824}
2825
2826#[cfg(target_os = "fuchsia")]
2827impl ProfileSynchronousProxy {
2828    pub fn new(channel: fidl::Channel) -> Self {
2829        let protocol_name = <ProfileMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2830        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2831    }
2832
2833    pub fn into_channel(self) -> fidl::Channel {
2834        self.client.into_channel()
2835    }
2836
2837    /// Waits until an event arrives and returns it. It is safe for other
2838    /// threads to make concurrent requests while waiting for an event.
2839    pub fn wait_for_event(
2840        &self,
2841        deadline: zx::MonotonicInstant,
2842    ) -> Result<ProfileEvent, fidl::Error> {
2843        ProfileEvent::decode(self.client.wait_for_event(deadline)?)
2844    }
2845
2846    /// Register a set of services.
2847    ///
2848    /// These services will be discoverable via Service Discovery Protocol server.
2849    /// All services advertising the same channel must be added at once - if services are already
2850    /// registered on any channel advertised, registration will fail, the receiver will be closed
2851    /// with ZX_ERR_ALREADY_BOUND and an error will be returned.
2852    /// The ConnectionReceiver will get calls for connections to the channels included in the
2853    /// `protocol_descriptor` or `alternative_protocol_descriptors` in the services advertised.
2854    /// The receiver will be closed if there are any errors advertising.
2855    ///
2856    /// The `ConnectionReceiver::OnRevoke` event can be used to synchronize revoking the
2857    /// advertisement, if necessary. Closing the `ConnectionReceiver` protocol will also stop
2858    /// advertising these services.
2859    ///
2860    /// If the advertisement cannot be made for any reason, an error of `INVALID_ARGUMENTS`
2861    /// will be returned and the receiver will be closed with a suitable epitaph.
2862    /// Returns the set of services that are registered via the Service Discovery Protocol
2863    /// server. The returned services may differ from the input `services` if any L2CAP protocol
2864    /// descriptors request `PSM_DYNAMIC`. In this case, the `Profile` server shall assign a valid
2865    /// PSM and include this value in the returned services.
2866    pub fn r#advertise(
2867        &self,
2868        mut payload: ProfileAdvertiseRequest,
2869        ___deadline: zx::MonotonicInstant,
2870    ) -> Result<ProfileAdvertiseResult, fidl::Error> {
2871        let _response = self
2872            .client
2873            .send_query::<ProfileAdvertiseRequest, fidl::encoding::FlexibleResultType<
2874                ProfileAdvertiseResponse,
2875                fidl_fuchsia_bluetooth::ErrorCode,
2876            >>(
2877                &mut payload,
2878                0x65e429c1f0205a0e,
2879                fidl::encoding::DynamicFlags::FLEXIBLE,
2880                ___deadline,
2881            )?
2882            .into_result::<ProfileMarker>("advertise")?;
2883        Ok(_response.map(|x| x))
2884    }
2885
2886    /// Register a search for services on newly connected peers. The SearchResults protocol will be
2887    /// used to report results for this search.
2888    /// Only one of `service_uuid` or `full_uuid` must be present. Any service result with a service
2889    /// matching the specified UUID will be returned with the additional attributes in `attr_ids`.
2890    /// If both `service_uuid` and `full_uuid` are present, then `ZX_ERR_INVALID_ARGS` will be
2891    /// returned.
2892    /// If `attr_ids` is empty or omitted, all attributes will be requested. The additional
2893    /// attribute BLUETOOTH_PROTOCOL_DESCRIPTOR_LIST is always requested. See the Bluetooth
2894    /// Spec v5.2, Vol 3, Part B, Section 5) and relevant profile specification documents.
2895    pub fn r#search(&self, mut payload: ProfileSearchRequest) -> Result<(), fidl::Error> {
2896        self.client.send::<ProfileSearchRequest>(
2897            &mut payload,
2898            0x2c59d8580bc8ef0a,
2899            fidl::encoding::DynamicFlags::FLEXIBLE,
2900        )
2901    }
2902
2903    /// Connect an L2CAP or RFCOMM channel to the connected peer identified by `peer_id` using the
2904    /// desired `connection` parameters listed. Dynamic PSMs can be specified in `connection`.
2905    ///
2906    /// Returns the channel connected once established, or an error code if the channel could not
2907    /// be connected.
2908    pub fn r#connect(
2909        &self,
2910        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
2911        mut connection: &ConnectParameters,
2912        ___deadline: zx::MonotonicInstant,
2913    ) -> Result<ProfileConnectResult, fidl::Error> {
2914        let _response = self
2915            .client
2916            .send_query::<ProfileConnectRequest, fidl::encoding::FlexibleResultType<
2917                ProfileConnectResponse,
2918                fidl_fuchsia_bluetooth::ErrorCode,
2919            >>(
2920                (peer_id, connection),
2921                0xaaeefc898901fb3,
2922                fidl::encoding::DynamicFlags::FLEXIBLE,
2923                ___deadline,
2924            )?
2925            .into_result::<ProfileMarker>("connect")?;
2926        Ok(_response.map(|x| x.channel))
2927    }
2928
2929    /// Attempt to establish a synchronous connection to `peer_id` configured
2930    /// using `params`.
2931    ///
2932    /// If `initiator` is true, a connection request will be sent. Only 1
2933    /// parameter may be specified.
2934    ///
2935    /// If `initiator` is false, the host will attempt to accept the next
2936    /// connection request using the parameters given in order. The parameters
2937    /// will be tried in order until either a connection is successful, all
2938    /// parameters have been rejected (`ScoErrorCode.PARAMETERS_REJECTED`), or
2939    /// the procedure is canceled.
2940    ///
2941    /// The result of the connection attempt and the parameters used for the
2942    /// connection will be returned with `connection`.  Dropping `connection` will
2943    /// cancel the request.
2944    pub fn r#connect_sco(&self, mut payload: ProfileConnectScoRequest) -> Result<(), fidl::Error> {
2945        self.client.send::<ProfileConnectScoRequest>(
2946            &mut payload,
2947            0x961976ddd116ee6,
2948            fidl::encoding::DynamicFlags::FLEXIBLE,
2949        )
2950    }
2951}
2952
2953#[cfg(target_os = "fuchsia")]
2954impl From<ProfileSynchronousProxy> for zx::Handle {
2955    fn from(value: ProfileSynchronousProxy) -> Self {
2956        value.into_channel().into()
2957    }
2958}
2959
2960#[cfg(target_os = "fuchsia")]
2961impl From<fidl::Channel> for ProfileSynchronousProxy {
2962    fn from(value: fidl::Channel) -> Self {
2963        Self::new(value)
2964    }
2965}
2966
2967#[derive(Debug, Clone)]
2968pub struct ProfileProxy {
2969    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2970}
2971
2972impl fidl::endpoints::Proxy for ProfileProxy {
2973    type Protocol = ProfileMarker;
2974
2975    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2976        Self::new(inner)
2977    }
2978
2979    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2980        self.client.into_channel().map_err(|client| Self { client })
2981    }
2982
2983    fn as_channel(&self) -> &::fidl::AsyncChannel {
2984        self.client.as_channel()
2985    }
2986}
2987
2988impl ProfileProxy {
2989    /// Create a new Proxy for fuchsia.bluetooth.bredr/Profile.
2990    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2991        let protocol_name = <ProfileMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2992        Self { client: fidl::client::Client::new(channel, protocol_name) }
2993    }
2994
2995    /// Get a Stream of events from the remote end of the protocol.
2996    ///
2997    /// # Panics
2998    ///
2999    /// Panics if the event stream was already taken.
3000    pub fn take_event_stream(&self) -> ProfileEventStream {
3001        ProfileEventStream { event_receiver: self.client.take_event_receiver() }
3002    }
3003
3004    /// Register a set of services.
3005    ///
3006    /// These services will be discoverable via Service Discovery Protocol server.
3007    /// All services advertising the same channel must be added at once - if services are already
3008    /// registered on any channel advertised, registration will fail, the receiver will be closed
3009    /// with ZX_ERR_ALREADY_BOUND and an error will be returned.
3010    /// The ConnectionReceiver will get calls for connections to the channels included in the
3011    /// `protocol_descriptor` or `alternative_protocol_descriptors` in the services advertised.
3012    /// The receiver will be closed if there are any errors advertising.
3013    ///
3014    /// The `ConnectionReceiver::OnRevoke` event can be used to synchronize revoking the
3015    /// advertisement, if necessary. Closing the `ConnectionReceiver` protocol will also stop
3016    /// advertising these services.
3017    ///
3018    /// If the advertisement cannot be made for any reason, an error of `INVALID_ARGUMENTS`
3019    /// will be returned and the receiver will be closed with a suitable epitaph.
3020    /// Returns the set of services that are registered via the Service Discovery Protocol
3021    /// server. The returned services may differ from the input `services` if any L2CAP protocol
3022    /// descriptors request `PSM_DYNAMIC`. In this case, the `Profile` server shall assign a valid
3023    /// PSM and include this value in the returned services.
3024    pub fn r#advertise(
3025        &self,
3026        mut payload: ProfileAdvertiseRequest,
3027    ) -> fidl::client::QueryResponseFut<
3028        ProfileAdvertiseResult,
3029        fidl::encoding::DefaultFuchsiaResourceDialect,
3030    > {
3031        ProfileProxyInterface::r#advertise(self, payload)
3032    }
3033
3034    /// Register a search for services on newly connected peers. The SearchResults protocol will be
3035    /// used to report results for this search.
3036    /// Only one of `service_uuid` or `full_uuid` must be present. Any service result with a service
3037    /// matching the specified UUID will be returned with the additional attributes in `attr_ids`.
3038    /// If both `service_uuid` and `full_uuid` are present, then `ZX_ERR_INVALID_ARGS` will be
3039    /// returned.
3040    /// If `attr_ids` is empty or omitted, all attributes will be requested. The additional
3041    /// attribute BLUETOOTH_PROTOCOL_DESCRIPTOR_LIST is always requested. See the Bluetooth
3042    /// Spec v5.2, Vol 3, Part B, Section 5) and relevant profile specification documents.
3043    pub fn r#search(&self, mut payload: ProfileSearchRequest) -> Result<(), fidl::Error> {
3044        ProfileProxyInterface::r#search(self, payload)
3045    }
3046
3047    /// Connect an L2CAP or RFCOMM channel to the connected peer identified by `peer_id` using the
3048    /// desired `connection` parameters listed. Dynamic PSMs can be specified in `connection`.
3049    ///
3050    /// Returns the channel connected once established, or an error code if the channel could not
3051    /// be connected.
3052    pub fn r#connect(
3053        &self,
3054        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
3055        mut connection: &ConnectParameters,
3056    ) -> fidl::client::QueryResponseFut<
3057        ProfileConnectResult,
3058        fidl::encoding::DefaultFuchsiaResourceDialect,
3059    > {
3060        ProfileProxyInterface::r#connect(self, peer_id, connection)
3061    }
3062
3063    /// Attempt to establish a synchronous connection to `peer_id` configured
3064    /// using `params`.
3065    ///
3066    /// If `initiator` is true, a connection request will be sent. Only 1
3067    /// parameter may be specified.
3068    ///
3069    /// If `initiator` is false, the host will attempt to accept the next
3070    /// connection request using the parameters given in order. The parameters
3071    /// will be tried in order until either a connection is successful, all
3072    /// parameters have been rejected (`ScoErrorCode.PARAMETERS_REJECTED`), or
3073    /// the procedure is canceled.
3074    ///
3075    /// The result of the connection attempt and the parameters used for the
3076    /// connection will be returned with `connection`.  Dropping `connection` will
3077    /// cancel the request.
3078    pub fn r#connect_sco(&self, mut payload: ProfileConnectScoRequest) -> Result<(), fidl::Error> {
3079        ProfileProxyInterface::r#connect_sco(self, payload)
3080    }
3081}
3082
3083impl ProfileProxyInterface for ProfileProxy {
3084    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
3085        ProfileAdvertiseResult,
3086        fidl::encoding::DefaultFuchsiaResourceDialect,
3087    >;
3088    fn r#advertise(&self, mut payload: ProfileAdvertiseRequest) -> Self::AdvertiseResponseFut {
3089        fn _decode(
3090            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3091        ) -> Result<ProfileAdvertiseResult, fidl::Error> {
3092            let _response = fidl::client::decode_transaction_body::<
3093                fidl::encoding::FlexibleResultType<
3094                    ProfileAdvertiseResponse,
3095                    fidl_fuchsia_bluetooth::ErrorCode,
3096                >,
3097                fidl::encoding::DefaultFuchsiaResourceDialect,
3098                0x65e429c1f0205a0e,
3099            >(_buf?)?
3100            .into_result::<ProfileMarker>("advertise")?;
3101            Ok(_response.map(|x| x))
3102        }
3103        self.client.send_query_and_decode::<ProfileAdvertiseRequest, ProfileAdvertiseResult>(
3104            &mut payload,
3105            0x65e429c1f0205a0e,
3106            fidl::encoding::DynamicFlags::FLEXIBLE,
3107            _decode,
3108        )
3109    }
3110
3111    fn r#search(&self, mut payload: ProfileSearchRequest) -> Result<(), fidl::Error> {
3112        self.client.send::<ProfileSearchRequest>(
3113            &mut payload,
3114            0x2c59d8580bc8ef0a,
3115            fidl::encoding::DynamicFlags::FLEXIBLE,
3116        )
3117    }
3118
3119    type ConnectResponseFut = fidl::client::QueryResponseFut<
3120        ProfileConnectResult,
3121        fidl::encoding::DefaultFuchsiaResourceDialect,
3122    >;
3123    fn r#connect(
3124        &self,
3125        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
3126        mut connection: &ConnectParameters,
3127    ) -> Self::ConnectResponseFut {
3128        fn _decode(
3129            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3130        ) -> Result<ProfileConnectResult, fidl::Error> {
3131            let _response = fidl::client::decode_transaction_body::<
3132                fidl::encoding::FlexibleResultType<
3133                    ProfileConnectResponse,
3134                    fidl_fuchsia_bluetooth::ErrorCode,
3135                >,
3136                fidl::encoding::DefaultFuchsiaResourceDialect,
3137                0xaaeefc898901fb3,
3138            >(_buf?)?
3139            .into_result::<ProfileMarker>("connect")?;
3140            Ok(_response.map(|x| x.channel))
3141        }
3142        self.client.send_query_and_decode::<ProfileConnectRequest, ProfileConnectResult>(
3143            (peer_id, connection),
3144            0xaaeefc898901fb3,
3145            fidl::encoding::DynamicFlags::FLEXIBLE,
3146            _decode,
3147        )
3148    }
3149
3150    fn r#connect_sco(&self, mut payload: ProfileConnectScoRequest) -> Result<(), fidl::Error> {
3151        self.client.send::<ProfileConnectScoRequest>(
3152            &mut payload,
3153            0x961976ddd116ee6,
3154            fidl::encoding::DynamicFlags::FLEXIBLE,
3155        )
3156    }
3157}
3158
3159pub struct ProfileEventStream {
3160    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3161}
3162
3163impl std::marker::Unpin for ProfileEventStream {}
3164
3165impl futures::stream::FusedStream for ProfileEventStream {
3166    fn is_terminated(&self) -> bool {
3167        self.event_receiver.is_terminated()
3168    }
3169}
3170
3171impl futures::Stream for ProfileEventStream {
3172    type Item = Result<ProfileEvent, fidl::Error>;
3173
3174    fn poll_next(
3175        mut self: std::pin::Pin<&mut Self>,
3176        cx: &mut std::task::Context<'_>,
3177    ) -> std::task::Poll<Option<Self::Item>> {
3178        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3179            &mut self.event_receiver,
3180            cx
3181        )?) {
3182            Some(buf) => std::task::Poll::Ready(Some(ProfileEvent::decode(buf))),
3183            None => std::task::Poll::Ready(None),
3184        }
3185    }
3186}
3187
3188#[derive(Debug)]
3189pub enum ProfileEvent {
3190    #[non_exhaustive]
3191    _UnknownEvent {
3192        /// Ordinal of the event that was sent.
3193        ordinal: u64,
3194    },
3195}
3196
3197impl ProfileEvent {
3198    /// Decodes a message buffer as a [`ProfileEvent`].
3199    fn decode(
3200        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3201    ) -> Result<ProfileEvent, fidl::Error> {
3202        let (bytes, _handles) = buf.split_mut();
3203        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3204        debug_assert_eq!(tx_header.tx_id, 0);
3205        match tx_header.ordinal {
3206            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3207                Ok(ProfileEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3208            }
3209            _ => Err(fidl::Error::UnknownOrdinal {
3210                ordinal: tx_header.ordinal,
3211                protocol_name: <ProfileMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3212            }),
3213        }
3214    }
3215}
3216
3217/// A Stream of incoming requests for fuchsia.bluetooth.bredr/Profile.
3218pub struct ProfileRequestStream {
3219    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3220    is_terminated: bool,
3221}
3222
3223impl std::marker::Unpin for ProfileRequestStream {}
3224
3225impl futures::stream::FusedStream for ProfileRequestStream {
3226    fn is_terminated(&self) -> bool {
3227        self.is_terminated
3228    }
3229}
3230
3231impl fidl::endpoints::RequestStream for ProfileRequestStream {
3232    type Protocol = ProfileMarker;
3233    type ControlHandle = ProfileControlHandle;
3234
3235    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3236        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3237    }
3238
3239    fn control_handle(&self) -> Self::ControlHandle {
3240        ProfileControlHandle { inner: self.inner.clone() }
3241    }
3242
3243    fn into_inner(
3244        self,
3245    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3246    {
3247        (self.inner, self.is_terminated)
3248    }
3249
3250    fn from_inner(
3251        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3252        is_terminated: bool,
3253    ) -> Self {
3254        Self { inner, is_terminated }
3255    }
3256}
3257
3258impl futures::Stream for ProfileRequestStream {
3259    type Item = Result<ProfileRequest, fidl::Error>;
3260
3261    fn poll_next(
3262        mut self: std::pin::Pin<&mut Self>,
3263        cx: &mut std::task::Context<'_>,
3264    ) -> std::task::Poll<Option<Self::Item>> {
3265        let this = &mut *self;
3266        if this.inner.check_shutdown(cx) {
3267            this.is_terminated = true;
3268            return std::task::Poll::Ready(None);
3269        }
3270        if this.is_terminated {
3271            panic!("polled ProfileRequestStream after completion");
3272        }
3273        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3274            |bytes, handles| {
3275                match this.inner.channel().read_etc(cx, bytes, handles) {
3276                    std::task::Poll::Ready(Ok(())) => {}
3277                    std::task::Poll::Pending => return std::task::Poll::Pending,
3278                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3279                        this.is_terminated = true;
3280                        return std::task::Poll::Ready(None);
3281                    }
3282                    std::task::Poll::Ready(Err(e)) => {
3283                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3284                            e.into(),
3285                        ))))
3286                    }
3287                }
3288
3289                // A message has been received from the channel
3290                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3291
3292                std::task::Poll::Ready(Some(match header.ordinal {
3293                    0x65e429c1f0205a0e => {
3294                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3295                        let mut req = fidl::new_empty!(
3296                            ProfileAdvertiseRequest,
3297                            fidl::encoding::DefaultFuchsiaResourceDialect
3298                        );
3299                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
3300                        let control_handle = ProfileControlHandle { inner: this.inner.clone() };
3301                        Ok(ProfileRequest::Advertise {
3302                            payload: req,
3303                            responder: ProfileAdvertiseResponder {
3304                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3305                                tx_id: header.tx_id,
3306                            },
3307                        })
3308                    }
3309                    0x2c59d8580bc8ef0a => {
3310                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3311                        let mut req = fidl::new_empty!(
3312                            ProfileSearchRequest,
3313                            fidl::encoding::DefaultFuchsiaResourceDialect
3314                        );
3315                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileSearchRequest>(&header, _body_bytes, handles, &mut req)?;
3316                        let control_handle = ProfileControlHandle { inner: this.inner.clone() };
3317                        Ok(ProfileRequest::Search { payload: req, control_handle })
3318                    }
3319                    0xaaeefc898901fb3 => {
3320                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3321                        let mut req = fidl::new_empty!(
3322                            ProfileConnectRequest,
3323                            fidl::encoding::DefaultFuchsiaResourceDialect
3324                        );
3325                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileConnectRequest>(&header, _body_bytes, handles, &mut req)?;
3326                        let control_handle = ProfileControlHandle { inner: this.inner.clone() };
3327                        Ok(ProfileRequest::Connect {
3328                            peer_id: req.peer_id,
3329                            connection: req.connection,
3330
3331                            responder: ProfileConnectResponder {
3332                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3333                                tx_id: header.tx_id,
3334                            },
3335                        })
3336                    }
3337                    0x961976ddd116ee6 => {
3338                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3339                        let mut req = fidl::new_empty!(
3340                            ProfileConnectScoRequest,
3341                            fidl::encoding::DefaultFuchsiaResourceDialect
3342                        );
3343                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileConnectScoRequest>(&header, _body_bytes, handles, &mut req)?;
3344                        let control_handle = ProfileControlHandle { inner: this.inner.clone() };
3345                        Ok(ProfileRequest::ConnectSco { payload: req, control_handle })
3346                    }
3347                    _ if header.tx_id == 0
3348                        && header
3349                            .dynamic_flags()
3350                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3351                    {
3352                        Ok(ProfileRequest::_UnknownMethod {
3353                            ordinal: header.ordinal,
3354                            control_handle: ProfileControlHandle { inner: this.inner.clone() },
3355                            method_type: fidl::MethodType::OneWay,
3356                        })
3357                    }
3358                    _ if header
3359                        .dynamic_flags()
3360                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3361                    {
3362                        this.inner.send_framework_err(
3363                            fidl::encoding::FrameworkErr::UnknownMethod,
3364                            header.tx_id,
3365                            header.ordinal,
3366                            header.dynamic_flags(),
3367                            (bytes, handles),
3368                        )?;
3369                        Ok(ProfileRequest::_UnknownMethod {
3370                            ordinal: header.ordinal,
3371                            control_handle: ProfileControlHandle { inner: this.inner.clone() },
3372                            method_type: fidl::MethodType::TwoWay,
3373                        })
3374                    }
3375                    _ => Err(fidl::Error::UnknownOrdinal {
3376                        ordinal: header.ordinal,
3377                        protocol_name:
3378                            <ProfileMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3379                    }),
3380                }))
3381            },
3382        )
3383    }
3384}
3385
3386/// Service provides Bluetooth BR/EDR profiles a way to register a service definition, making a
3387/// profile discoverable by peers. Registered services can receive L2CAP connections made to the
3388/// advertised records, and can open new connections on peers.
3389#[derive(Debug)]
3390pub enum ProfileRequest {
3391    /// Register a set of services.
3392    ///
3393    /// These services will be discoverable via Service Discovery Protocol server.
3394    /// All services advertising the same channel must be added at once - if services are already
3395    /// registered on any channel advertised, registration will fail, the receiver will be closed
3396    /// with ZX_ERR_ALREADY_BOUND and an error will be returned.
3397    /// The ConnectionReceiver will get calls for connections to the channels included in the
3398    /// `protocol_descriptor` or `alternative_protocol_descriptors` in the services advertised.
3399    /// The receiver will be closed if there are any errors advertising.
3400    ///
3401    /// The `ConnectionReceiver::OnRevoke` event can be used to synchronize revoking the
3402    /// advertisement, if necessary. Closing the `ConnectionReceiver` protocol will also stop
3403    /// advertising these services.
3404    ///
3405    /// If the advertisement cannot be made for any reason, an error of `INVALID_ARGUMENTS`
3406    /// will be returned and the receiver will be closed with a suitable epitaph.
3407    /// Returns the set of services that are registered via the Service Discovery Protocol
3408    /// server. The returned services may differ from the input `services` if any L2CAP protocol
3409    /// descriptors request `PSM_DYNAMIC`. In this case, the `Profile` server shall assign a valid
3410    /// PSM and include this value in the returned services.
3411    Advertise { payload: ProfileAdvertiseRequest, responder: ProfileAdvertiseResponder },
3412    /// Register a search for services on newly connected peers. The SearchResults protocol will be
3413    /// used to report results for this search.
3414    /// Only one of `service_uuid` or `full_uuid` must be present. Any service result with a service
3415    /// matching the specified UUID will be returned with the additional attributes in `attr_ids`.
3416    /// If both `service_uuid` and `full_uuid` are present, then `ZX_ERR_INVALID_ARGS` will be
3417    /// returned.
3418    /// If `attr_ids` is empty or omitted, all attributes will be requested. The additional
3419    /// attribute BLUETOOTH_PROTOCOL_DESCRIPTOR_LIST is always requested. See the Bluetooth
3420    /// Spec v5.2, Vol 3, Part B, Section 5) and relevant profile specification documents.
3421    Search { payload: ProfileSearchRequest, control_handle: ProfileControlHandle },
3422    /// Connect an L2CAP or RFCOMM channel to the connected peer identified by `peer_id` using the
3423    /// desired `connection` parameters listed. Dynamic PSMs can be specified in `connection`.
3424    ///
3425    /// Returns the channel connected once established, or an error code if the channel could not
3426    /// be connected.
3427    Connect {
3428        peer_id: fidl_fuchsia_bluetooth::PeerId,
3429        connection: ConnectParameters,
3430        responder: ProfileConnectResponder,
3431    },
3432    /// Attempt to establish a synchronous connection to `peer_id` configured
3433    /// using `params`.
3434    ///
3435    /// If `initiator` is true, a connection request will be sent. Only 1
3436    /// parameter may be specified.
3437    ///
3438    /// If `initiator` is false, the host will attempt to accept the next
3439    /// connection request using the parameters given in order. The parameters
3440    /// will be tried in order until either a connection is successful, all
3441    /// parameters have been rejected (`ScoErrorCode.PARAMETERS_REJECTED`), or
3442    /// the procedure is canceled.
3443    ///
3444    /// The result of the connection attempt and the parameters used for the
3445    /// connection will be returned with `connection`.  Dropping `connection` will
3446    /// cancel the request.
3447    ConnectSco { payload: ProfileConnectScoRequest, control_handle: ProfileControlHandle },
3448    /// An interaction was received which does not match any known method.
3449    #[non_exhaustive]
3450    _UnknownMethod {
3451        /// Ordinal of the method that was called.
3452        ordinal: u64,
3453        control_handle: ProfileControlHandle,
3454        method_type: fidl::MethodType,
3455    },
3456}
3457
3458impl ProfileRequest {
3459    #[allow(irrefutable_let_patterns)]
3460    pub fn into_advertise(self) -> Option<(ProfileAdvertiseRequest, ProfileAdvertiseResponder)> {
3461        if let ProfileRequest::Advertise { payload, responder } = self {
3462            Some((payload, responder))
3463        } else {
3464            None
3465        }
3466    }
3467
3468    #[allow(irrefutable_let_patterns)]
3469    pub fn into_search(self) -> Option<(ProfileSearchRequest, ProfileControlHandle)> {
3470        if let ProfileRequest::Search { payload, control_handle } = self {
3471            Some((payload, control_handle))
3472        } else {
3473            None
3474        }
3475    }
3476
3477    #[allow(irrefutable_let_patterns)]
3478    pub fn into_connect(
3479        self,
3480    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, ConnectParameters, ProfileConnectResponder)> {
3481        if let ProfileRequest::Connect { peer_id, connection, responder } = self {
3482            Some((peer_id, connection, responder))
3483        } else {
3484            None
3485        }
3486    }
3487
3488    #[allow(irrefutable_let_patterns)]
3489    pub fn into_connect_sco(self) -> Option<(ProfileConnectScoRequest, ProfileControlHandle)> {
3490        if let ProfileRequest::ConnectSco { payload, control_handle } = self {
3491            Some((payload, control_handle))
3492        } else {
3493            None
3494        }
3495    }
3496
3497    /// Name of the method defined in FIDL
3498    pub fn method_name(&self) -> &'static str {
3499        match *self {
3500            ProfileRequest::Advertise { .. } => "advertise",
3501            ProfileRequest::Search { .. } => "search",
3502            ProfileRequest::Connect { .. } => "connect",
3503            ProfileRequest::ConnectSco { .. } => "connect_sco",
3504            ProfileRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
3505                "unknown one-way method"
3506            }
3507            ProfileRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
3508                "unknown two-way method"
3509            }
3510        }
3511    }
3512}
3513
3514#[derive(Debug, Clone)]
3515pub struct ProfileControlHandle {
3516    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3517}
3518
3519impl fidl::endpoints::ControlHandle for ProfileControlHandle {
3520    fn shutdown(&self) {
3521        self.inner.shutdown()
3522    }
3523    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3524        self.inner.shutdown_with_epitaph(status)
3525    }
3526
3527    fn is_closed(&self) -> bool {
3528        self.inner.channel().is_closed()
3529    }
3530    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3531        self.inner.channel().on_closed()
3532    }
3533
3534    #[cfg(target_os = "fuchsia")]
3535    fn signal_peer(
3536        &self,
3537        clear_mask: zx::Signals,
3538        set_mask: zx::Signals,
3539    ) -> Result<(), zx_status::Status> {
3540        use fidl::Peered;
3541        self.inner.channel().signal_peer(clear_mask, set_mask)
3542    }
3543}
3544
3545impl ProfileControlHandle {}
3546
3547#[must_use = "FIDL methods require a response to be sent"]
3548#[derive(Debug)]
3549pub struct ProfileAdvertiseResponder {
3550    control_handle: std::mem::ManuallyDrop<ProfileControlHandle>,
3551    tx_id: u32,
3552}
3553
3554/// Set the the channel to be shutdown (see [`ProfileControlHandle::shutdown`])
3555/// if the responder is dropped without sending a response, so that the client
3556/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3557impl std::ops::Drop for ProfileAdvertiseResponder {
3558    fn drop(&mut self) {
3559        self.control_handle.shutdown();
3560        // Safety: drops once, never accessed again
3561        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3562    }
3563}
3564
3565impl fidl::endpoints::Responder for ProfileAdvertiseResponder {
3566    type ControlHandle = ProfileControlHandle;
3567
3568    fn control_handle(&self) -> &ProfileControlHandle {
3569        &self.control_handle
3570    }
3571
3572    fn drop_without_shutdown(mut self) {
3573        // Safety: drops once, never accessed again due to mem::forget
3574        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3575        // Prevent Drop from running (which would shut down the channel)
3576        std::mem::forget(self);
3577    }
3578}
3579
3580impl ProfileAdvertiseResponder {
3581    /// Sends a response to the FIDL transaction.
3582    ///
3583    /// Sets the channel to shutdown if an error occurs.
3584    pub fn send(
3585        self,
3586        mut result: Result<&ProfileAdvertiseResponse, fidl_fuchsia_bluetooth::ErrorCode>,
3587    ) -> Result<(), fidl::Error> {
3588        let _result = self.send_raw(result);
3589        if _result.is_err() {
3590            self.control_handle.shutdown();
3591        }
3592        self.drop_without_shutdown();
3593        _result
3594    }
3595
3596    /// Similar to "send" but does not shutdown the channel if an error occurs.
3597    pub fn send_no_shutdown_on_err(
3598        self,
3599        mut result: Result<&ProfileAdvertiseResponse, fidl_fuchsia_bluetooth::ErrorCode>,
3600    ) -> Result<(), fidl::Error> {
3601        let _result = self.send_raw(result);
3602        self.drop_without_shutdown();
3603        _result
3604    }
3605
3606    fn send_raw(
3607        &self,
3608        mut result: Result<&ProfileAdvertiseResponse, fidl_fuchsia_bluetooth::ErrorCode>,
3609    ) -> Result<(), fidl::Error> {
3610        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3611            ProfileAdvertiseResponse,
3612            fidl_fuchsia_bluetooth::ErrorCode,
3613        >>(
3614            fidl::encoding::FlexibleResult::new(result),
3615            self.tx_id,
3616            0x65e429c1f0205a0e,
3617            fidl::encoding::DynamicFlags::FLEXIBLE,
3618        )
3619    }
3620}
3621
3622#[must_use = "FIDL methods require a response to be sent"]
3623#[derive(Debug)]
3624pub struct ProfileConnectResponder {
3625    control_handle: std::mem::ManuallyDrop<ProfileControlHandle>,
3626    tx_id: u32,
3627}
3628
3629/// Set the the channel to be shutdown (see [`ProfileControlHandle::shutdown`])
3630/// if the responder is dropped without sending a response, so that the client
3631/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3632impl std::ops::Drop for ProfileConnectResponder {
3633    fn drop(&mut self) {
3634        self.control_handle.shutdown();
3635        // Safety: drops once, never accessed again
3636        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3637    }
3638}
3639
3640impl fidl::endpoints::Responder for ProfileConnectResponder {
3641    type ControlHandle = ProfileControlHandle;
3642
3643    fn control_handle(&self) -> &ProfileControlHandle {
3644        &self.control_handle
3645    }
3646
3647    fn drop_without_shutdown(mut self) {
3648        // Safety: drops once, never accessed again due to mem::forget
3649        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3650        // Prevent Drop from running (which would shut down the channel)
3651        std::mem::forget(self);
3652    }
3653}
3654
3655impl ProfileConnectResponder {
3656    /// Sends a response to the FIDL transaction.
3657    ///
3658    /// Sets the channel to shutdown if an error occurs.
3659    pub fn send(
3660        self,
3661        mut result: Result<Channel, fidl_fuchsia_bluetooth::ErrorCode>,
3662    ) -> Result<(), fidl::Error> {
3663        let _result = self.send_raw(result);
3664        if _result.is_err() {
3665            self.control_handle.shutdown();
3666        }
3667        self.drop_without_shutdown();
3668        _result
3669    }
3670
3671    /// Similar to "send" but does not shutdown the channel if an error occurs.
3672    pub fn send_no_shutdown_on_err(
3673        self,
3674        mut result: Result<Channel, fidl_fuchsia_bluetooth::ErrorCode>,
3675    ) -> Result<(), fidl::Error> {
3676        let _result = self.send_raw(result);
3677        self.drop_without_shutdown();
3678        _result
3679    }
3680
3681    fn send_raw(
3682        &self,
3683        mut result: Result<Channel, fidl_fuchsia_bluetooth::ErrorCode>,
3684    ) -> Result<(), fidl::Error> {
3685        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3686            ProfileConnectResponse,
3687            fidl_fuchsia_bluetooth::ErrorCode,
3688        >>(
3689            fidl::encoding::FlexibleResult::new(
3690                result.as_mut().map_err(|e| *e).map(|channel| (channel,)),
3691            ),
3692            self.tx_id,
3693            0xaaeefc898901fb3,
3694            fidl::encoding::DynamicFlags::FLEXIBLE,
3695        )
3696    }
3697}
3698
3699#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3700pub struct ScoConnectionMarker;
3701
3702impl fidl::endpoints::ProtocolMarker for ScoConnectionMarker {
3703    type Proxy = ScoConnectionProxy;
3704    type RequestStream = ScoConnectionRequestStream;
3705    #[cfg(target_os = "fuchsia")]
3706    type SynchronousProxy = ScoConnectionSynchronousProxy;
3707
3708    const DEBUG_NAME: &'static str = "(anonymous) ScoConnection";
3709}
3710
3711pub trait ScoConnectionProxyInterface: Send + Sync {
3712    type ReadResponseFut: std::future::Future<Output = Result<ScoConnectionReadResponse, fidl::Error>>
3713        + Send;
3714    fn r#read(&self) -> Self::ReadResponseFut;
3715    type WriteResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3716    fn r#write(&self, payload: &ScoConnectionWriteRequest) -> Self::WriteResponseFut;
3717}
3718#[derive(Debug)]
3719#[cfg(target_os = "fuchsia")]
3720pub struct ScoConnectionSynchronousProxy {
3721    client: fidl::client::sync::Client,
3722}
3723
3724#[cfg(target_os = "fuchsia")]
3725impl fidl::endpoints::SynchronousProxy for ScoConnectionSynchronousProxy {
3726    type Proxy = ScoConnectionProxy;
3727    type Protocol = ScoConnectionMarker;
3728
3729    fn from_channel(inner: fidl::Channel) -> Self {
3730        Self::new(inner)
3731    }
3732
3733    fn into_channel(self) -> fidl::Channel {
3734        self.client.into_channel()
3735    }
3736
3737    fn as_channel(&self) -> &fidl::Channel {
3738        self.client.as_channel()
3739    }
3740}
3741
3742#[cfg(target_os = "fuchsia")]
3743impl ScoConnectionSynchronousProxy {
3744    pub fn new(channel: fidl::Channel) -> Self {
3745        let protocol_name = <ScoConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3746        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3747    }
3748
3749    pub fn into_channel(self) -> fidl::Channel {
3750        self.client.into_channel()
3751    }
3752
3753    /// Waits until an event arrives and returns it. It is safe for other
3754    /// threads to make concurrent requests while waiting for an event.
3755    pub fn wait_for_event(
3756        &self,
3757        deadline: zx::MonotonicInstant,
3758    ) -> Result<ScoConnectionEvent, fidl::Error> {
3759        ScoConnectionEvent::decode(self.client.wait_for_event(deadline)?)
3760    }
3761
3762    /// Read the next inbound SCO payload.
3763    /// Hangs until new data is received.
3764    /// Only one Read request may be pending at a time. Additional requests will result in protocol
3765    /// closure.
3766    pub fn r#read(
3767        &self,
3768        ___deadline: zx::MonotonicInstant,
3769    ) -> Result<ScoConnectionReadResponse, fidl::Error> {
3770        let _response = self.client.send_query::<
3771            fidl::encoding::EmptyPayload,
3772            fidl::encoding::FlexibleType<ScoConnectionReadResponse>,
3773        >(
3774            (),
3775            0x6fb29eb1e16ac616,
3776            fidl::encoding::DynamicFlags::FLEXIBLE,
3777            ___deadline,
3778        )?
3779        .into_result::<ScoConnectionMarker>("read")?;
3780        Ok(_response)
3781    }
3782
3783    /// Write `data` to the SCO connection.
3784    /// If Write tries to send more data than `max_tx_data_size`, the protocol will be closed.
3785    /// Only one Write request may be pending at a time. Additional requests will result in protocol
3786    /// closure.
3787    pub fn r#write(
3788        &self,
3789        mut payload: &ScoConnectionWriteRequest,
3790        ___deadline: zx::MonotonicInstant,
3791    ) -> Result<(), fidl::Error> {
3792        let _response = self.client.send_query::<
3793            ScoConnectionWriteRequest,
3794            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3795        >(
3796            payload,
3797            0x394e1b2ff7f4a5a9,
3798            fidl::encoding::DynamicFlags::FLEXIBLE,
3799            ___deadline,
3800        )?
3801        .into_result::<ScoConnectionMarker>("write")?;
3802        Ok(_response)
3803    }
3804}
3805
3806#[cfg(target_os = "fuchsia")]
3807impl From<ScoConnectionSynchronousProxy> for zx::Handle {
3808    fn from(value: ScoConnectionSynchronousProxy) -> Self {
3809        value.into_channel().into()
3810    }
3811}
3812
3813#[cfg(target_os = "fuchsia")]
3814impl From<fidl::Channel> for ScoConnectionSynchronousProxy {
3815    fn from(value: fidl::Channel) -> Self {
3816        Self::new(value)
3817    }
3818}
3819
3820#[derive(Debug, Clone)]
3821pub struct ScoConnectionProxy {
3822    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3823}
3824
3825impl fidl::endpoints::Proxy for ScoConnectionProxy {
3826    type Protocol = ScoConnectionMarker;
3827
3828    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3829        Self::new(inner)
3830    }
3831
3832    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3833        self.client.into_channel().map_err(|client| Self { client })
3834    }
3835
3836    fn as_channel(&self) -> &::fidl::AsyncChannel {
3837        self.client.as_channel()
3838    }
3839}
3840
3841impl ScoConnectionProxy {
3842    /// Create a new Proxy for fuchsia.bluetooth.bredr/ScoConnection.
3843    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3844        let protocol_name = <ScoConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3845        Self { client: fidl::client::Client::new(channel, protocol_name) }
3846    }
3847
3848    /// Get a Stream of events from the remote end of the protocol.
3849    ///
3850    /// # Panics
3851    ///
3852    /// Panics if the event stream was already taken.
3853    pub fn take_event_stream(&self) -> ScoConnectionEventStream {
3854        ScoConnectionEventStream { event_receiver: self.client.take_event_receiver() }
3855    }
3856
3857    /// Read the next inbound SCO payload.
3858    /// Hangs until new data is received.
3859    /// Only one Read request may be pending at a time. Additional requests will result in protocol
3860    /// closure.
3861    pub fn r#read(
3862        &self,
3863    ) -> fidl::client::QueryResponseFut<
3864        ScoConnectionReadResponse,
3865        fidl::encoding::DefaultFuchsiaResourceDialect,
3866    > {
3867        ScoConnectionProxyInterface::r#read(self)
3868    }
3869
3870    /// Write `data` to the SCO connection.
3871    /// If Write tries to send more data than `max_tx_data_size`, the protocol will be closed.
3872    /// Only one Write request may be pending at a time. Additional requests will result in protocol
3873    /// closure.
3874    pub fn r#write(
3875        &self,
3876        mut payload: &ScoConnectionWriteRequest,
3877    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3878        ScoConnectionProxyInterface::r#write(self, payload)
3879    }
3880}
3881
3882impl ScoConnectionProxyInterface for ScoConnectionProxy {
3883    type ReadResponseFut = fidl::client::QueryResponseFut<
3884        ScoConnectionReadResponse,
3885        fidl::encoding::DefaultFuchsiaResourceDialect,
3886    >;
3887    fn r#read(&self) -> Self::ReadResponseFut {
3888        fn _decode(
3889            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3890        ) -> Result<ScoConnectionReadResponse, fidl::Error> {
3891            let _response = fidl::client::decode_transaction_body::<
3892                fidl::encoding::FlexibleType<ScoConnectionReadResponse>,
3893                fidl::encoding::DefaultFuchsiaResourceDialect,
3894                0x6fb29eb1e16ac616,
3895            >(_buf?)?
3896            .into_result::<ScoConnectionMarker>("read")?;
3897            Ok(_response)
3898        }
3899        self.client
3900            .send_query_and_decode::<fidl::encoding::EmptyPayload, ScoConnectionReadResponse>(
3901                (),
3902                0x6fb29eb1e16ac616,
3903                fidl::encoding::DynamicFlags::FLEXIBLE,
3904                _decode,
3905            )
3906    }
3907
3908    type WriteResponseFut =
3909        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3910    fn r#write(&self, mut payload: &ScoConnectionWriteRequest) -> Self::WriteResponseFut {
3911        fn _decode(
3912            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3913        ) -> Result<(), fidl::Error> {
3914            let _response = fidl::client::decode_transaction_body::<
3915                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3916                fidl::encoding::DefaultFuchsiaResourceDialect,
3917                0x394e1b2ff7f4a5a9,
3918            >(_buf?)?
3919            .into_result::<ScoConnectionMarker>("write")?;
3920            Ok(_response)
3921        }
3922        self.client.send_query_and_decode::<ScoConnectionWriteRequest, ()>(
3923            payload,
3924            0x394e1b2ff7f4a5a9,
3925            fidl::encoding::DynamicFlags::FLEXIBLE,
3926            _decode,
3927        )
3928    }
3929}
3930
3931pub struct ScoConnectionEventStream {
3932    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3933}
3934
3935impl std::marker::Unpin for ScoConnectionEventStream {}
3936
3937impl futures::stream::FusedStream for ScoConnectionEventStream {
3938    fn is_terminated(&self) -> bool {
3939        self.event_receiver.is_terminated()
3940    }
3941}
3942
3943impl futures::Stream for ScoConnectionEventStream {
3944    type Item = Result<ScoConnectionEvent, fidl::Error>;
3945
3946    fn poll_next(
3947        mut self: std::pin::Pin<&mut Self>,
3948        cx: &mut std::task::Context<'_>,
3949    ) -> std::task::Poll<Option<Self::Item>> {
3950        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3951            &mut self.event_receiver,
3952            cx
3953        )?) {
3954            Some(buf) => std::task::Poll::Ready(Some(ScoConnectionEvent::decode(buf))),
3955            None => std::task::Poll::Ready(None),
3956        }
3957    }
3958}
3959
3960#[derive(Debug)]
3961pub enum ScoConnectionEvent {
3962    OnConnectionComplete {
3963        payload: ScoConnectionOnConnectionCompleteRequest,
3964    },
3965    #[non_exhaustive]
3966    _UnknownEvent {
3967        /// Ordinal of the event that was sent.
3968        ordinal: u64,
3969    },
3970}
3971
3972impl ScoConnectionEvent {
3973    #[allow(irrefutable_let_patterns)]
3974    pub fn into_on_connection_complete(self) -> Option<ScoConnectionOnConnectionCompleteRequest> {
3975        if let ScoConnectionEvent::OnConnectionComplete { payload } = self {
3976            Some((payload))
3977        } else {
3978            None
3979        }
3980    }
3981
3982    /// Decodes a message buffer as a [`ScoConnectionEvent`].
3983    fn decode(
3984        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3985    ) -> Result<ScoConnectionEvent, fidl::Error> {
3986        let (bytes, _handles) = buf.split_mut();
3987        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3988        debug_assert_eq!(tx_header.tx_id, 0);
3989        match tx_header.ordinal {
3990            0x193aa06408ba384d => {
3991                let mut out = fidl::new_empty!(
3992                    ScoConnectionOnConnectionCompleteRequest,
3993                    fidl::encoding::DefaultFuchsiaResourceDialect
3994                );
3995                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScoConnectionOnConnectionCompleteRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3996                Ok((ScoConnectionEvent::OnConnectionComplete { payload: out }))
3997            }
3998            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3999                Ok(ScoConnectionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4000            }
4001            _ => Err(fidl::Error::UnknownOrdinal {
4002                ordinal: tx_header.ordinal,
4003                protocol_name: <ScoConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4004            }),
4005        }
4006    }
4007}
4008
4009/// A Stream of incoming requests for fuchsia.bluetooth.bredr/ScoConnection.
4010pub struct ScoConnectionRequestStream {
4011    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4012    is_terminated: bool,
4013}
4014
4015impl std::marker::Unpin for ScoConnectionRequestStream {}
4016
4017impl futures::stream::FusedStream for ScoConnectionRequestStream {
4018    fn is_terminated(&self) -> bool {
4019        self.is_terminated
4020    }
4021}
4022
4023impl fidl::endpoints::RequestStream for ScoConnectionRequestStream {
4024    type Protocol = ScoConnectionMarker;
4025    type ControlHandle = ScoConnectionControlHandle;
4026
4027    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4028        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4029    }
4030
4031    fn control_handle(&self) -> Self::ControlHandle {
4032        ScoConnectionControlHandle { inner: self.inner.clone() }
4033    }
4034
4035    fn into_inner(
4036        self,
4037    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4038    {
4039        (self.inner, self.is_terminated)
4040    }
4041
4042    fn from_inner(
4043        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4044        is_terminated: bool,
4045    ) -> Self {
4046        Self { inner, is_terminated }
4047    }
4048}
4049
4050impl futures::Stream for ScoConnectionRequestStream {
4051    type Item = Result<ScoConnectionRequest, fidl::Error>;
4052
4053    fn poll_next(
4054        mut self: std::pin::Pin<&mut Self>,
4055        cx: &mut std::task::Context<'_>,
4056    ) -> std::task::Poll<Option<Self::Item>> {
4057        let this = &mut *self;
4058        if this.inner.check_shutdown(cx) {
4059            this.is_terminated = true;
4060            return std::task::Poll::Ready(None);
4061        }
4062        if this.is_terminated {
4063            panic!("polled ScoConnectionRequestStream after completion");
4064        }
4065        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4066            |bytes, handles| {
4067                match this.inner.channel().read_etc(cx, bytes, handles) {
4068                    std::task::Poll::Ready(Ok(())) => {}
4069                    std::task::Poll::Pending => return std::task::Poll::Pending,
4070                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4071                        this.is_terminated = true;
4072                        return std::task::Poll::Ready(None);
4073                    }
4074                    std::task::Poll::Ready(Err(e)) => {
4075                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4076                            e.into(),
4077                        ))))
4078                    }
4079                }
4080
4081                // A message has been received from the channel
4082                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4083
4084                std::task::Poll::Ready(Some(match header.ordinal {
4085                    0x6fb29eb1e16ac616 => {
4086                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4087                        let mut req = fidl::new_empty!(
4088                            fidl::encoding::EmptyPayload,
4089                            fidl::encoding::DefaultFuchsiaResourceDialect
4090                        );
4091                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4092                        let control_handle =
4093                            ScoConnectionControlHandle { inner: this.inner.clone() };
4094                        Ok(ScoConnectionRequest::Read {
4095                            responder: ScoConnectionReadResponder {
4096                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4097                                tx_id: header.tx_id,
4098                            },
4099                        })
4100                    }
4101                    0x394e1b2ff7f4a5a9 => {
4102                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4103                        let mut req = fidl::new_empty!(
4104                            ScoConnectionWriteRequest,
4105                            fidl::encoding::DefaultFuchsiaResourceDialect
4106                        );
4107                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScoConnectionWriteRequest>(&header, _body_bytes, handles, &mut req)?;
4108                        let control_handle =
4109                            ScoConnectionControlHandle { inner: this.inner.clone() };
4110                        Ok(ScoConnectionRequest::Write {
4111                            payload: req,
4112                            responder: ScoConnectionWriteResponder {
4113                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4114                                tx_id: header.tx_id,
4115                            },
4116                        })
4117                    }
4118                    _ if header.tx_id == 0
4119                        && header
4120                            .dynamic_flags()
4121                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4122                    {
4123                        Ok(ScoConnectionRequest::_UnknownMethod {
4124                            ordinal: header.ordinal,
4125                            control_handle: ScoConnectionControlHandle {
4126                                inner: this.inner.clone(),
4127                            },
4128                            method_type: fidl::MethodType::OneWay,
4129                        })
4130                    }
4131                    _ if header
4132                        .dynamic_flags()
4133                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4134                    {
4135                        this.inner.send_framework_err(
4136                            fidl::encoding::FrameworkErr::UnknownMethod,
4137                            header.tx_id,
4138                            header.ordinal,
4139                            header.dynamic_flags(),
4140                            (bytes, handles),
4141                        )?;
4142                        Ok(ScoConnectionRequest::_UnknownMethod {
4143                            ordinal: header.ordinal,
4144                            control_handle: ScoConnectionControlHandle {
4145                                inner: this.inner.clone(),
4146                            },
4147                            method_type: fidl::MethodType::TwoWay,
4148                        })
4149                    }
4150                    _ => Err(fidl::Error::UnknownOrdinal {
4151                        ordinal: header.ordinal,
4152                        protocol_name:
4153                            <ScoConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4154                    }),
4155                }))
4156            },
4157        )
4158    }
4159}
4160
4161/// A SCO connection. The connection is pending until the `OnConnectionComplete` event is sent,
4162/// which will always arrive first. If the connection fails, the protocol will be closed after the
4163/// error is delivered. If methods are called before the `OnConnectionComplete` event, they will
4164/// and the protocol will be closed.
4165#[derive(Debug)]
4166pub enum ScoConnectionRequest {
4167    /// Read the next inbound SCO payload.
4168    /// Hangs until new data is received.
4169    /// Only one Read request may be pending at a time. Additional requests will result in protocol
4170    /// closure.
4171    Read { responder: ScoConnectionReadResponder },
4172    /// Write `data` to the SCO connection.
4173    /// If Write tries to send more data than `max_tx_data_size`, the protocol will be closed.
4174    /// Only one Write request may be pending at a time. Additional requests will result in protocol
4175    /// closure.
4176    Write { payload: ScoConnectionWriteRequest, responder: ScoConnectionWriteResponder },
4177    /// An interaction was received which does not match any known method.
4178    #[non_exhaustive]
4179    _UnknownMethod {
4180        /// Ordinal of the method that was called.
4181        ordinal: u64,
4182        control_handle: ScoConnectionControlHandle,
4183        method_type: fidl::MethodType,
4184    },
4185}
4186
4187impl ScoConnectionRequest {
4188    #[allow(irrefutable_let_patterns)]
4189    pub fn into_read(self) -> Option<(ScoConnectionReadResponder)> {
4190        if let ScoConnectionRequest::Read { responder } = self {
4191            Some((responder))
4192        } else {
4193            None
4194        }
4195    }
4196
4197    #[allow(irrefutable_let_patterns)]
4198    pub fn into_write(self) -> Option<(ScoConnectionWriteRequest, ScoConnectionWriteResponder)> {
4199        if let ScoConnectionRequest::Write { payload, responder } = self {
4200            Some((payload, responder))
4201        } else {
4202            None
4203        }
4204    }
4205
4206    /// Name of the method defined in FIDL
4207    pub fn method_name(&self) -> &'static str {
4208        match *self {
4209            ScoConnectionRequest::Read { .. } => "read",
4210            ScoConnectionRequest::Write { .. } => "write",
4211            ScoConnectionRequest::_UnknownMethod {
4212                method_type: fidl::MethodType::OneWay, ..
4213            } => "unknown one-way method",
4214            ScoConnectionRequest::_UnknownMethod {
4215                method_type: fidl::MethodType::TwoWay, ..
4216            } => "unknown two-way method",
4217        }
4218    }
4219}
4220
4221#[derive(Debug, Clone)]
4222pub struct ScoConnectionControlHandle {
4223    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4224}
4225
4226impl fidl::endpoints::ControlHandle for ScoConnectionControlHandle {
4227    fn shutdown(&self) {
4228        self.inner.shutdown()
4229    }
4230    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4231        self.inner.shutdown_with_epitaph(status)
4232    }
4233
4234    fn is_closed(&self) -> bool {
4235        self.inner.channel().is_closed()
4236    }
4237    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4238        self.inner.channel().on_closed()
4239    }
4240
4241    #[cfg(target_os = "fuchsia")]
4242    fn signal_peer(
4243        &self,
4244        clear_mask: zx::Signals,
4245        set_mask: zx::Signals,
4246    ) -> Result<(), zx_status::Status> {
4247        use fidl::Peered;
4248        self.inner.channel().signal_peer(clear_mask, set_mask)
4249    }
4250}
4251
4252impl ScoConnectionControlHandle {
4253    pub fn send_on_connection_complete(
4254        &self,
4255        mut payload: &ScoConnectionOnConnectionCompleteRequest,
4256    ) -> Result<(), fidl::Error> {
4257        self.inner.send::<ScoConnectionOnConnectionCompleteRequest>(
4258            payload,
4259            0,
4260            0x193aa06408ba384d,
4261            fidl::encoding::DynamicFlags::FLEXIBLE,
4262        )
4263    }
4264}
4265
4266#[must_use = "FIDL methods require a response to be sent"]
4267#[derive(Debug)]
4268pub struct ScoConnectionReadResponder {
4269    control_handle: std::mem::ManuallyDrop<ScoConnectionControlHandle>,
4270    tx_id: u32,
4271}
4272
4273/// Set the the channel to be shutdown (see [`ScoConnectionControlHandle::shutdown`])
4274/// if the responder is dropped without sending a response, so that the client
4275/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4276impl std::ops::Drop for ScoConnectionReadResponder {
4277    fn drop(&mut self) {
4278        self.control_handle.shutdown();
4279        // Safety: drops once, never accessed again
4280        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4281    }
4282}
4283
4284impl fidl::endpoints::Responder for ScoConnectionReadResponder {
4285    type ControlHandle = ScoConnectionControlHandle;
4286
4287    fn control_handle(&self) -> &ScoConnectionControlHandle {
4288        &self.control_handle
4289    }
4290
4291    fn drop_without_shutdown(mut self) {
4292        // Safety: drops once, never accessed again due to mem::forget
4293        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4294        // Prevent Drop from running (which would shut down the channel)
4295        std::mem::forget(self);
4296    }
4297}
4298
4299impl ScoConnectionReadResponder {
4300    /// Sends a response to the FIDL transaction.
4301    ///
4302    /// Sets the channel to shutdown if an error occurs.
4303    pub fn send(self, mut payload: &ScoConnectionReadResponse) -> Result<(), fidl::Error> {
4304        let _result = self.send_raw(payload);
4305        if _result.is_err() {
4306            self.control_handle.shutdown();
4307        }
4308        self.drop_without_shutdown();
4309        _result
4310    }
4311
4312    /// Similar to "send" but does not shutdown the channel if an error occurs.
4313    pub fn send_no_shutdown_on_err(
4314        self,
4315        mut payload: &ScoConnectionReadResponse,
4316    ) -> Result<(), fidl::Error> {
4317        let _result = self.send_raw(payload);
4318        self.drop_without_shutdown();
4319        _result
4320    }
4321
4322    fn send_raw(&self, mut payload: &ScoConnectionReadResponse) -> Result<(), fidl::Error> {
4323        self.control_handle.inner.send::<fidl::encoding::FlexibleType<ScoConnectionReadResponse>>(
4324            fidl::encoding::Flexible::new(payload),
4325            self.tx_id,
4326            0x6fb29eb1e16ac616,
4327            fidl::encoding::DynamicFlags::FLEXIBLE,
4328        )
4329    }
4330}
4331
4332#[must_use = "FIDL methods require a response to be sent"]
4333#[derive(Debug)]
4334pub struct ScoConnectionWriteResponder {
4335    control_handle: std::mem::ManuallyDrop<ScoConnectionControlHandle>,
4336    tx_id: u32,
4337}
4338
4339/// Set the the channel to be shutdown (see [`ScoConnectionControlHandle::shutdown`])
4340/// if the responder is dropped without sending a response, so that the client
4341/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4342impl std::ops::Drop for ScoConnectionWriteResponder {
4343    fn drop(&mut self) {
4344        self.control_handle.shutdown();
4345        // Safety: drops once, never accessed again
4346        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4347    }
4348}
4349
4350impl fidl::endpoints::Responder for ScoConnectionWriteResponder {
4351    type ControlHandle = ScoConnectionControlHandle;
4352
4353    fn control_handle(&self) -> &ScoConnectionControlHandle {
4354        &self.control_handle
4355    }
4356
4357    fn drop_without_shutdown(mut self) {
4358        // Safety: drops once, never accessed again due to mem::forget
4359        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4360        // Prevent Drop from running (which would shut down the channel)
4361        std::mem::forget(self);
4362    }
4363}
4364
4365impl ScoConnectionWriteResponder {
4366    /// Sends a response to the FIDL transaction.
4367    ///
4368    /// Sets the channel to shutdown if an error occurs.
4369    pub fn send(self) -> Result<(), fidl::Error> {
4370        let _result = self.send_raw();
4371        if _result.is_err() {
4372            self.control_handle.shutdown();
4373        }
4374        self.drop_without_shutdown();
4375        _result
4376    }
4377
4378    /// Similar to "send" but does not shutdown the channel if an error occurs.
4379    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4380        let _result = self.send_raw();
4381        self.drop_without_shutdown();
4382        _result
4383    }
4384
4385    fn send_raw(&self) -> Result<(), fidl::Error> {
4386        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4387            fidl::encoding::Flexible::new(()),
4388            self.tx_id,
4389            0x394e1b2ff7f4a5a9,
4390            fidl::encoding::DynamicFlags::FLEXIBLE,
4391        )
4392    }
4393}
4394
4395#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4396pub struct SearchResultsMarker;
4397
4398impl fidl::endpoints::ProtocolMarker for SearchResultsMarker {
4399    type Proxy = SearchResultsProxy;
4400    type RequestStream = SearchResultsRequestStream;
4401    #[cfg(target_os = "fuchsia")]
4402    type SynchronousProxy = SearchResultsSynchronousProxy;
4403
4404    const DEBUG_NAME: &'static str = "(anonymous) SearchResults";
4405}
4406
4407pub trait SearchResultsProxyInterface: Send + Sync {
4408    type ServiceFoundResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4409    fn r#service_found(
4410        &self,
4411        peer_id: &fidl_fuchsia_bluetooth::PeerId,
4412        protocol: Option<&[ProtocolDescriptor]>,
4413        attributes: &[Attribute],
4414    ) -> Self::ServiceFoundResponseFut;
4415}
4416#[derive(Debug)]
4417#[cfg(target_os = "fuchsia")]
4418pub struct SearchResultsSynchronousProxy {
4419    client: fidl::client::sync::Client,
4420}
4421
4422#[cfg(target_os = "fuchsia")]
4423impl fidl::endpoints::SynchronousProxy for SearchResultsSynchronousProxy {
4424    type Proxy = SearchResultsProxy;
4425    type Protocol = SearchResultsMarker;
4426
4427    fn from_channel(inner: fidl::Channel) -> Self {
4428        Self::new(inner)
4429    }
4430
4431    fn into_channel(self) -> fidl::Channel {
4432        self.client.into_channel()
4433    }
4434
4435    fn as_channel(&self) -> &fidl::Channel {
4436        self.client.as_channel()
4437    }
4438}
4439
4440#[cfg(target_os = "fuchsia")]
4441impl SearchResultsSynchronousProxy {
4442    pub fn new(channel: fidl::Channel) -> Self {
4443        let protocol_name = <SearchResultsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4444        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4445    }
4446
4447    pub fn into_channel(self) -> fidl::Channel {
4448        self.client.into_channel()
4449    }
4450
4451    /// Waits until an event arrives and returns it. It is safe for other
4452    /// threads to make concurrent requests while waiting for an event.
4453    pub fn wait_for_event(
4454        &self,
4455        deadline: zx::MonotonicInstant,
4456    ) -> Result<SearchResultsEvent, fidl::Error> {
4457        SearchResultsEvent::decode(self.client.wait_for_event(deadline)?)
4458    }
4459
4460    /// Called when a search this client added finds a matching service on a peer.
4461    /// `peer_id` is the peer the service was found on.
4462    /// `protocol` includes the ProtocolDescriptorList in the service record if it exists
4463    /// (it is also included in `attributes`.)
4464    /// `attributes` contains all attributes requested from the search that are present on the
4465    /// peer record.  It may also include additional attributes.
4466    /// Each ServiceFound call should be acknowledged by replying.
4467    /// A limited amount of unacknowledged results will be sent on the channel. Results may be
4468    /// dropped if results are received while too many results are unacknowledged.
4469    pub fn r#service_found(
4470        &self,
4471        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
4472        mut protocol: Option<&[ProtocolDescriptor]>,
4473        mut attributes: &[Attribute],
4474        ___deadline: zx::MonotonicInstant,
4475    ) -> Result<(), fidl::Error> {
4476        let _response = self.client.send_query::<
4477            SearchResultsServiceFoundRequest,
4478            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
4479        >(
4480            (peer_id, protocol, attributes,),
4481            0x526509a842ebd43c,
4482            fidl::encoding::DynamicFlags::FLEXIBLE,
4483            ___deadline,
4484        )?
4485        .into_result::<SearchResultsMarker>("service_found")?;
4486        Ok(_response)
4487    }
4488}
4489
4490#[cfg(target_os = "fuchsia")]
4491impl From<SearchResultsSynchronousProxy> for zx::Handle {
4492    fn from(value: SearchResultsSynchronousProxy) -> Self {
4493        value.into_channel().into()
4494    }
4495}
4496
4497#[cfg(target_os = "fuchsia")]
4498impl From<fidl::Channel> for SearchResultsSynchronousProxy {
4499    fn from(value: fidl::Channel) -> Self {
4500        Self::new(value)
4501    }
4502}
4503
4504#[derive(Debug, Clone)]
4505pub struct SearchResultsProxy {
4506    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4507}
4508
4509impl fidl::endpoints::Proxy for SearchResultsProxy {
4510    type Protocol = SearchResultsMarker;
4511
4512    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4513        Self::new(inner)
4514    }
4515
4516    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4517        self.client.into_channel().map_err(|client| Self { client })
4518    }
4519
4520    fn as_channel(&self) -> &::fidl::AsyncChannel {
4521        self.client.as_channel()
4522    }
4523}
4524
4525impl SearchResultsProxy {
4526    /// Create a new Proxy for fuchsia.bluetooth.bredr/SearchResults.
4527    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4528        let protocol_name = <SearchResultsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4529        Self { client: fidl::client::Client::new(channel, protocol_name) }
4530    }
4531
4532    /// Get a Stream of events from the remote end of the protocol.
4533    ///
4534    /// # Panics
4535    ///
4536    /// Panics if the event stream was already taken.
4537    pub fn take_event_stream(&self) -> SearchResultsEventStream {
4538        SearchResultsEventStream { event_receiver: self.client.take_event_receiver() }
4539    }
4540
4541    /// Called when a search this client added finds a matching service on a peer.
4542    /// `peer_id` is the peer the service was found on.
4543    /// `protocol` includes the ProtocolDescriptorList in the service record if it exists
4544    /// (it is also included in `attributes`.)
4545    /// `attributes` contains all attributes requested from the search that are present on the
4546    /// peer record.  It may also include additional attributes.
4547    /// Each ServiceFound call should be acknowledged by replying.
4548    /// A limited amount of unacknowledged results will be sent on the channel. Results may be
4549    /// dropped if results are received while too many results are unacknowledged.
4550    pub fn r#service_found(
4551        &self,
4552        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
4553        mut protocol: Option<&[ProtocolDescriptor]>,
4554        mut attributes: &[Attribute],
4555    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4556        SearchResultsProxyInterface::r#service_found(self, peer_id, protocol, attributes)
4557    }
4558}
4559
4560impl SearchResultsProxyInterface for SearchResultsProxy {
4561    type ServiceFoundResponseFut =
4562        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4563    fn r#service_found(
4564        &self,
4565        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
4566        mut protocol: Option<&[ProtocolDescriptor]>,
4567        mut attributes: &[Attribute],
4568    ) -> Self::ServiceFoundResponseFut {
4569        fn _decode(
4570            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4571        ) -> Result<(), fidl::Error> {
4572            let _response = fidl::client::decode_transaction_body::<
4573                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
4574                fidl::encoding::DefaultFuchsiaResourceDialect,
4575                0x526509a842ebd43c,
4576            >(_buf?)?
4577            .into_result::<SearchResultsMarker>("service_found")?;
4578            Ok(_response)
4579        }
4580        self.client.send_query_and_decode::<SearchResultsServiceFoundRequest, ()>(
4581            (peer_id, protocol, attributes),
4582            0x526509a842ebd43c,
4583            fidl::encoding::DynamicFlags::FLEXIBLE,
4584            _decode,
4585        )
4586    }
4587}
4588
4589pub struct SearchResultsEventStream {
4590    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4591}
4592
4593impl std::marker::Unpin for SearchResultsEventStream {}
4594
4595impl futures::stream::FusedStream for SearchResultsEventStream {
4596    fn is_terminated(&self) -> bool {
4597        self.event_receiver.is_terminated()
4598    }
4599}
4600
4601impl futures::Stream for SearchResultsEventStream {
4602    type Item = Result<SearchResultsEvent, fidl::Error>;
4603
4604    fn poll_next(
4605        mut self: std::pin::Pin<&mut Self>,
4606        cx: &mut std::task::Context<'_>,
4607    ) -> std::task::Poll<Option<Self::Item>> {
4608        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4609            &mut self.event_receiver,
4610            cx
4611        )?) {
4612            Some(buf) => std::task::Poll::Ready(Some(SearchResultsEvent::decode(buf))),
4613            None => std::task::Poll::Ready(None),
4614        }
4615    }
4616}
4617
4618#[derive(Debug)]
4619pub enum SearchResultsEvent {
4620    #[non_exhaustive]
4621    _UnknownEvent {
4622        /// Ordinal of the event that was sent.
4623        ordinal: u64,
4624    },
4625}
4626
4627impl SearchResultsEvent {
4628    /// Decodes a message buffer as a [`SearchResultsEvent`].
4629    fn decode(
4630        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4631    ) -> Result<SearchResultsEvent, fidl::Error> {
4632        let (bytes, _handles) = buf.split_mut();
4633        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4634        debug_assert_eq!(tx_header.tx_id, 0);
4635        match tx_header.ordinal {
4636            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4637                Ok(SearchResultsEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4638            }
4639            _ => Err(fidl::Error::UnknownOrdinal {
4640                ordinal: tx_header.ordinal,
4641                protocol_name: <SearchResultsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4642            }),
4643        }
4644    }
4645}
4646
4647/// A Stream of incoming requests for fuchsia.bluetooth.bredr/SearchResults.
4648pub struct SearchResultsRequestStream {
4649    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4650    is_terminated: bool,
4651}
4652
4653impl std::marker::Unpin for SearchResultsRequestStream {}
4654
4655impl futures::stream::FusedStream for SearchResultsRequestStream {
4656    fn is_terminated(&self) -> bool {
4657        self.is_terminated
4658    }
4659}
4660
4661impl fidl::endpoints::RequestStream for SearchResultsRequestStream {
4662    type Protocol = SearchResultsMarker;
4663    type ControlHandle = SearchResultsControlHandle;
4664
4665    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4666        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4667    }
4668
4669    fn control_handle(&self) -> Self::ControlHandle {
4670        SearchResultsControlHandle { inner: self.inner.clone() }
4671    }
4672
4673    fn into_inner(
4674        self,
4675    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4676    {
4677        (self.inner, self.is_terminated)
4678    }
4679
4680    fn from_inner(
4681        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4682        is_terminated: bool,
4683    ) -> Self {
4684        Self { inner, is_terminated }
4685    }
4686}
4687
4688impl futures::Stream for SearchResultsRequestStream {
4689    type Item = Result<SearchResultsRequest, fidl::Error>;
4690
4691    fn poll_next(
4692        mut self: std::pin::Pin<&mut Self>,
4693        cx: &mut std::task::Context<'_>,
4694    ) -> std::task::Poll<Option<Self::Item>> {
4695        let this = &mut *self;
4696        if this.inner.check_shutdown(cx) {
4697            this.is_terminated = true;
4698            return std::task::Poll::Ready(None);
4699        }
4700        if this.is_terminated {
4701            panic!("polled SearchResultsRequestStream after completion");
4702        }
4703        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4704            |bytes, handles| {
4705                match this.inner.channel().read_etc(cx, bytes, handles) {
4706                    std::task::Poll::Ready(Ok(())) => {}
4707                    std::task::Poll::Pending => return std::task::Poll::Pending,
4708                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4709                        this.is_terminated = true;
4710                        return std::task::Poll::Ready(None);
4711                    }
4712                    std::task::Poll::Ready(Err(e)) => {
4713                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4714                            e.into(),
4715                        ))))
4716                    }
4717                }
4718
4719                // A message has been received from the channel
4720                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4721
4722                std::task::Poll::Ready(Some(match header.ordinal {
4723                    0x526509a842ebd43c => {
4724                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4725                        let mut req = fidl::new_empty!(
4726                            SearchResultsServiceFoundRequest,
4727                            fidl::encoding::DefaultFuchsiaResourceDialect
4728                        );
4729                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SearchResultsServiceFoundRequest>(&header, _body_bytes, handles, &mut req)?;
4730                        let control_handle =
4731                            SearchResultsControlHandle { inner: this.inner.clone() };
4732                        Ok(SearchResultsRequest::ServiceFound {
4733                            peer_id: req.peer_id,
4734                            protocol: req.protocol,
4735                            attributes: req.attributes,
4736
4737                            responder: SearchResultsServiceFoundResponder {
4738                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4739                                tx_id: header.tx_id,
4740                            },
4741                        })
4742                    }
4743                    _ if header.tx_id == 0
4744                        && header
4745                            .dynamic_flags()
4746                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4747                    {
4748                        Ok(SearchResultsRequest::_UnknownMethod {
4749                            ordinal: header.ordinal,
4750                            control_handle: SearchResultsControlHandle {
4751                                inner: this.inner.clone(),
4752                            },
4753                            method_type: fidl::MethodType::OneWay,
4754                        })
4755                    }
4756                    _ if header
4757                        .dynamic_flags()
4758                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4759                    {
4760                        this.inner.send_framework_err(
4761                            fidl::encoding::FrameworkErr::UnknownMethod,
4762                            header.tx_id,
4763                            header.ordinal,
4764                            header.dynamic_flags(),
4765                            (bytes, handles),
4766                        )?;
4767                        Ok(SearchResultsRequest::_UnknownMethod {
4768                            ordinal: header.ordinal,
4769                            control_handle: SearchResultsControlHandle {
4770                                inner: this.inner.clone(),
4771                            },
4772                            method_type: fidl::MethodType::TwoWay,
4773                        })
4774                    }
4775                    _ => Err(fidl::Error::UnknownOrdinal {
4776                        ordinal: header.ordinal,
4777                        protocol_name:
4778                            <SearchResultsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4779                    }),
4780                }))
4781            },
4782        )
4783    }
4784}
4785
4786/// Represents an active search which can produce results when peers are connected.  Closing this
4787/// protocol will result in the associated search not being performed on new connected peers.
4788#[derive(Debug)]
4789pub enum SearchResultsRequest {
4790    /// Called when a search this client added finds a matching service on a peer.
4791    /// `peer_id` is the peer the service was found on.
4792    /// `protocol` includes the ProtocolDescriptorList in the service record if it exists
4793    /// (it is also included in `attributes`.)
4794    /// `attributes` contains all attributes requested from the search that are present on the
4795    /// peer record.  It may also include additional attributes.
4796    /// Each ServiceFound call should be acknowledged by replying.
4797    /// A limited amount of unacknowledged results will be sent on the channel. Results may be
4798    /// dropped if results are received while too many results are unacknowledged.
4799    ServiceFound {
4800        peer_id: fidl_fuchsia_bluetooth::PeerId,
4801        protocol: Option<Vec<ProtocolDescriptor>>,
4802        attributes: Vec<Attribute>,
4803        responder: SearchResultsServiceFoundResponder,
4804    },
4805    /// An interaction was received which does not match any known method.
4806    #[non_exhaustive]
4807    _UnknownMethod {
4808        /// Ordinal of the method that was called.
4809        ordinal: u64,
4810        control_handle: SearchResultsControlHandle,
4811        method_type: fidl::MethodType,
4812    },
4813}
4814
4815impl SearchResultsRequest {
4816    #[allow(irrefutable_let_patterns)]
4817    pub fn into_service_found(
4818        self,
4819    ) -> Option<(
4820        fidl_fuchsia_bluetooth::PeerId,
4821        Option<Vec<ProtocolDescriptor>>,
4822        Vec<Attribute>,
4823        SearchResultsServiceFoundResponder,
4824    )> {
4825        if let SearchResultsRequest::ServiceFound { peer_id, protocol, attributes, responder } =
4826            self
4827        {
4828            Some((peer_id, protocol, attributes, responder))
4829        } else {
4830            None
4831        }
4832    }
4833
4834    /// Name of the method defined in FIDL
4835    pub fn method_name(&self) -> &'static str {
4836        match *self {
4837            SearchResultsRequest::ServiceFound { .. } => "service_found",
4838            SearchResultsRequest::_UnknownMethod {
4839                method_type: fidl::MethodType::OneWay, ..
4840            } => "unknown one-way method",
4841            SearchResultsRequest::_UnknownMethod {
4842                method_type: fidl::MethodType::TwoWay, ..
4843            } => "unknown two-way method",
4844        }
4845    }
4846}
4847
4848#[derive(Debug, Clone)]
4849pub struct SearchResultsControlHandle {
4850    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4851}
4852
4853impl fidl::endpoints::ControlHandle for SearchResultsControlHandle {
4854    fn shutdown(&self) {
4855        self.inner.shutdown()
4856    }
4857    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4858        self.inner.shutdown_with_epitaph(status)
4859    }
4860
4861    fn is_closed(&self) -> bool {
4862        self.inner.channel().is_closed()
4863    }
4864    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4865        self.inner.channel().on_closed()
4866    }
4867
4868    #[cfg(target_os = "fuchsia")]
4869    fn signal_peer(
4870        &self,
4871        clear_mask: zx::Signals,
4872        set_mask: zx::Signals,
4873    ) -> Result<(), zx_status::Status> {
4874        use fidl::Peered;
4875        self.inner.channel().signal_peer(clear_mask, set_mask)
4876    }
4877}
4878
4879impl SearchResultsControlHandle {}
4880
4881#[must_use = "FIDL methods require a response to be sent"]
4882#[derive(Debug)]
4883pub struct SearchResultsServiceFoundResponder {
4884    control_handle: std::mem::ManuallyDrop<SearchResultsControlHandle>,
4885    tx_id: u32,
4886}
4887
4888/// Set the the channel to be shutdown (see [`SearchResultsControlHandle::shutdown`])
4889/// if the responder is dropped without sending a response, so that the client
4890/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4891impl std::ops::Drop for SearchResultsServiceFoundResponder {
4892    fn drop(&mut self) {
4893        self.control_handle.shutdown();
4894        // Safety: drops once, never accessed again
4895        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4896    }
4897}
4898
4899impl fidl::endpoints::Responder for SearchResultsServiceFoundResponder {
4900    type ControlHandle = SearchResultsControlHandle;
4901
4902    fn control_handle(&self) -> &SearchResultsControlHandle {
4903        &self.control_handle
4904    }
4905
4906    fn drop_without_shutdown(mut self) {
4907        // Safety: drops once, never accessed again due to mem::forget
4908        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4909        // Prevent Drop from running (which would shut down the channel)
4910        std::mem::forget(self);
4911    }
4912}
4913
4914impl SearchResultsServiceFoundResponder {
4915    /// Sends a response to the FIDL transaction.
4916    ///
4917    /// Sets the channel to shutdown if an error occurs.
4918    pub fn send(self) -> Result<(), fidl::Error> {
4919        let _result = self.send_raw();
4920        if _result.is_err() {
4921            self.control_handle.shutdown();
4922        }
4923        self.drop_without_shutdown();
4924        _result
4925    }
4926
4927    /// Similar to "send" but does not shutdown the channel if an error occurs.
4928    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4929        let _result = self.send_raw();
4930        self.drop_without_shutdown();
4931        _result
4932    }
4933
4934    fn send_raw(&self) -> Result<(), fidl::Error> {
4935        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4936            fidl::encoding::Flexible::new(()),
4937            self.tx_id,
4938            0x526509a842ebd43c,
4939            fidl::encoding::DynamicFlags::FLEXIBLE,
4940        )
4941    }
4942}
4943
4944mod internal {
4945    use super::*;
4946
4947    impl fidl::encoding::ResourceTypeMarker for AudioOffloadExtStartAudioOffloadRequest {
4948        type Borrowed<'a> = &'a mut Self;
4949        fn take_or_borrow<'a>(
4950            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4951        ) -> Self::Borrowed<'a> {
4952            value
4953        }
4954    }
4955
4956    unsafe impl fidl::encoding::TypeMarker for AudioOffloadExtStartAudioOffloadRequest {
4957        type Owned = Self;
4958
4959        #[inline(always)]
4960        fn inline_align(_context: fidl::encoding::Context) -> usize {
4961            8
4962        }
4963
4964        #[inline(always)]
4965        fn inline_size(_context: fidl::encoding::Context) -> usize {
4966            24
4967        }
4968    }
4969
4970    unsafe impl
4971        fidl::encoding::Encode<
4972            AudioOffloadExtStartAudioOffloadRequest,
4973            fidl::encoding::DefaultFuchsiaResourceDialect,
4974        > for &mut AudioOffloadExtStartAudioOffloadRequest
4975    {
4976        #[inline]
4977        unsafe fn encode(
4978            self,
4979            encoder: &mut fidl::encoding::Encoder<
4980                '_,
4981                fidl::encoding::DefaultFuchsiaResourceDialect,
4982            >,
4983            offset: usize,
4984            _depth: fidl::encoding::Depth,
4985        ) -> fidl::Result<()> {
4986            encoder.debug_check_bounds::<AudioOffloadExtStartAudioOffloadRequest>(offset);
4987            // Delegate to tuple encoding.
4988            fidl::encoding::Encode::<
4989                AudioOffloadExtStartAudioOffloadRequest,
4990                fidl::encoding::DefaultFuchsiaResourceDialect,
4991            >::encode(
4992                (
4993                    <AudioOffloadConfiguration as fidl::encoding::ValueTypeMarker>::borrow(
4994                        &self.configuration,
4995                    ),
4996                    <fidl::encoding::Endpoint<
4997                        fidl::endpoints::ServerEnd<AudioOffloadControllerMarker>,
4998                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4999                        &mut self.controller
5000                    ),
5001                ),
5002                encoder,
5003                offset,
5004                _depth,
5005            )
5006        }
5007    }
5008    unsafe impl<
5009            T0: fidl::encoding::Encode<
5010                AudioOffloadConfiguration,
5011                fidl::encoding::DefaultFuchsiaResourceDialect,
5012            >,
5013            T1: fidl::encoding::Encode<
5014                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioOffloadControllerMarker>>,
5015                fidl::encoding::DefaultFuchsiaResourceDialect,
5016            >,
5017        >
5018        fidl::encoding::Encode<
5019            AudioOffloadExtStartAudioOffloadRequest,
5020            fidl::encoding::DefaultFuchsiaResourceDialect,
5021        > for (T0, T1)
5022    {
5023        #[inline]
5024        unsafe fn encode(
5025            self,
5026            encoder: &mut fidl::encoding::Encoder<
5027                '_,
5028                fidl::encoding::DefaultFuchsiaResourceDialect,
5029            >,
5030            offset: usize,
5031            depth: fidl::encoding::Depth,
5032        ) -> fidl::Result<()> {
5033            encoder.debug_check_bounds::<AudioOffloadExtStartAudioOffloadRequest>(offset);
5034            // Zero out padding regions. There's no need to apply masks
5035            // because the unmasked parts will be overwritten by fields.
5036            unsafe {
5037                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
5038                (ptr as *mut u64).write_unaligned(0);
5039            }
5040            // Write the fields.
5041            self.0.encode(encoder, offset + 0, depth)?;
5042            self.1.encode(encoder, offset + 16, depth)?;
5043            Ok(())
5044        }
5045    }
5046
5047    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5048        for AudioOffloadExtStartAudioOffloadRequest
5049    {
5050        #[inline(always)]
5051        fn new_empty() -> Self {
5052            Self {
5053                configuration: fidl::new_empty!(
5054                    AudioOffloadConfiguration,
5055                    fidl::encoding::DefaultFuchsiaResourceDialect
5056                ),
5057                controller: fidl::new_empty!(
5058                    fidl::encoding::Endpoint<
5059                        fidl::endpoints::ServerEnd<AudioOffloadControllerMarker>,
5060                    >,
5061                    fidl::encoding::DefaultFuchsiaResourceDialect
5062                ),
5063            }
5064        }
5065
5066        #[inline]
5067        unsafe fn decode(
5068            &mut self,
5069            decoder: &mut fidl::encoding::Decoder<
5070                '_,
5071                fidl::encoding::DefaultFuchsiaResourceDialect,
5072            >,
5073            offset: usize,
5074            _depth: fidl::encoding::Depth,
5075        ) -> fidl::Result<()> {
5076            decoder.debug_check_bounds::<Self>(offset);
5077            // Verify that padding bytes are zero.
5078            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
5079            let padval = unsafe { (ptr as *const u64).read_unaligned() };
5080            let mask = 0xffffffff00000000u64;
5081            let maskedval = padval & mask;
5082            if maskedval != 0 {
5083                return Err(fidl::Error::NonZeroPadding {
5084                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
5085                });
5086            }
5087            fidl::decode!(
5088                AudioOffloadConfiguration,
5089                fidl::encoding::DefaultFuchsiaResourceDialect,
5090                &mut self.configuration,
5091                decoder,
5092                offset + 0,
5093                _depth
5094            )?;
5095            fidl::decode!(
5096                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioOffloadControllerMarker>>,
5097                fidl::encoding::DefaultFuchsiaResourceDialect,
5098                &mut self.controller,
5099                decoder,
5100                offset + 16,
5101                _depth
5102            )?;
5103            Ok(())
5104        }
5105    }
5106
5107    impl fidl::encoding::ResourceTypeMarker for ConnectionReceiverConnectedRequest {
5108        type Borrowed<'a> = &'a mut Self;
5109        fn take_or_borrow<'a>(
5110            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5111        ) -> Self::Borrowed<'a> {
5112            value
5113        }
5114    }
5115
5116    unsafe impl fidl::encoding::TypeMarker for ConnectionReceiverConnectedRequest {
5117        type Owned = Self;
5118
5119        #[inline(always)]
5120        fn inline_align(_context: fidl::encoding::Context) -> usize {
5121            8
5122        }
5123
5124        #[inline(always)]
5125        fn inline_size(_context: fidl::encoding::Context) -> usize {
5126            40
5127        }
5128    }
5129
5130    unsafe impl
5131        fidl::encoding::Encode<
5132            ConnectionReceiverConnectedRequest,
5133            fidl::encoding::DefaultFuchsiaResourceDialect,
5134        > for &mut ConnectionReceiverConnectedRequest
5135    {
5136        #[inline]
5137        unsafe fn encode(
5138            self,
5139            encoder: &mut fidl::encoding::Encoder<
5140                '_,
5141                fidl::encoding::DefaultFuchsiaResourceDialect,
5142            >,
5143            offset: usize,
5144            _depth: fidl::encoding::Depth,
5145        ) -> fidl::Result<()> {
5146            encoder.debug_check_bounds::<ConnectionReceiverConnectedRequest>(offset);
5147            // Delegate to tuple encoding.
5148            fidl::encoding::Encode::<ConnectionReceiverConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5149                (
5150                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.peer_id),
5151                    <Channel as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.channel),
5152                    <fidl::encoding::Vector<ProtocolDescriptor, 255> as fidl::encoding::ValueTypeMarker>::borrow(&self.protocol),
5153                ),
5154                encoder, offset, _depth
5155            )
5156        }
5157    }
5158    unsafe impl<
5159            T0: fidl::encoding::Encode<
5160                fidl_fuchsia_bluetooth::PeerId,
5161                fidl::encoding::DefaultFuchsiaResourceDialect,
5162            >,
5163            T1: fidl::encoding::Encode<Channel, fidl::encoding::DefaultFuchsiaResourceDialect>,
5164            T2: fidl::encoding::Encode<
5165                fidl::encoding::Vector<ProtocolDescriptor, 255>,
5166                fidl::encoding::DefaultFuchsiaResourceDialect,
5167            >,
5168        >
5169        fidl::encoding::Encode<
5170            ConnectionReceiverConnectedRequest,
5171            fidl::encoding::DefaultFuchsiaResourceDialect,
5172        > for (T0, T1, T2)
5173    {
5174        #[inline]
5175        unsafe fn encode(
5176            self,
5177            encoder: &mut fidl::encoding::Encoder<
5178                '_,
5179                fidl::encoding::DefaultFuchsiaResourceDialect,
5180            >,
5181            offset: usize,
5182            depth: fidl::encoding::Depth,
5183        ) -> fidl::Result<()> {
5184            encoder.debug_check_bounds::<ConnectionReceiverConnectedRequest>(offset);
5185            // Zero out padding regions. There's no need to apply masks
5186            // because the unmasked parts will be overwritten by fields.
5187            // Write the fields.
5188            self.0.encode(encoder, offset + 0, depth)?;
5189            self.1.encode(encoder, offset + 8, depth)?;
5190            self.2.encode(encoder, offset + 24, depth)?;
5191            Ok(())
5192        }
5193    }
5194
5195    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5196        for ConnectionReceiverConnectedRequest
5197    {
5198        #[inline(always)]
5199        fn new_empty() -> Self {
5200            Self {
5201                peer_id: fidl::new_empty!(
5202                    fidl_fuchsia_bluetooth::PeerId,
5203                    fidl::encoding::DefaultFuchsiaResourceDialect
5204                ),
5205                channel: fidl::new_empty!(Channel, fidl::encoding::DefaultFuchsiaResourceDialect),
5206                protocol: fidl::new_empty!(fidl::encoding::Vector<ProtocolDescriptor, 255>, fidl::encoding::DefaultFuchsiaResourceDialect),
5207            }
5208        }
5209
5210        #[inline]
5211        unsafe fn decode(
5212            &mut self,
5213            decoder: &mut fidl::encoding::Decoder<
5214                '_,
5215                fidl::encoding::DefaultFuchsiaResourceDialect,
5216            >,
5217            offset: usize,
5218            _depth: fidl::encoding::Depth,
5219        ) -> fidl::Result<()> {
5220            decoder.debug_check_bounds::<Self>(offset);
5221            // Verify that padding bytes are zero.
5222            fidl::decode!(
5223                fidl_fuchsia_bluetooth::PeerId,
5224                fidl::encoding::DefaultFuchsiaResourceDialect,
5225                &mut self.peer_id,
5226                decoder,
5227                offset + 0,
5228                _depth
5229            )?;
5230            fidl::decode!(
5231                Channel,
5232                fidl::encoding::DefaultFuchsiaResourceDialect,
5233                &mut self.channel,
5234                decoder,
5235                offset + 8,
5236                _depth
5237            )?;
5238            fidl::decode!(fidl::encoding::Vector<ProtocolDescriptor, 255>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.protocol, decoder, offset + 24, _depth)?;
5239            Ok(())
5240        }
5241    }
5242
5243    impl fidl::encoding::ResourceTypeMarker for ProfileConnectResponse {
5244        type Borrowed<'a> = &'a mut Self;
5245        fn take_or_borrow<'a>(
5246            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5247        ) -> Self::Borrowed<'a> {
5248            value
5249        }
5250    }
5251
5252    unsafe impl fidl::encoding::TypeMarker for ProfileConnectResponse {
5253        type Owned = Self;
5254
5255        #[inline(always)]
5256        fn inline_align(_context: fidl::encoding::Context) -> usize {
5257            8
5258        }
5259
5260        #[inline(always)]
5261        fn inline_size(_context: fidl::encoding::Context) -> usize {
5262            16
5263        }
5264    }
5265
5266    unsafe impl
5267        fidl::encoding::Encode<
5268            ProfileConnectResponse,
5269            fidl::encoding::DefaultFuchsiaResourceDialect,
5270        > for &mut ProfileConnectResponse
5271    {
5272        #[inline]
5273        unsafe fn encode(
5274            self,
5275            encoder: &mut fidl::encoding::Encoder<
5276                '_,
5277                fidl::encoding::DefaultFuchsiaResourceDialect,
5278            >,
5279            offset: usize,
5280            _depth: fidl::encoding::Depth,
5281        ) -> fidl::Result<()> {
5282            encoder.debug_check_bounds::<ProfileConnectResponse>(offset);
5283            // Delegate to tuple encoding.
5284            fidl::encoding::Encode::<
5285                ProfileConnectResponse,
5286                fidl::encoding::DefaultFuchsiaResourceDialect,
5287            >::encode(
5288                (<Channel as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5289                    &mut self.channel,
5290                ),),
5291                encoder,
5292                offset,
5293                _depth,
5294            )
5295        }
5296    }
5297    unsafe impl<T0: fidl::encoding::Encode<Channel, fidl::encoding::DefaultFuchsiaResourceDialect>>
5298        fidl::encoding::Encode<
5299            ProfileConnectResponse,
5300            fidl::encoding::DefaultFuchsiaResourceDialect,
5301        > for (T0,)
5302    {
5303        #[inline]
5304        unsafe fn encode(
5305            self,
5306            encoder: &mut fidl::encoding::Encoder<
5307                '_,
5308                fidl::encoding::DefaultFuchsiaResourceDialect,
5309            >,
5310            offset: usize,
5311            depth: fidl::encoding::Depth,
5312        ) -> fidl::Result<()> {
5313            encoder.debug_check_bounds::<ProfileConnectResponse>(offset);
5314            // Zero out padding regions. There's no need to apply masks
5315            // because the unmasked parts will be overwritten by fields.
5316            // Write the fields.
5317            self.0.encode(encoder, offset + 0, depth)?;
5318            Ok(())
5319        }
5320    }
5321
5322    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5323        for ProfileConnectResponse
5324    {
5325        #[inline(always)]
5326        fn new_empty() -> Self {
5327            Self {
5328                channel: fidl::new_empty!(Channel, fidl::encoding::DefaultFuchsiaResourceDialect),
5329            }
5330        }
5331
5332        #[inline]
5333        unsafe fn decode(
5334            &mut self,
5335            decoder: &mut fidl::encoding::Decoder<
5336                '_,
5337                fidl::encoding::DefaultFuchsiaResourceDialect,
5338            >,
5339            offset: usize,
5340            _depth: fidl::encoding::Depth,
5341        ) -> fidl::Result<()> {
5342            decoder.debug_check_bounds::<Self>(offset);
5343            // Verify that padding bytes are zero.
5344            fidl::decode!(
5345                Channel,
5346                fidl::encoding::DefaultFuchsiaResourceDialect,
5347                &mut self.channel,
5348                decoder,
5349                offset + 0,
5350                _depth
5351            )?;
5352            Ok(())
5353        }
5354    }
5355
5356    impl Channel {
5357        #[inline(always)]
5358        fn max_ordinal_present(&self) -> u64 {
5359            if let Some(_) = self.connection {
5360                return 8;
5361            }
5362            if let Some(_) = self.ext_audio_offload {
5363                return 7;
5364            }
5365            if let Some(_) = self.ext_l2cap {
5366                return 6;
5367            }
5368            if let Some(_) = self.flush_timeout {
5369                return 5;
5370            }
5371            if let Some(_) = self.ext_direction {
5372                return 4;
5373            }
5374            if let Some(_) = self.max_tx_sdu_size {
5375                return 3;
5376            }
5377            if let Some(_) = self.channel_mode {
5378                return 2;
5379            }
5380            if let Some(_) = self.socket {
5381                return 1;
5382            }
5383            0
5384        }
5385    }
5386
5387    impl fidl::encoding::ResourceTypeMarker for Channel {
5388        type Borrowed<'a> = &'a mut Self;
5389        fn take_or_borrow<'a>(
5390            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5391        ) -> Self::Borrowed<'a> {
5392            value
5393        }
5394    }
5395
5396    unsafe impl fidl::encoding::TypeMarker for Channel {
5397        type Owned = Self;
5398
5399        #[inline(always)]
5400        fn inline_align(_context: fidl::encoding::Context) -> usize {
5401            8
5402        }
5403
5404        #[inline(always)]
5405        fn inline_size(_context: fidl::encoding::Context) -> usize {
5406            16
5407        }
5408    }
5409
5410    unsafe impl fidl::encoding::Encode<Channel, fidl::encoding::DefaultFuchsiaResourceDialect>
5411        for &mut Channel
5412    {
5413        unsafe fn encode(
5414            self,
5415            encoder: &mut fidl::encoding::Encoder<
5416                '_,
5417                fidl::encoding::DefaultFuchsiaResourceDialect,
5418            >,
5419            offset: usize,
5420            mut depth: fidl::encoding::Depth,
5421        ) -> fidl::Result<()> {
5422            encoder.debug_check_bounds::<Channel>(offset);
5423            // Vector header
5424            let max_ordinal: u64 = self.max_ordinal_present();
5425            encoder.write_num(max_ordinal, offset);
5426            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5427            // Calling encoder.out_of_line_offset(0) is not allowed.
5428            if max_ordinal == 0 {
5429                return Ok(());
5430            }
5431            depth.increment()?;
5432            let envelope_size = 8;
5433            let bytes_len = max_ordinal as usize * envelope_size;
5434            #[allow(unused_variables)]
5435            let offset = encoder.out_of_line_offset(bytes_len);
5436            let mut _prev_end_offset: usize = 0;
5437            if 1 > max_ordinal {
5438                return Ok(());
5439            }
5440
5441            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5442            // are envelope_size bytes.
5443            let cur_offset: usize = (1 - 1) * envelope_size;
5444
5445            // Zero reserved fields.
5446            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5447
5448            // Safety:
5449            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5450            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5451            //   envelope_size bytes, there is always sufficient room.
5452            fidl::encoding::encode_in_envelope_optional::<
5453                fidl::encoding::HandleType<
5454                    fidl::Socket,
5455                    { fidl::ObjectType::SOCKET.into_raw() },
5456                    2147483648,
5457                >,
5458                fidl::encoding::DefaultFuchsiaResourceDialect,
5459            >(
5460                self.socket.as_mut().map(
5461                    <fidl::encoding::HandleType<
5462                        fidl::Socket,
5463                        { fidl::ObjectType::SOCKET.into_raw() },
5464                        2147483648,
5465                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5466                ),
5467                encoder,
5468                offset + cur_offset,
5469                depth,
5470            )?;
5471
5472            _prev_end_offset = cur_offset + envelope_size;
5473            if 2 > max_ordinal {
5474                return Ok(());
5475            }
5476
5477            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5478            // are envelope_size bytes.
5479            let cur_offset: usize = (2 - 1) * envelope_size;
5480
5481            // Zero reserved fields.
5482            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5483
5484            // Safety:
5485            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5486            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5487            //   envelope_size bytes, there is always sufficient room.
5488            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth::ChannelMode, fidl::encoding::DefaultFuchsiaResourceDialect>(
5489            self.channel_mode.as_ref().map(<fidl_fuchsia_bluetooth::ChannelMode as fidl::encoding::ValueTypeMarker>::borrow),
5490            encoder, offset + cur_offset, depth
5491        )?;
5492
5493            _prev_end_offset = cur_offset + envelope_size;
5494            if 3 > max_ordinal {
5495                return Ok(());
5496            }
5497
5498            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5499            // are envelope_size bytes.
5500            let cur_offset: usize = (3 - 1) * envelope_size;
5501
5502            // Zero reserved fields.
5503            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5504
5505            // Safety:
5506            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5507            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5508            //   envelope_size bytes, there is always sufficient room.
5509            fidl::encoding::encode_in_envelope_optional::<
5510                u16,
5511                fidl::encoding::DefaultFuchsiaResourceDialect,
5512            >(
5513                self.max_tx_sdu_size.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
5514                encoder,
5515                offset + cur_offset,
5516                depth,
5517            )?;
5518
5519            _prev_end_offset = cur_offset + envelope_size;
5520            if 4 > max_ordinal {
5521                return Ok(());
5522            }
5523
5524            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5525            // are envelope_size bytes.
5526            let cur_offset: usize = (4 - 1) * envelope_size;
5527
5528            // Zero reserved fields.
5529            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5530
5531            // Safety:
5532            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5533            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5534            //   envelope_size bytes, there is always sufficient room.
5535            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AudioDirectionExtMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5536            self.ext_direction.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AudioDirectionExtMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5537            encoder, offset + cur_offset, depth
5538        )?;
5539
5540            _prev_end_offset = cur_offset + envelope_size;
5541            if 5 > max_ordinal {
5542                return Ok(());
5543            }
5544
5545            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5546            // are envelope_size bytes.
5547            let cur_offset: usize = (5 - 1) * envelope_size;
5548
5549            // Zero reserved fields.
5550            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5551
5552            // Safety:
5553            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5554            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5555            //   envelope_size bytes, there is always sufficient room.
5556            fidl::encoding::encode_in_envelope_optional::<
5557                i64,
5558                fidl::encoding::DefaultFuchsiaResourceDialect,
5559            >(
5560                self.flush_timeout.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
5561                encoder,
5562                offset + cur_offset,
5563                depth,
5564            )?;
5565
5566            _prev_end_offset = cur_offset + envelope_size;
5567            if 6 > max_ordinal {
5568                return Ok(());
5569            }
5570
5571            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5572            // are envelope_size bytes.
5573            let cur_offset: usize = (6 - 1) * envelope_size;
5574
5575            // Zero reserved fields.
5576            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5577
5578            // Safety:
5579            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5580            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5581            //   envelope_size bytes, there is always sufficient room.
5582            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<L2capParametersExtMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5583            self.ext_l2cap.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<L2capParametersExtMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5584            encoder, offset + cur_offset, depth
5585        )?;
5586
5587            _prev_end_offset = cur_offset + envelope_size;
5588            if 7 > max_ordinal {
5589                return Ok(());
5590            }
5591
5592            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5593            // are envelope_size bytes.
5594            let cur_offset: usize = (7 - 1) * envelope_size;
5595
5596            // Zero reserved fields.
5597            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5598
5599            // Safety:
5600            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5601            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5602            //   envelope_size bytes, there is always sufficient room.
5603            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AudioOffloadExtMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5604            self.ext_audio_offload.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AudioOffloadExtMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5605            encoder, offset + cur_offset, depth
5606        )?;
5607
5608            _prev_end_offset = cur_offset + envelope_size;
5609            if 8 > max_ordinal {
5610                return Ok(());
5611            }
5612
5613            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5614            // are envelope_size bytes.
5615            let cur_offset: usize = (8 - 1) * envelope_size;
5616
5617            // Zero reserved fields.
5618            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5619
5620            // Safety:
5621            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5622            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5623            //   envelope_size bytes, there is always sufficient room.
5624            fidl::encoding::encode_in_envelope_optional::<
5625                fidl::encoding::Endpoint<
5626                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
5627                >,
5628                fidl::encoding::DefaultFuchsiaResourceDialect,
5629            >(
5630                self.connection.as_mut().map(
5631                    <fidl::encoding::Endpoint<
5632                        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
5633                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5634                ),
5635                encoder,
5636                offset + cur_offset,
5637                depth,
5638            )?;
5639
5640            _prev_end_offset = cur_offset + envelope_size;
5641
5642            Ok(())
5643        }
5644    }
5645
5646    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Channel {
5647        #[inline(always)]
5648        fn new_empty() -> Self {
5649            Self::default()
5650        }
5651
5652        unsafe fn decode(
5653            &mut self,
5654            decoder: &mut fidl::encoding::Decoder<
5655                '_,
5656                fidl::encoding::DefaultFuchsiaResourceDialect,
5657            >,
5658            offset: usize,
5659            mut depth: fidl::encoding::Depth,
5660        ) -> fidl::Result<()> {
5661            decoder.debug_check_bounds::<Self>(offset);
5662            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5663                None => return Err(fidl::Error::NotNullable),
5664                Some(len) => len,
5665            };
5666            // Calling decoder.out_of_line_offset(0) is not allowed.
5667            if len == 0 {
5668                return Ok(());
5669            };
5670            depth.increment()?;
5671            let envelope_size = 8;
5672            let bytes_len = len * envelope_size;
5673            let offset = decoder.out_of_line_offset(bytes_len)?;
5674            // Decode the envelope for each type.
5675            let mut _next_ordinal_to_read = 0;
5676            let mut next_offset = offset;
5677            let end_offset = offset + bytes_len;
5678            _next_ordinal_to_read += 1;
5679            if next_offset >= end_offset {
5680                return Ok(());
5681            }
5682
5683            // Decode unknown envelopes for gaps in ordinals.
5684            while _next_ordinal_to_read < 1 {
5685                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5686                _next_ordinal_to_read += 1;
5687                next_offset += envelope_size;
5688            }
5689
5690            let next_out_of_line = decoder.next_out_of_line();
5691            let handles_before = decoder.remaining_handles();
5692            if let Some((inlined, num_bytes, num_handles)) =
5693                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5694            {
5695                let member_inline_size = <fidl::encoding::HandleType<
5696                    fidl::Socket,
5697                    { fidl::ObjectType::SOCKET.into_raw() },
5698                    2147483648,
5699                > as fidl::encoding::TypeMarker>::inline_size(
5700                    decoder.context
5701                );
5702                if inlined != (member_inline_size <= 4) {
5703                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5704                }
5705                let inner_offset;
5706                let mut inner_depth = depth.clone();
5707                if inlined {
5708                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5709                    inner_offset = next_offset;
5710                } else {
5711                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5712                    inner_depth.increment()?;
5713                }
5714                let val_ref =
5715                self.socket.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
5716                fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5717                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5718                {
5719                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5720                }
5721                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5722                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5723                }
5724            }
5725
5726            next_offset += envelope_size;
5727            _next_ordinal_to_read += 1;
5728            if next_offset >= end_offset {
5729                return Ok(());
5730            }
5731
5732            // Decode unknown envelopes for gaps in ordinals.
5733            while _next_ordinal_to_read < 2 {
5734                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5735                _next_ordinal_to_read += 1;
5736                next_offset += envelope_size;
5737            }
5738
5739            let next_out_of_line = decoder.next_out_of_line();
5740            let handles_before = decoder.remaining_handles();
5741            if let Some((inlined, num_bytes, num_handles)) =
5742                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5743            {
5744                let member_inline_size = <fidl_fuchsia_bluetooth::ChannelMode as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5745                if inlined != (member_inline_size <= 4) {
5746                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5747                }
5748                let inner_offset;
5749                let mut inner_depth = depth.clone();
5750                if inlined {
5751                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5752                    inner_offset = next_offset;
5753                } else {
5754                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5755                    inner_depth.increment()?;
5756                }
5757                let val_ref = self.channel_mode.get_or_insert_with(|| {
5758                    fidl::new_empty!(
5759                        fidl_fuchsia_bluetooth::ChannelMode,
5760                        fidl::encoding::DefaultFuchsiaResourceDialect
5761                    )
5762                });
5763                fidl::decode!(
5764                    fidl_fuchsia_bluetooth::ChannelMode,
5765                    fidl::encoding::DefaultFuchsiaResourceDialect,
5766                    val_ref,
5767                    decoder,
5768                    inner_offset,
5769                    inner_depth
5770                )?;
5771                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5772                {
5773                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5774                }
5775                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5776                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5777                }
5778            }
5779
5780            next_offset += envelope_size;
5781            _next_ordinal_to_read += 1;
5782            if next_offset >= end_offset {
5783                return Ok(());
5784            }
5785
5786            // Decode unknown envelopes for gaps in ordinals.
5787            while _next_ordinal_to_read < 3 {
5788                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5789                _next_ordinal_to_read += 1;
5790                next_offset += envelope_size;
5791            }
5792
5793            let next_out_of_line = decoder.next_out_of_line();
5794            let handles_before = decoder.remaining_handles();
5795            if let Some((inlined, num_bytes, num_handles)) =
5796                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5797            {
5798                let member_inline_size =
5799                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5800                if inlined != (member_inline_size <= 4) {
5801                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5802                }
5803                let inner_offset;
5804                let mut inner_depth = depth.clone();
5805                if inlined {
5806                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5807                    inner_offset = next_offset;
5808                } else {
5809                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5810                    inner_depth.increment()?;
5811                }
5812                let val_ref = self.max_tx_sdu_size.get_or_insert_with(|| {
5813                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
5814                });
5815                fidl::decode!(
5816                    u16,
5817                    fidl::encoding::DefaultFuchsiaResourceDialect,
5818                    val_ref,
5819                    decoder,
5820                    inner_offset,
5821                    inner_depth
5822                )?;
5823                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5824                {
5825                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5826                }
5827                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5828                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5829                }
5830            }
5831
5832            next_offset += envelope_size;
5833            _next_ordinal_to_read += 1;
5834            if next_offset >= end_offset {
5835                return Ok(());
5836            }
5837
5838            // Decode unknown envelopes for gaps in ordinals.
5839            while _next_ordinal_to_read < 4 {
5840                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5841                _next_ordinal_to_read += 1;
5842                next_offset += envelope_size;
5843            }
5844
5845            let next_out_of_line = decoder.next_out_of_line();
5846            let handles_before = decoder.remaining_handles();
5847            if let Some((inlined, num_bytes, num_handles)) =
5848                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5849            {
5850                let member_inline_size = <fidl::encoding::Endpoint<
5851                    fidl::endpoints::ClientEnd<AudioDirectionExtMarker>,
5852                > as fidl::encoding::TypeMarker>::inline_size(
5853                    decoder.context
5854                );
5855                if inlined != (member_inline_size <= 4) {
5856                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5857                }
5858                let inner_offset;
5859                let mut inner_depth = depth.clone();
5860                if inlined {
5861                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5862                    inner_offset = next_offset;
5863                } else {
5864                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5865                    inner_depth.increment()?;
5866                }
5867                let val_ref = self.ext_direction.get_or_insert_with(|| {
5868                    fidl::new_empty!(
5869                        fidl::encoding::Endpoint<
5870                            fidl::endpoints::ClientEnd<AudioDirectionExtMarker>,
5871                        >,
5872                        fidl::encoding::DefaultFuchsiaResourceDialect
5873                    )
5874                });
5875                fidl::decode!(
5876                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AudioDirectionExtMarker>>,
5877                    fidl::encoding::DefaultFuchsiaResourceDialect,
5878                    val_ref,
5879                    decoder,
5880                    inner_offset,
5881                    inner_depth
5882                )?;
5883                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5884                {
5885                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5886                }
5887                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5888                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5889                }
5890            }
5891
5892            next_offset += envelope_size;
5893            _next_ordinal_to_read += 1;
5894            if next_offset >= end_offset {
5895                return Ok(());
5896            }
5897
5898            // Decode unknown envelopes for gaps in ordinals.
5899            while _next_ordinal_to_read < 5 {
5900                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5901                _next_ordinal_to_read += 1;
5902                next_offset += envelope_size;
5903            }
5904
5905            let next_out_of_line = decoder.next_out_of_line();
5906            let handles_before = decoder.remaining_handles();
5907            if let Some((inlined, num_bytes, num_handles)) =
5908                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5909            {
5910                let member_inline_size =
5911                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5912                if inlined != (member_inline_size <= 4) {
5913                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5914                }
5915                let inner_offset;
5916                let mut inner_depth = depth.clone();
5917                if inlined {
5918                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5919                    inner_offset = next_offset;
5920                } else {
5921                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5922                    inner_depth.increment()?;
5923                }
5924                let val_ref = self.flush_timeout.get_or_insert_with(|| {
5925                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
5926                });
5927                fidl::decode!(
5928                    i64,
5929                    fidl::encoding::DefaultFuchsiaResourceDialect,
5930                    val_ref,
5931                    decoder,
5932                    inner_offset,
5933                    inner_depth
5934                )?;
5935                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5936                {
5937                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5938                }
5939                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5940                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5941                }
5942            }
5943
5944            next_offset += envelope_size;
5945            _next_ordinal_to_read += 1;
5946            if next_offset >= end_offset {
5947                return Ok(());
5948            }
5949
5950            // Decode unknown envelopes for gaps in ordinals.
5951            while _next_ordinal_to_read < 6 {
5952                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5953                _next_ordinal_to_read += 1;
5954                next_offset += envelope_size;
5955            }
5956
5957            let next_out_of_line = decoder.next_out_of_line();
5958            let handles_before = decoder.remaining_handles();
5959            if let Some((inlined, num_bytes, num_handles)) =
5960                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5961            {
5962                let member_inline_size = <fidl::encoding::Endpoint<
5963                    fidl::endpoints::ClientEnd<L2capParametersExtMarker>,
5964                > as fidl::encoding::TypeMarker>::inline_size(
5965                    decoder.context
5966                );
5967                if inlined != (member_inline_size <= 4) {
5968                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5969                }
5970                let inner_offset;
5971                let mut inner_depth = depth.clone();
5972                if inlined {
5973                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5974                    inner_offset = next_offset;
5975                } else {
5976                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5977                    inner_depth.increment()?;
5978                }
5979                let val_ref = self.ext_l2cap.get_or_insert_with(|| {
5980                    fidl::new_empty!(
5981                        fidl::encoding::Endpoint<
5982                            fidl::endpoints::ClientEnd<L2capParametersExtMarker>,
5983                        >,
5984                        fidl::encoding::DefaultFuchsiaResourceDialect
5985                    )
5986                });
5987                fidl::decode!(
5988                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<L2capParametersExtMarker>>,
5989                    fidl::encoding::DefaultFuchsiaResourceDialect,
5990                    val_ref,
5991                    decoder,
5992                    inner_offset,
5993                    inner_depth
5994                )?;
5995                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5996                {
5997                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5998                }
5999                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6000                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6001                }
6002            }
6003
6004            next_offset += envelope_size;
6005            _next_ordinal_to_read += 1;
6006            if next_offset >= end_offset {
6007                return Ok(());
6008            }
6009
6010            // Decode unknown envelopes for gaps in ordinals.
6011            while _next_ordinal_to_read < 7 {
6012                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6013                _next_ordinal_to_read += 1;
6014                next_offset += envelope_size;
6015            }
6016
6017            let next_out_of_line = decoder.next_out_of_line();
6018            let handles_before = decoder.remaining_handles();
6019            if let Some((inlined, num_bytes, num_handles)) =
6020                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6021            {
6022                let member_inline_size = <fidl::encoding::Endpoint<
6023                    fidl::endpoints::ClientEnd<AudioOffloadExtMarker>,
6024                > as fidl::encoding::TypeMarker>::inline_size(
6025                    decoder.context
6026                );
6027                if inlined != (member_inline_size <= 4) {
6028                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6029                }
6030                let inner_offset;
6031                let mut inner_depth = depth.clone();
6032                if inlined {
6033                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6034                    inner_offset = next_offset;
6035                } else {
6036                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6037                    inner_depth.increment()?;
6038                }
6039                let val_ref = self.ext_audio_offload.get_or_insert_with(|| {
6040                    fidl::new_empty!(
6041                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AudioOffloadExtMarker>>,
6042                        fidl::encoding::DefaultFuchsiaResourceDialect
6043                    )
6044                });
6045                fidl::decode!(
6046                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AudioOffloadExtMarker>>,
6047                    fidl::encoding::DefaultFuchsiaResourceDialect,
6048                    val_ref,
6049                    decoder,
6050                    inner_offset,
6051                    inner_depth
6052                )?;
6053                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6054                {
6055                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6056                }
6057                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6058                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6059                }
6060            }
6061
6062            next_offset += envelope_size;
6063            _next_ordinal_to_read += 1;
6064            if next_offset >= end_offset {
6065                return Ok(());
6066            }
6067
6068            // Decode unknown envelopes for gaps in ordinals.
6069            while _next_ordinal_to_read < 8 {
6070                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6071                _next_ordinal_to_read += 1;
6072                next_offset += envelope_size;
6073            }
6074
6075            let next_out_of_line = decoder.next_out_of_line();
6076            let handles_before = decoder.remaining_handles();
6077            if let Some((inlined, num_bytes, num_handles)) =
6078                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6079            {
6080                let member_inline_size = <fidl::encoding::Endpoint<
6081                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
6082                > as fidl::encoding::TypeMarker>::inline_size(
6083                    decoder.context
6084                );
6085                if inlined != (member_inline_size <= 4) {
6086                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6087                }
6088                let inner_offset;
6089                let mut inner_depth = depth.clone();
6090                if inlined {
6091                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6092                    inner_offset = next_offset;
6093                } else {
6094                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6095                    inner_depth.increment()?;
6096                }
6097                let val_ref = self.connection.get_or_insert_with(|| {
6098                    fidl::new_empty!(
6099                        fidl::encoding::Endpoint<
6100                            fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
6101                        >,
6102                        fidl::encoding::DefaultFuchsiaResourceDialect
6103                    )
6104                });
6105                fidl::decode!(
6106                    fidl::encoding::Endpoint<
6107                        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
6108                    >,
6109                    fidl::encoding::DefaultFuchsiaResourceDialect,
6110                    val_ref,
6111                    decoder,
6112                    inner_offset,
6113                    inner_depth
6114                )?;
6115                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6116                {
6117                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6118                }
6119                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6120                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6121                }
6122            }
6123
6124            next_offset += envelope_size;
6125
6126            // Decode the remaining unknown envelopes.
6127            while next_offset < end_offset {
6128                _next_ordinal_to_read += 1;
6129                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6130                next_offset += envelope_size;
6131            }
6132
6133            Ok(())
6134        }
6135    }
6136
6137    impl ProfileAdvertiseRequest {
6138        #[inline(always)]
6139        fn max_ordinal_present(&self) -> u64 {
6140            if let Some(_) = self.parameters {
6141                return 3;
6142            }
6143            if let Some(_) = self.receiver {
6144                return 2;
6145            }
6146            if let Some(_) = self.services {
6147                return 1;
6148            }
6149            0
6150        }
6151    }
6152
6153    impl fidl::encoding::ResourceTypeMarker for ProfileAdvertiseRequest {
6154        type Borrowed<'a> = &'a mut Self;
6155        fn take_or_borrow<'a>(
6156            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6157        ) -> Self::Borrowed<'a> {
6158            value
6159        }
6160    }
6161
6162    unsafe impl fidl::encoding::TypeMarker for ProfileAdvertiseRequest {
6163        type Owned = Self;
6164
6165        #[inline(always)]
6166        fn inline_align(_context: fidl::encoding::Context) -> usize {
6167            8
6168        }
6169
6170        #[inline(always)]
6171        fn inline_size(_context: fidl::encoding::Context) -> usize {
6172            16
6173        }
6174    }
6175
6176    unsafe impl
6177        fidl::encoding::Encode<
6178            ProfileAdvertiseRequest,
6179            fidl::encoding::DefaultFuchsiaResourceDialect,
6180        > for &mut ProfileAdvertiseRequest
6181    {
6182        unsafe fn encode(
6183            self,
6184            encoder: &mut fidl::encoding::Encoder<
6185                '_,
6186                fidl::encoding::DefaultFuchsiaResourceDialect,
6187            >,
6188            offset: usize,
6189            mut depth: fidl::encoding::Depth,
6190        ) -> fidl::Result<()> {
6191            encoder.debug_check_bounds::<ProfileAdvertiseRequest>(offset);
6192            // Vector header
6193            let max_ordinal: u64 = self.max_ordinal_present();
6194            encoder.write_num(max_ordinal, offset);
6195            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6196            // Calling encoder.out_of_line_offset(0) is not allowed.
6197            if max_ordinal == 0 {
6198                return Ok(());
6199            }
6200            depth.increment()?;
6201            let envelope_size = 8;
6202            let bytes_len = max_ordinal as usize * envelope_size;
6203            #[allow(unused_variables)]
6204            let offset = encoder.out_of_line_offset(bytes_len);
6205            let mut _prev_end_offset: usize = 0;
6206            if 1 > max_ordinal {
6207                return Ok(());
6208            }
6209
6210            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6211            // are envelope_size bytes.
6212            let cur_offset: usize = (1 - 1) * envelope_size;
6213
6214            // Zero reserved fields.
6215            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6216
6217            // Safety:
6218            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6219            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6220            //   envelope_size bytes, there is always sufficient room.
6221            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<ServiceDefinition, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
6222            self.services.as_ref().map(<fidl::encoding::Vector<ServiceDefinition, 32> as fidl::encoding::ValueTypeMarker>::borrow),
6223            encoder, offset + cur_offset, depth
6224        )?;
6225
6226            _prev_end_offset = cur_offset + envelope_size;
6227            if 2 > max_ordinal {
6228                return Ok(());
6229            }
6230
6231            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6232            // are envelope_size bytes.
6233            let cur_offset: usize = (2 - 1) * envelope_size;
6234
6235            // Zero reserved fields.
6236            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6237
6238            // Safety:
6239            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6240            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6241            //   envelope_size bytes, there is always sufficient room.
6242            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionReceiverMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
6243            self.receiver.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionReceiverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
6244            encoder, offset + cur_offset, depth
6245        )?;
6246
6247            _prev_end_offset = cur_offset + envelope_size;
6248            if 3 > max_ordinal {
6249                return Ok(());
6250            }
6251
6252            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6253            // are envelope_size bytes.
6254            let cur_offset: usize = (3 - 1) * envelope_size;
6255
6256            // Zero reserved fields.
6257            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6258
6259            // Safety:
6260            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6261            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6262            //   envelope_size bytes, there is always sufficient room.
6263            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth::ChannelParameters, fidl::encoding::DefaultFuchsiaResourceDialect>(
6264            self.parameters.as_ref().map(<fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::ValueTypeMarker>::borrow),
6265            encoder, offset + cur_offset, depth
6266        )?;
6267
6268            _prev_end_offset = cur_offset + envelope_size;
6269
6270            Ok(())
6271        }
6272    }
6273
6274    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6275        for ProfileAdvertiseRequest
6276    {
6277        #[inline(always)]
6278        fn new_empty() -> Self {
6279            Self::default()
6280        }
6281
6282        unsafe fn decode(
6283            &mut self,
6284            decoder: &mut fidl::encoding::Decoder<
6285                '_,
6286                fidl::encoding::DefaultFuchsiaResourceDialect,
6287            >,
6288            offset: usize,
6289            mut depth: fidl::encoding::Depth,
6290        ) -> fidl::Result<()> {
6291            decoder.debug_check_bounds::<Self>(offset);
6292            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6293                None => return Err(fidl::Error::NotNullable),
6294                Some(len) => len,
6295            };
6296            // Calling decoder.out_of_line_offset(0) is not allowed.
6297            if len == 0 {
6298                return Ok(());
6299            };
6300            depth.increment()?;
6301            let envelope_size = 8;
6302            let bytes_len = len * envelope_size;
6303            let offset = decoder.out_of_line_offset(bytes_len)?;
6304            // Decode the envelope for each type.
6305            let mut _next_ordinal_to_read = 0;
6306            let mut next_offset = offset;
6307            let end_offset = offset + bytes_len;
6308            _next_ordinal_to_read += 1;
6309            if next_offset >= end_offset {
6310                return Ok(());
6311            }
6312
6313            // Decode unknown envelopes for gaps in ordinals.
6314            while _next_ordinal_to_read < 1 {
6315                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6316                _next_ordinal_to_read += 1;
6317                next_offset += envelope_size;
6318            }
6319
6320            let next_out_of_line = decoder.next_out_of_line();
6321            let handles_before = decoder.remaining_handles();
6322            if let Some((inlined, num_bytes, num_handles)) =
6323                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6324            {
6325                let member_inline_size = <fidl::encoding::Vector<ServiceDefinition, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6326                if inlined != (member_inline_size <= 4) {
6327                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6328                }
6329                let inner_offset;
6330                let mut inner_depth = depth.clone();
6331                if inlined {
6332                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6333                    inner_offset = next_offset;
6334                } else {
6335                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6336                    inner_depth.increment()?;
6337                }
6338                let val_ref =
6339                self.services.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<ServiceDefinition, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
6340                fidl::decode!(fidl::encoding::Vector<ServiceDefinition, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
6341                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6342                {
6343                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6344                }
6345                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6346                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6347                }
6348            }
6349
6350            next_offset += envelope_size;
6351            _next_ordinal_to_read += 1;
6352            if next_offset >= end_offset {
6353                return Ok(());
6354            }
6355
6356            // Decode unknown envelopes for gaps in ordinals.
6357            while _next_ordinal_to_read < 2 {
6358                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6359                _next_ordinal_to_read += 1;
6360                next_offset += envelope_size;
6361            }
6362
6363            let next_out_of_line = decoder.next_out_of_line();
6364            let handles_before = decoder.remaining_handles();
6365            if let Some((inlined, num_bytes, num_handles)) =
6366                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6367            {
6368                let member_inline_size = <fidl::encoding::Endpoint<
6369                    fidl::endpoints::ClientEnd<ConnectionReceiverMarker>,
6370                > as fidl::encoding::TypeMarker>::inline_size(
6371                    decoder.context
6372                );
6373                if inlined != (member_inline_size <= 4) {
6374                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6375                }
6376                let inner_offset;
6377                let mut inner_depth = depth.clone();
6378                if inlined {
6379                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6380                    inner_offset = next_offset;
6381                } else {
6382                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6383                    inner_depth.increment()?;
6384                }
6385                let val_ref = self.receiver.get_or_insert_with(|| {
6386                    fidl::new_empty!(
6387                        fidl::encoding::Endpoint<
6388                            fidl::endpoints::ClientEnd<ConnectionReceiverMarker>,
6389                        >,
6390                        fidl::encoding::DefaultFuchsiaResourceDialect
6391                    )
6392                });
6393                fidl::decode!(
6394                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionReceiverMarker>>,
6395                    fidl::encoding::DefaultFuchsiaResourceDialect,
6396                    val_ref,
6397                    decoder,
6398                    inner_offset,
6399                    inner_depth
6400                )?;
6401                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6402                {
6403                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6404                }
6405                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6406                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6407                }
6408            }
6409
6410            next_offset += envelope_size;
6411            _next_ordinal_to_read += 1;
6412            if next_offset >= end_offset {
6413                return Ok(());
6414            }
6415
6416            // Decode unknown envelopes for gaps in ordinals.
6417            while _next_ordinal_to_read < 3 {
6418                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6419                _next_ordinal_to_read += 1;
6420                next_offset += envelope_size;
6421            }
6422
6423            let next_out_of_line = decoder.next_out_of_line();
6424            let handles_before = decoder.remaining_handles();
6425            if let Some((inlined, num_bytes, num_handles)) =
6426                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6427            {
6428                let member_inline_size = <fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6429                if inlined != (member_inline_size <= 4) {
6430                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6431                }
6432                let inner_offset;
6433                let mut inner_depth = depth.clone();
6434                if inlined {
6435                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6436                    inner_offset = next_offset;
6437                } else {
6438                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6439                    inner_depth.increment()?;
6440                }
6441                let val_ref = self.parameters.get_or_insert_with(|| {
6442                    fidl::new_empty!(
6443                        fidl_fuchsia_bluetooth::ChannelParameters,
6444                        fidl::encoding::DefaultFuchsiaResourceDialect
6445                    )
6446                });
6447                fidl::decode!(
6448                    fidl_fuchsia_bluetooth::ChannelParameters,
6449                    fidl::encoding::DefaultFuchsiaResourceDialect,
6450                    val_ref,
6451                    decoder,
6452                    inner_offset,
6453                    inner_depth
6454                )?;
6455                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6456                {
6457                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6458                }
6459                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6460                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6461                }
6462            }
6463
6464            next_offset += envelope_size;
6465
6466            // Decode the remaining unknown envelopes.
6467            while next_offset < end_offset {
6468                _next_ordinal_to_read += 1;
6469                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6470                next_offset += envelope_size;
6471            }
6472
6473            Ok(())
6474        }
6475    }
6476
6477    impl ProfileConnectScoRequest {
6478        #[inline(always)]
6479        fn max_ordinal_present(&self) -> u64 {
6480            if let Some(_) = self.connection {
6481                return 4;
6482            }
6483            if let Some(_) = self.params {
6484                return 3;
6485            }
6486            if let Some(_) = self.initiator {
6487                return 2;
6488            }
6489            if let Some(_) = self.peer_id {
6490                return 1;
6491            }
6492            0
6493        }
6494    }
6495
6496    impl fidl::encoding::ResourceTypeMarker for ProfileConnectScoRequest {
6497        type Borrowed<'a> = &'a mut Self;
6498        fn take_or_borrow<'a>(
6499            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6500        ) -> Self::Borrowed<'a> {
6501            value
6502        }
6503    }
6504
6505    unsafe impl fidl::encoding::TypeMarker for ProfileConnectScoRequest {
6506        type Owned = Self;
6507
6508        #[inline(always)]
6509        fn inline_align(_context: fidl::encoding::Context) -> usize {
6510            8
6511        }
6512
6513        #[inline(always)]
6514        fn inline_size(_context: fidl::encoding::Context) -> usize {
6515            16
6516        }
6517    }
6518
6519    unsafe impl
6520        fidl::encoding::Encode<
6521            ProfileConnectScoRequest,
6522            fidl::encoding::DefaultFuchsiaResourceDialect,
6523        > for &mut ProfileConnectScoRequest
6524    {
6525        unsafe fn encode(
6526            self,
6527            encoder: &mut fidl::encoding::Encoder<
6528                '_,
6529                fidl::encoding::DefaultFuchsiaResourceDialect,
6530            >,
6531            offset: usize,
6532            mut depth: fidl::encoding::Depth,
6533        ) -> fidl::Result<()> {
6534            encoder.debug_check_bounds::<ProfileConnectScoRequest>(offset);
6535            // Vector header
6536            let max_ordinal: u64 = self.max_ordinal_present();
6537            encoder.write_num(max_ordinal, offset);
6538            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6539            // Calling encoder.out_of_line_offset(0) is not allowed.
6540            if max_ordinal == 0 {
6541                return Ok(());
6542            }
6543            depth.increment()?;
6544            let envelope_size = 8;
6545            let bytes_len = max_ordinal as usize * envelope_size;
6546            #[allow(unused_variables)]
6547            let offset = encoder.out_of_line_offset(bytes_len);
6548            let mut _prev_end_offset: usize = 0;
6549            if 1 > max_ordinal {
6550                return Ok(());
6551            }
6552
6553            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6554            // are envelope_size bytes.
6555            let cur_offset: usize = (1 - 1) * envelope_size;
6556
6557            // Zero reserved fields.
6558            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6559
6560            // Safety:
6561            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6562            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6563            //   envelope_size bytes, there is always sufficient room.
6564            fidl::encoding::encode_in_envelope_optional::<
6565                fidl_fuchsia_bluetooth::PeerId,
6566                fidl::encoding::DefaultFuchsiaResourceDialect,
6567            >(
6568                self.peer_id.as_ref().map(
6569                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow,
6570                ),
6571                encoder,
6572                offset + cur_offset,
6573                depth,
6574            )?;
6575
6576            _prev_end_offset = cur_offset + envelope_size;
6577            if 2 > max_ordinal {
6578                return Ok(());
6579            }
6580
6581            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6582            // are envelope_size bytes.
6583            let cur_offset: usize = (2 - 1) * envelope_size;
6584
6585            // Zero reserved fields.
6586            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6587
6588            // Safety:
6589            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6590            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6591            //   envelope_size bytes, there is always sufficient room.
6592            fidl::encoding::encode_in_envelope_optional::<
6593                bool,
6594                fidl::encoding::DefaultFuchsiaResourceDialect,
6595            >(
6596                self.initiator.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
6597                encoder,
6598                offset + cur_offset,
6599                depth,
6600            )?;
6601
6602            _prev_end_offset = cur_offset + envelope_size;
6603            if 3 > max_ordinal {
6604                return Ok(());
6605            }
6606
6607            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6608            // are envelope_size bytes.
6609            let cur_offset: usize = (3 - 1) * envelope_size;
6610
6611            // Zero reserved fields.
6612            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6613
6614            // Safety:
6615            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6616            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6617            //   envelope_size bytes, there is always sufficient room.
6618            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<ScoConnectionParameters>, fidl::encoding::DefaultFuchsiaResourceDialect>(
6619            self.params.as_ref().map(<fidl::encoding::UnboundedVector<ScoConnectionParameters> as fidl::encoding::ValueTypeMarker>::borrow),
6620            encoder, offset + cur_offset, depth
6621        )?;
6622
6623            _prev_end_offset = cur_offset + envelope_size;
6624            if 4 > max_ordinal {
6625                return Ok(());
6626            }
6627
6628            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6629            // are envelope_size bytes.
6630            let cur_offset: usize = (4 - 1) * envelope_size;
6631
6632            // Zero reserved fields.
6633            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6634
6635            // Safety:
6636            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6637            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6638            //   envelope_size bytes, there is always sufficient room.
6639            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
6640            self.connection.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
6641            encoder, offset + cur_offset, depth
6642        )?;
6643
6644            _prev_end_offset = cur_offset + envelope_size;
6645
6646            Ok(())
6647        }
6648    }
6649
6650    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6651        for ProfileConnectScoRequest
6652    {
6653        #[inline(always)]
6654        fn new_empty() -> Self {
6655            Self::default()
6656        }
6657
6658        unsafe fn decode(
6659            &mut self,
6660            decoder: &mut fidl::encoding::Decoder<
6661                '_,
6662                fidl::encoding::DefaultFuchsiaResourceDialect,
6663            >,
6664            offset: usize,
6665            mut depth: fidl::encoding::Depth,
6666        ) -> fidl::Result<()> {
6667            decoder.debug_check_bounds::<Self>(offset);
6668            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6669                None => return Err(fidl::Error::NotNullable),
6670                Some(len) => len,
6671            };
6672            // Calling decoder.out_of_line_offset(0) is not allowed.
6673            if len == 0 {
6674                return Ok(());
6675            };
6676            depth.increment()?;
6677            let envelope_size = 8;
6678            let bytes_len = len * envelope_size;
6679            let offset = decoder.out_of_line_offset(bytes_len)?;
6680            // Decode the envelope for each type.
6681            let mut _next_ordinal_to_read = 0;
6682            let mut next_offset = offset;
6683            let end_offset = offset + bytes_len;
6684            _next_ordinal_to_read += 1;
6685            if next_offset >= end_offset {
6686                return Ok(());
6687            }
6688
6689            // Decode unknown envelopes for gaps in ordinals.
6690            while _next_ordinal_to_read < 1 {
6691                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6692                _next_ordinal_to_read += 1;
6693                next_offset += envelope_size;
6694            }
6695
6696            let next_out_of_line = decoder.next_out_of_line();
6697            let handles_before = decoder.remaining_handles();
6698            if let Some((inlined, num_bytes, num_handles)) =
6699                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6700            {
6701                let member_inline_size =
6702                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::TypeMarker>::inline_size(
6703                        decoder.context,
6704                    );
6705                if inlined != (member_inline_size <= 4) {
6706                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6707                }
6708                let inner_offset;
6709                let mut inner_depth = depth.clone();
6710                if inlined {
6711                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6712                    inner_offset = next_offset;
6713                } else {
6714                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6715                    inner_depth.increment()?;
6716                }
6717                let val_ref = self.peer_id.get_or_insert_with(|| {
6718                    fidl::new_empty!(
6719                        fidl_fuchsia_bluetooth::PeerId,
6720                        fidl::encoding::DefaultFuchsiaResourceDialect
6721                    )
6722                });
6723                fidl::decode!(
6724                    fidl_fuchsia_bluetooth::PeerId,
6725                    fidl::encoding::DefaultFuchsiaResourceDialect,
6726                    val_ref,
6727                    decoder,
6728                    inner_offset,
6729                    inner_depth
6730                )?;
6731                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6732                {
6733                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6734                }
6735                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6736                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6737                }
6738            }
6739
6740            next_offset += envelope_size;
6741            _next_ordinal_to_read += 1;
6742            if next_offset >= end_offset {
6743                return Ok(());
6744            }
6745
6746            // Decode unknown envelopes for gaps in ordinals.
6747            while _next_ordinal_to_read < 2 {
6748                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6749                _next_ordinal_to_read += 1;
6750                next_offset += envelope_size;
6751            }
6752
6753            let next_out_of_line = decoder.next_out_of_line();
6754            let handles_before = decoder.remaining_handles();
6755            if let Some((inlined, num_bytes, num_handles)) =
6756                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6757            {
6758                let member_inline_size =
6759                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6760                if inlined != (member_inline_size <= 4) {
6761                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6762                }
6763                let inner_offset;
6764                let mut inner_depth = depth.clone();
6765                if inlined {
6766                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6767                    inner_offset = next_offset;
6768                } else {
6769                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6770                    inner_depth.increment()?;
6771                }
6772                let val_ref = self.initiator.get_or_insert_with(|| {
6773                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
6774                });
6775                fidl::decode!(
6776                    bool,
6777                    fidl::encoding::DefaultFuchsiaResourceDialect,
6778                    val_ref,
6779                    decoder,
6780                    inner_offset,
6781                    inner_depth
6782                )?;
6783                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6784                {
6785                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6786                }
6787                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6788                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6789                }
6790            }
6791
6792            next_offset += envelope_size;
6793            _next_ordinal_to_read += 1;
6794            if next_offset >= end_offset {
6795                return Ok(());
6796            }
6797
6798            // Decode unknown envelopes for gaps in ordinals.
6799            while _next_ordinal_to_read < 3 {
6800                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6801                _next_ordinal_to_read += 1;
6802                next_offset += envelope_size;
6803            }
6804
6805            let next_out_of_line = decoder.next_out_of_line();
6806            let handles_before = decoder.remaining_handles();
6807            if let Some((inlined, num_bytes, num_handles)) =
6808                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6809            {
6810                let member_inline_size = <fidl::encoding::UnboundedVector<ScoConnectionParameters> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6811                if inlined != (member_inline_size <= 4) {
6812                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6813                }
6814                let inner_offset;
6815                let mut inner_depth = depth.clone();
6816                if inlined {
6817                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6818                    inner_offset = next_offset;
6819                } else {
6820                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6821                    inner_depth.increment()?;
6822                }
6823                let val_ref = self.params.get_or_insert_with(|| {
6824                    fidl::new_empty!(
6825                        fidl::encoding::UnboundedVector<ScoConnectionParameters>,
6826                        fidl::encoding::DefaultFuchsiaResourceDialect
6827                    )
6828                });
6829                fidl::decode!(
6830                    fidl::encoding::UnboundedVector<ScoConnectionParameters>,
6831                    fidl::encoding::DefaultFuchsiaResourceDialect,
6832                    val_ref,
6833                    decoder,
6834                    inner_offset,
6835                    inner_depth
6836                )?;
6837                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6838                {
6839                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6840                }
6841                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6842                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6843                }
6844            }
6845
6846            next_offset += envelope_size;
6847            _next_ordinal_to_read += 1;
6848            if next_offset >= end_offset {
6849                return Ok(());
6850            }
6851
6852            // Decode unknown envelopes for gaps in ordinals.
6853            while _next_ordinal_to_read < 4 {
6854                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6855                _next_ordinal_to_read += 1;
6856                next_offset += envelope_size;
6857            }
6858
6859            let next_out_of_line = decoder.next_out_of_line();
6860            let handles_before = decoder.remaining_handles();
6861            if let Some((inlined, num_bytes, num_handles)) =
6862                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6863            {
6864                let member_inline_size = <fidl::encoding::Endpoint<
6865                    fidl::endpoints::ServerEnd<ScoConnectionMarker>,
6866                > as fidl::encoding::TypeMarker>::inline_size(
6867                    decoder.context
6868                );
6869                if inlined != (member_inline_size <= 4) {
6870                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6871                }
6872                let inner_offset;
6873                let mut inner_depth = depth.clone();
6874                if inlined {
6875                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6876                    inner_offset = next_offset;
6877                } else {
6878                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6879                    inner_depth.increment()?;
6880                }
6881                let val_ref = self.connection.get_or_insert_with(|| {
6882                    fidl::new_empty!(
6883                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>>,
6884                        fidl::encoding::DefaultFuchsiaResourceDialect
6885                    )
6886                });
6887                fidl::decode!(
6888                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>>,
6889                    fidl::encoding::DefaultFuchsiaResourceDialect,
6890                    val_ref,
6891                    decoder,
6892                    inner_offset,
6893                    inner_depth
6894                )?;
6895                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6896                {
6897                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6898                }
6899                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6900                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6901                }
6902            }
6903
6904            next_offset += envelope_size;
6905
6906            // Decode the remaining unknown envelopes.
6907            while next_offset < end_offset {
6908                _next_ordinal_to_read += 1;
6909                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6910                next_offset += envelope_size;
6911            }
6912
6913            Ok(())
6914        }
6915    }
6916
6917    impl ProfileSearchRequest {
6918        #[inline(always)]
6919        fn max_ordinal_present(&self) -> u64 {
6920            if let Some(_) = self.full_uuid {
6921                return 4;
6922            }
6923            if let Some(_) = self.results {
6924                return 3;
6925            }
6926            if let Some(_) = self.attr_ids {
6927                return 2;
6928            }
6929            if let Some(_) = self.service_uuid {
6930                return 1;
6931            }
6932            0
6933        }
6934    }
6935
6936    impl fidl::encoding::ResourceTypeMarker for ProfileSearchRequest {
6937        type Borrowed<'a> = &'a mut Self;
6938        fn take_or_borrow<'a>(
6939            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6940        ) -> Self::Borrowed<'a> {
6941            value
6942        }
6943    }
6944
6945    unsafe impl fidl::encoding::TypeMarker for ProfileSearchRequest {
6946        type Owned = Self;
6947
6948        #[inline(always)]
6949        fn inline_align(_context: fidl::encoding::Context) -> usize {
6950            8
6951        }
6952
6953        #[inline(always)]
6954        fn inline_size(_context: fidl::encoding::Context) -> usize {
6955            16
6956        }
6957    }
6958
6959    unsafe impl
6960        fidl::encoding::Encode<ProfileSearchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6961        for &mut ProfileSearchRequest
6962    {
6963        unsafe fn encode(
6964            self,
6965            encoder: &mut fidl::encoding::Encoder<
6966                '_,
6967                fidl::encoding::DefaultFuchsiaResourceDialect,
6968            >,
6969            offset: usize,
6970            mut depth: fidl::encoding::Depth,
6971        ) -> fidl::Result<()> {
6972            encoder.debug_check_bounds::<ProfileSearchRequest>(offset);
6973            // Vector header
6974            let max_ordinal: u64 = self.max_ordinal_present();
6975            encoder.write_num(max_ordinal, offset);
6976            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6977            // Calling encoder.out_of_line_offset(0) is not allowed.
6978            if max_ordinal == 0 {
6979                return Ok(());
6980            }
6981            depth.increment()?;
6982            let envelope_size = 8;
6983            let bytes_len = max_ordinal as usize * envelope_size;
6984            #[allow(unused_variables)]
6985            let offset = encoder.out_of_line_offset(bytes_len);
6986            let mut _prev_end_offset: usize = 0;
6987            if 1 > max_ordinal {
6988                return Ok(());
6989            }
6990
6991            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6992            // are envelope_size bytes.
6993            let cur_offset: usize = (1 - 1) * envelope_size;
6994
6995            // Zero reserved fields.
6996            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6997
6998            // Safety:
6999            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7000            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7001            //   envelope_size bytes, there is always sufficient room.
7002            fidl::encoding::encode_in_envelope_optional::<
7003                ServiceClassProfileIdentifier,
7004                fidl::encoding::DefaultFuchsiaResourceDialect,
7005            >(
7006                self.service_uuid.as_ref().map(
7007                    <ServiceClassProfileIdentifier as fidl::encoding::ValueTypeMarker>::borrow,
7008                ),
7009                encoder,
7010                offset + cur_offset,
7011                depth,
7012            )?;
7013
7014            _prev_end_offset = cur_offset + envelope_size;
7015            if 2 > max_ordinal {
7016                return Ok(());
7017            }
7018
7019            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7020            // are envelope_size bytes.
7021            let cur_offset: usize = (2 - 1) * envelope_size;
7022
7023            // Zero reserved fields.
7024            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7025
7026            // Safety:
7027            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7028            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7029            //   envelope_size bytes, there is always sufficient room.
7030            fidl::encoding::encode_in_envelope_optional::<
7031                fidl::encoding::Vector<u16, 512>,
7032                fidl::encoding::DefaultFuchsiaResourceDialect,
7033            >(
7034                self.attr_ids.as_ref().map(
7035                    <fidl::encoding::Vector<u16, 512> as fidl::encoding::ValueTypeMarker>::borrow,
7036                ),
7037                encoder,
7038                offset + cur_offset,
7039                depth,
7040            )?;
7041
7042            _prev_end_offset = cur_offset + envelope_size;
7043            if 3 > max_ordinal {
7044                return Ok(());
7045            }
7046
7047            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7048            // are envelope_size bytes.
7049            let cur_offset: usize = (3 - 1) * envelope_size;
7050
7051            // Zero reserved fields.
7052            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7053
7054            // Safety:
7055            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7056            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7057            //   envelope_size bytes, there is always sufficient room.
7058            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SearchResultsMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
7059            self.results.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SearchResultsMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
7060            encoder, offset + cur_offset, depth
7061        )?;
7062
7063            _prev_end_offset = cur_offset + envelope_size;
7064            if 4 > max_ordinal {
7065                return Ok(());
7066            }
7067
7068            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7069            // are envelope_size bytes.
7070            let cur_offset: usize = (4 - 1) * envelope_size;
7071
7072            // Zero reserved fields.
7073            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7074
7075            // Safety:
7076            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7077            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7078            //   envelope_size bytes, there is always sufficient room.
7079            fidl::encoding::encode_in_envelope_optional::<
7080                fidl_fuchsia_bluetooth::Uuid,
7081                fidl::encoding::DefaultFuchsiaResourceDialect,
7082            >(
7083                self.full_uuid
7084                    .as_ref()
7085                    .map(<fidl_fuchsia_bluetooth::Uuid as fidl::encoding::ValueTypeMarker>::borrow),
7086                encoder,
7087                offset + cur_offset,
7088                depth,
7089            )?;
7090
7091            _prev_end_offset = cur_offset + envelope_size;
7092
7093            Ok(())
7094        }
7095    }
7096
7097    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7098        for ProfileSearchRequest
7099    {
7100        #[inline(always)]
7101        fn new_empty() -> Self {
7102            Self::default()
7103        }
7104
7105        unsafe fn decode(
7106            &mut self,
7107            decoder: &mut fidl::encoding::Decoder<
7108                '_,
7109                fidl::encoding::DefaultFuchsiaResourceDialect,
7110            >,
7111            offset: usize,
7112            mut depth: fidl::encoding::Depth,
7113        ) -> fidl::Result<()> {
7114            decoder.debug_check_bounds::<Self>(offset);
7115            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7116                None => return Err(fidl::Error::NotNullable),
7117                Some(len) => len,
7118            };
7119            // Calling decoder.out_of_line_offset(0) is not allowed.
7120            if len == 0 {
7121                return Ok(());
7122            };
7123            depth.increment()?;
7124            let envelope_size = 8;
7125            let bytes_len = len * envelope_size;
7126            let offset = decoder.out_of_line_offset(bytes_len)?;
7127            // Decode the envelope for each type.
7128            let mut _next_ordinal_to_read = 0;
7129            let mut next_offset = offset;
7130            let end_offset = offset + bytes_len;
7131            _next_ordinal_to_read += 1;
7132            if next_offset >= end_offset {
7133                return Ok(());
7134            }
7135
7136            // Decode unknown envelopes for gaps in ordinals.
7137            while _next_ordinal_to_read < 1 {
7138                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7139                _next_ordinal_to_read += 1;
7140                next_offset += envelope_size;
7141            }
7142
7143            let next_out_of_line = decoder.next_out_of_line();
7144            let handles_before = decoder.remaining_handles();
7145            if let Some((inlined, num_bytes, num_handles)) =
7146                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7147            {
7148                let member_inline_size =
7149                    <ServiceClassProfileIdentifier as fidl::encoding::TypeMarker>::inline_size(
7150                        decoder.context,
7151                    );
7152                if inlined != (member_inline_size <= 4) {
7153                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7154                }
7155                let inner_offset;
7156                let mut inner_depth = depth.clone();
7157                if inlined {
7158                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7159                    inner_offset = next_offset;
7160                } else {
7161                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7162                    inner_depth.increment()?;
7163                }
7164                let val_ref = self.service_uuid.get_or_insert_with(|| {
7165                    fidl::new_empty!(
7166                        ServiceClassProfileIdentifier,
7167                        fidl::encoding::DefaultFuchsiaResourceDialect
7168                    )
7169                });
7170                fidl::decode!(
7171                    ServiceClassProfileIdentifier,
7172                    fidl::encoding::DefaultFuchsiaResourceDialect,
7173                    val_ref,
7174                    decoder,
7175                    inner_offset,
7176                    inner_depth
7177                )?;
7178                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7179                {
7180                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7181                }
7182                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7183                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7184                }
7185            }
7186
7187            next_offset += envelope_size;
7188            _next_ordinal_to_read += 1;
7189            if next_offset >= end_offset {
7190                return Ok(());
7191            }
7192
7193            // Decode unknown envelopes for gaps in ordinals.
7194            while _next_ordinal_to_read < 2 {
7195                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7196                _next_ordinal_to_read += 1;
7197                next_offset += envelope_size;
7198            }
7199
7200            let next_out_of_line = decoder.next_out_of_line();
7201            let handles_before = decoder.remaining_handles();
7202            if let Some((inlined, num_bytes, num_handles)) =
7203                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7204            {
7205                let member_inline_size =
7206                    <fidl::encoding::Vector<u16, 512> as fidl::encoding::TypeMarker>::inline_size(
7207                        decoder.context,
7208                    );
7209                if inlined != (member_inline_size <= 4) {
7210                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7211                }
7212                let inner_offset;
7213                let mut inner_depth = depth.clone();
7214                if inlined {
7215                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7216                    inner_offset = next_offset;
7217                } else {
7218                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7219                    inner_depth.increment()?;
7220                }
7221                let val_ref =
7222                self.attr_ids.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u16, 512>, fidl::encoding::DefaultFuchsiaResourceDialect));
7223                fidl::decode!(fidl::encoding::Vector<u16, 512>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7224                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7225                {
7226                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7227                }
7228                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7229                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7230                }
7231            }
7232
7233            next_offset += envelope_size;
7234            _next_ordinal_to_read += 1;
7235            if next_offset >= end_offset {
7236                return Ok(());
7237            }
7238
7239            // Decode unknown envelopes for gaps in ordinals.
7240            while _next_ordinal_to_read < 3 {
7241                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7242                _next_ordinal_to_read += 1;
7243                next_offset += envelope_size;
7244            }
7245
7246            let next_out_of_line = decoder.next_out_of_line();
7247            let handles_before = decoder.remaining_handles();
7248            if let Some((inlined, num_bytes, num_handles)) =
7249                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7250            {
7251                let member_inline_size = <fidl::encoding::Endpoint<
7252                    fidl::endpoints::ClientEnd<SearchResultsMarker>,
7253                > as fidl::encoding::TypeMarker>::inline_size(
7254                    decoder.context
7255                );
7256                if inlined != (member_inline_size <= 4) {
7257                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7258                }
7259                let inner_offset;
7260                let mut inner_depth = depth.clone();
7261                if inlined {
7262                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7263                    inner_offset = next_offset;
7264                } else {
7265                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7266                    inner_depth.increment()?;
7267                }
7268                let val_ref = self.results.get_or_insert_with(|| {
7269                    fidl::new_empty!(
7270                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SearchResultsMarker>>,
7271                        fidl::encoding::DefaultFuchsiaResourceDialect
7272                    )
7273                });
7274                fidl::decode!(
7275                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SearchResultsMarker>>,
7276                    fidl::encoding::DefaultFuchsiaResourceDialect,
7277                    val_ref,
7278                    decoder,
7279                    inner_offset,
7280                    inner_depth
7281                )?;
7282                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7283                {
7284                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7285                }
7286                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7287                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7288                }
7289            }
7290
7291            next_offset += envelope_size;
7292            _next_ordinal_to_read += 1;
7293            if next_offset >= end_offset {
7294                return Ok(());
7295            }
7296
7297            // Decode unknown envelopes for gaps in ordinals.
7298            while _next_ordinal_to_read < 4 {
7299                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7300                _next_ordinal_to_read += 1;
7301                next_offset += envelope_size;
7302            }
7303
7304            let next_out_of_line = decoder.next_out_of_line();
7305            let handles_before = decoder.remaining_handles();
7306            if let Some((inlined, num_bytes, num_handles)) =
7307                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7308            {
7309                let member_inline_size =
7310                    <fidl_fuchsia_bluetooth::Uuid as fidl::encoding::TypeMarker>::inline_size(
7311                        decoder.context,
7312                    );
7313                if inlined != (member_inline_size <= 4) {
7314                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7315                }
7316                let inner_offset;
7317                let mut inner_depth = depth.clone();
7318                if inlined {
7319                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7320                    inner_offset = next_offset;
7321                } else {
7322                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7323                    inner_depth.increment()?;
7324                }
7325                let val_ref = self.full_uuid.get_or_insert_with(|| {
7326                    fidl::new_empty!(
7327                        fidl_fuchsia_bluetooth::Uuid,
7328                        fidl::encoding::DefaultFuchsiaResourceDialect
7329                    )
7330                });
7331                fidl::decode!(
7332                    fidl_fuchsia_bluetooth::Uuid,
7333                    fidl::encoding::DefaultFuchsiaResourceDialect,
7334                    val_ref,
7335                    decoder,
7336                    inner_offset,
7337                    inner_depth
7338                )?;
7339                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7340                {
7341                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7342                }
7343                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7344                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7345                }
7346            }
7347
7348            next_offset += envelope_size;
7349
7350            // Decode the remaining unknown envelopes.
7351            while next_offset < end_offset {
7352                _next_ordinal_to_read += 1;
7353                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7354                next_offset += envelope_size;
7355            }
7356
7357            Ok(())
7358        }
7359    }
7360}