fidl_fuchsia_bluetooth_bredr/
fidl_fuchsia_bluetooth_bredr.rs

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