Skip to main content

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