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