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