fidl_fuchsia_bluetooth_avrcp_test/
fidl_fuchsia_bluetooth_avrcp_test.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_avrcp_test__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct PeerManagerExtGetBrowseControllerForTargetRequest {
16    pub peer_id: fidl_fuchsia_bluetooth::PeerId,
17    pub client: fidl::endpoints::ServerEnd<BrowseControllerExtMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for PeerManagerExtGetBrowseControllerForTargetRequest
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct PeerManagerExtGetControllerForTargetRequest {
27    pub peer_id: fidl_fuchsia_bluetooth::PeerId,
28    pub client: fidl::endpoints::ServerEnd<ControllerExtMarker>,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for PeerManagerExtGetControllerForTargetRequest
33{
34}
35
36#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
37pub struct BrowseControllerExtMarker;
38
39impl fidl::endpoints::ProtocolMarker for BrowseControllerExtMarker {
40    type Proxy = BrowseControllerExtProxy;
41    type RequestStream = BrowseControllerExtRequestStream;
42    #[cfg(target_os = "fuchsia")]
43    type SynchronousProxy = BrowseControllerExtSynchronousProxy;
44
45    const DEBUG_NAME: &'static str = "(anonymous) BrowseControllerExt";
46}
47pub type BrowseControllerExtSendRawBrowseCommandResult =
48    Result<Vec<u8>, fidl_fuchsia_bluetooth_avrcp::BrowseControllerError>;
49
50pub trait BrowseControllerExtProxyInterface: Send + Sync {
51    type IsConnectedResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
52    fn r#is_connected(&self) -> Self::IsConnectedResponseFut;
53    type SendRawBrowseCommandResponseFut: std::future::Future<
54            Output = Result<BrowseControllerExtSendRawBrowseCommandResult, fidl::Error>,
55        > + Send;
56    fn r#send_raw_browse_command(
57        &self,
58        pdu_id: u8,
59        command: &[u8],
60    ) -> Self::SendRawBrowseCommandResponseFut;
61}
62#[derive(Debug)]
63#[cfg(target_os = "fuchsia")]
64pub struct BrowseControllerExtSynchronousProxy {
65    client: fidl::client::sync::Client,
66}
67
68#[cfg(target_os = "fuchsia")]
69impl fidl::endpoints::SynchronousProxy for BrowseControllerExtSynchronousProxy {
70    type Proxy = BrowseControllerExtProxy;
71    type Protocol = BrowseControllerExtMarker;
72
73    fn from_channel(inner: fidl::Channel) -> Self {
74        Self::new(inner)
75    }
76
77    fn into_channel(self) -> fidl::Channel {
78        self.client.into_channel()
79    }
80
81    fn as_channel(&self) -> &fidl::Channel {
82        self.client.as_channel()
83    }
84}
85
86#[cfg(target_os = "fuchsia")]
87impl BrowseControllerExtSynchronousProxy {
88    pub fn new(channel: fidl::Channel) -> Self {
89        let protocol_name =
90            <BrowseControllerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
91        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
92    }
93
94    pub fn into_channel(self) -> fidl::Channel {
95        self.client.into_channel()
96    }
97
98    /// Waits until an event arrives and returns it. It is safe for other
99    /// threads to make concurrent requests while waiting for an event.
100    pub fn wait_for_event(
101        &self,
102        deadline: zx::MonotonicInstant,
103    ) -> Result<BrowseControllerExtEvent, fidl::Error> {
104        BrowseControllerExtEvent::decode(self.client.wait_for_event(deadline)?)
105    }
106
107    /// Returns whether there is an underlying connection open with the remote device currently.
108    pub fn r#is_connected(&self, ___deadline: zx::MonotonicInstant) -> Result<bool, fidl::Error> {
109        let _response = self
110            .client
111            .send_query::<fidl::encoding::EmptyPayload, BrowseControllerExtIsConnectedResponse>(
112                (),
113                0x276450990f1915b6,
114                fidl::encoding::DynamicFlags::empty(),
115                ___deadline,
116            )?;
117        Ok(_response.connected)
118    }
119
120    /// Send raw AVRCP "browse" command packet to a specific PDU on the remote peer.
121    /// Returns the entire response packet including the headers or error if the remote endpoint
122    /// disconnects or does not return a response in set amount of time.
123    /// + request `command` contains a specific browse command's encoded
124    ///         parameters.
125    pub fn r#send_raw_browse_command(
126        &self,
127        mut pdu_id: u8,
128        mut command: &[u8],
129        ___deadline: zx::MonotonicInstant,
130    ) -> Result<BrowseControllerExtSendRawBrowseCommandResult, fidl::Error> {
131        let _response = self.client.send_query::<
132            BrowseControllerExtSendRawBrowseCommandRequest,
133            fidl::encoding::ResultType<BrowseControllerExtSendRawBrowseCommandResponse, fidl_fuchsia_bluetooth_avrcp::BrowseControllerError>,
134        >(
135            (pdu_id, command,),
136            0x7346e59b68ac4a71,
137            fidl::encoding::DynamicFlags::empty(),
138            ___deadline,
139        )?;
140        Ok(_response.map(|x| x.response))
141    }
142}
143
144#[cfg(target_os = "fuchsia")]
145impl From<BrowseControllerExtSynchronousProxy> for zx::Handle {
146    fn from(value: BrowseControllerExtSynchronousProxy) -> Self {
147        value.into_channel().into()
148    }
149}
150
151#[cfg(target_os = "fuchsia")]
152impl From<fidl::Channel> for BrowseControllerExtSynchronousProxy {
153    fn from(value: fidl::Channel) -> Self {
154        Self::new(value)
155    }
156}
157
158#[cfg(target_os = "fuchsia")]
159impl fidl::endpoints::FromClient for BrowseControllerExtSynchronousProxy {
160    type Protocol = BrowseControllerExtMarker;
161
162    fn from_client(value: fidl::endpoints::ClientEnd<BrowseControllerExtMarker>) -> Self {
163        Self::new(value.into_channel())
164    }
165}
166
167#[derive(Debug, Clone)]
168pub struct BrowseControllerExtProxy {
169    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
170}
171
172impl fidl::endpoints::Proxy for BrowseControllerExtProxy {
173    type Protocol = BrowseControllerExtMarker;
174
175    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
176        Self::new(inner)
177    }
178
179    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
180        self.client.into_channel().map_err(|client| Self { client })
181    }
182
183    fn as_channel(&self) -> &::fidl::AsyncChannel {
184        self.client.as_channel()
185    }
186}
187
188impl BrowseControllerExtProxy {
189    /// Create a new Proxy for fuchsia.bluetooth.avrcp.test/BrowseControllerExt.
190    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
191        let protocol_name =
192            <BrowseControllerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
193        Self { client: fidl::client::Client::new(channel, protocol_name) }
194    }
195
196    /// Get a Stream of events from the remote end of the protocol.
197    ///
198    /// # Panics
199    ///
200    /// Panics if the event stream was already taken.
201    pub fn take_event_stream(&self) -> BrowseControllerExtEventStream {
202        BrowseControllerExtEventStream { event_receiver: self.client.take_event_receiver() }
203    }
204
205    /// Returns whether there is an underlying connection open with the remote device currently.
206    pub fn r#is_connected(
207        &self,
208    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
209        BrowseControllerExtProxyInterface::r#is_connected(self)
210    }
211
212    /// Send raw AVRCP "browse" command packet to a specific PDU on the remote peer.
213    /// Returns the entire response packet including the headers or error if the remote endpoint
214    /// disconnects or does not return a response in set amount of time.
215    /// + request `command` contains a specific browse command's encoded
216    ///         parameters.
217    pub fn r#send_raw_browse_command(
218        &self,
219        mut pdu_id: u8,
220        mut command: &[u8],
221    ) -> fidl::client::QueryResponseFut<
222        BrowseControllerExtSendRawBrowseCommandResult,
223        fidl::encoding::DefaultFuchsiaResourceDialect,
224    > {
225        BrowseControllerExtProxyInterface::r#send_raw_browse_command(self, pdu_id, command)
226    }
227}
228
229impl BrowseControllerExtProxyInterface for BrowseControllerExtProxy {
230    type IsConnectedResponseFut =
231        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
232    fn r#is_connected(&self) -> Self::IsConnectedResponseFut {
233        fn _decode(
234            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
235        ) -> Result<bool, fidl::Error> {
236            let _response = fidl::client::decode_transaction_body::<
237                BrowseControllerExtIsConnectedResponse,
238                fidl::encoding::DefaultFuchsiaResourceDialect,
239                0x276450990f1915b6,
240            >(_buf?)?;
241            Ok(_response.connected)
242        }
243        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
244            (),
245            0x276450990f1915b6,
246            fidl::encoding::DynamicFlags::empty(),
247            _decode,
248        )
249    }
250
251    type SendRawBrowseCommandResponseFut = fidl::client::QueryResponseFut<
252        BrowseControllerExtSendRawBrowseCommandResult,
253        fidl::encoding::DefaultFuchsiaResourceDialect,
254    >;
255    fn r#send_raw_browse_command(
256        &self,
257        mut pdu_id: u8,
258        mut command: &[u8],
259    ) -> Self::SendRawBrowseCommandResponseFut {
260        fn _decode(
261            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
262        ) -> Result<BrowseControllerExtSendRawBrowseCommandResult, fidl::Error> {
263            let _response = fidl::client::decode_transaction_body::<
264                fidl::encoding::ResultType<
265                    BrowseControllerExtSendRawBrowseCommandResponse,
266                    fidl_fuchsia_bluetooth_avrcp::BrowseControllerError,
267                >,
268                fidl::encoding::DefaultFuchsiaResourceDialect,
269                0x7346e59b68ac4a71,
270            >(_buf?)?;
271            Ok(_response.map(|x| x.response))
272        }
273        self.client.send_query_and_decode::<
274            BrowseControllerExtSendRawBrowseCommandRequest,
275            BrowseControllerExtSendRawBrowseCommandResult,
276        >(
277            (pdu_id, command,),
278            0x7346e59b68ac4a71,
279            fidl::encoding::DynamicFlags::empty(),
280            _decode,
281        )
282    }
283}
284
285pub struct BrowseControllerExtEventStream {
286    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
287}
288
289impl std::marker::Unpin for BrowseControllerExtEventStream {}
290
291impl futures::stream::FusedStream for BrowseControllerExtEventStream {
292    fn is_terminated(&self) -> bool {
293        self.event_receiver.is_terminated()
294    }
295}
296
297impl futures::Stream for BrowseControllerExtEventStream {
298    type Item = Result<BrowseControllerExtEvent, fidl::Error>;
299
300    fn poll_next(
301        mut self: std::pin::Pin<&mut Self>,
302        cx: &mut std::task::Context<'_>,
303    ) -> std::task::Poll<Option<Self::Item>> {
304        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
305            &mut self.event_receiver,
306            cx
307        )?) {
308            Some(buf) => std::task::Poll::Ready(Some(BrowseControllerExtEvent::decode(buf))),
309            None => std::task::Poll::Ready(None),
310        }
311    }
312}
313
314#[derive(Debug)]
315pub enum BrowseControllerExtEvent {}
316
317impl BrowseControllerExtEvent {
318    /// Decodes a message buffer as a [`BrowseControllerExtEvent`].
319    fn decode(
320        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
321    ) -> Result<BrowseControllerExtEvent, fidl::Error> {
322        let (bytes, _handles) = buf.split_mut();
323        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
324        debug_assert_eq!(tx_header.tx_id, 0);
325        match tx_header.ordinal {
326            _ => Err(fidl::Error::UnknownOrdinal {
327                ordinal: tx_header.ordinal,
328                protocol_name:
329                    <BrowseControllerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
330            }),
331        }
332    }
333}
334
335/// A Stream of incoming requests for fuchsia.bluetooth.avrcp.test/BrowseControllerExt.
336pub struct BrowseControllerExtRequestStream {
337    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
338    is_terminated: bool,
339}
340
341impl std::marker::Unpin for BrowseControllerExtRequestStream {}
342
343impl futures::stream::FusedStream for BrowseControllerExtRequestStream {
344    fn is_terminated(&self) -> bool {
345        self.is_terminated
346    }
347}
348
349impl fidl::endpoints::RequestStream for BrowseControllerExtRequestStream {
350    type Protocol = BrowseControllerExtMarker;
351    type ControlHandle = BrowseControllerExtControlHandle;
352
353    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
354        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
355    }
356
357    fn control_handle(&self) -> Self::ControlHandle {
358        BrowseControllerExtControlHandle { inner: self.inner.clone() }
359    }
360
361    fn into_inner(
362        self,
363    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
364    {
365        (self.inner, self.is_terminated)
366    }
367
368    fn from_inner(
369        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
370        is_terminated: bool,
371    ) -> Self {
372        Self { inner, is_terminated }
373    }
374}
375
376impl futures::Stream for BrowseControllerExtRequestStream {
377    type Item = Result<BrowseControllerExtRequest, fidl::Error>;
378
379    fn poll_next(
380        mut self: std::pin::Pin<&mut Self>,
381        cx: &mut std::task::Context<'_>,
382    ) -> std::task::Poll<Option<Self::Item>> {
383        let this = &mut *self;
384        if this.inner.check_shutdown(cx) {
385            this.is_terminated = true;
386            return std::task::Poll::Ready(None);
387        }
388        if this.is_terminated {
389            panic!("polled BrowseControllerExtRequestStream after completion");
390        }
391        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
392            |bytes, handles| {
393                match this.inner.channel().read_etc(cx, bytes, handles) {
394                    std::task::Poll::Ready(Ok(())) => {}
395                    std::task::Poll::Pending => return std::task::Poll::Pending,
396                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
397                        this.is_terminated = true;
398                        return std::task::Poll::Ready(None);
399                    }
400                    std::task::Poll::Ready(Err(e)) => {
401                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
402                            e.into(),
403                        ))))
404                    }
405                }
406
407                // A message has been received from the channel
408                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
409
410                std::task::Poll::Ready(Some(match header.ordinal {
411                0x276450990f1915b6 => {
412                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
413                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
414                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
415                    let control_handle = BrowseControllerExtControlHandle {
416                        inner: this.inner.clone(),
417                    };
418                    Ok(BrowseControllerExtRequest::IsConnected {
419                        responder: BrowseControllerExtIsConnectedResponder {
420                            control_handle: std::mem::ManuallyDrop::new(control_handle),
421                            tx_id: header.tx_id,
422                        },
423                    })
424                }
425                0x7346e59b68ac4a71 => {
426                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
427                    let mut req = fidl::new_empty!(BrowseControllerExtSendRawBrowseCommandRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
428                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BrowseControllerExtSendRawBrowseCommandRequest>(&header, _body_bytes, handles, &mut req)?;
429                    let control_handle = BrowseControllerExtControlHandle {
430                        inner: this.inner.clone(),
431                    };
432                    Ok(BrowseControllerExtRequest::SendRawBrowseCommand {pdu_id: req.pdu_id,
433command: req.command,
434
435                        responder: BrowseControllerExtSendRawBrowseCommandResponder {
436                            control_handle: std::mem::ManuallyDrop::new(control_handle),
437                            tx_id: header.tx_id,
438                        },
439                    })
440                }
441                _ => Err(fidl::Error::UnknownOrdinal {
442                    ordinal: header.ordinal,
443                    protocol_name: <BrowseControllerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
444                }),
445            }))
446            },
447        )
448    }
449}
450
451/// Provides additional methods not in `BrowseController` that are strictly for
452/// testing and debug.
453#[derive(Debug)]
454pub enum BrowseControllerExtRequest {
455    /// Returns whether there is an underlying connection open with the remote device currently.
456    IsConnected { responder: BrowseControllerExtIsConnectedResponder },
457    /// Send raw AVRCP "browse" command packet to a specific PDU on the remote peer.
458    /// Returns the entire response packet including the headers or error if the remote endpoint
459    /// disconnects or does not return a response in set amount of time.
460    /// + request `command` contains a specific browse command's encoded
461    ///         parameters.
462    SendRawBrowseCommand {
463        pdu_id: u8,
464        command: Vec<u8>,
465        responder: BrowseControllerExtSendRawBrowseCommandResponder,
466    },
467}
468
469impl BrowseControllerExtRequest {
470    #[allow(irrefutable_let_patterns)]
471    pub fn into_is_connected(self) -> Option<(BrowseControllerExtIsConnectedResponder)> {
472        if let BrowseControllerExtRequest::IsConnected { responder } = self {
473            Some((responder))
474        } else {
475            None
476        }
477    }
478
479    #[allow(irrefutable_let_patterns)]
480    pub fn into_send_raw_browse_command(
481        self,
482    ) -> Option<(u8, Vec<u8>, BrowseControllerExtSendRawBrowseCommandResponder)> {
483        if let BrowseControllerExtRequest::SendRawBrowseCommand { pdu_id, command, responder } =
484            self
485        {
486            Some((pdu_id, command, responder))
487        } else {
488            None
489        }
490    }
491
492    /// Name of the method defined in FIDL
493    pub fn method_name(&self) -> &'static str {
494        match *self {
495            BrowseControllerExtRequest::IsConnected { .. } => "is_connected",
496            BrowseControllerExtRequest::SendRawBrowseCommand { .. } => "send_raw_browse_command",
497        }
498    }
499}
500
501#[derive(Debug, Clone)]
502pub struct BrowseControllerExtControlHandle {
503    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
504}
505
506impl fidl::endpoints::ControlHandle for BrowseControllerExtControlHandle {
507    fn shutdown(&self) {
508        self.inner.shutdown()
509    }
510    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
511        self.inner.shutdown_with_epitaph(status)
512    }
513
514    fn is_closed(&self) -> bool {
515        self.inner.channel().is_closed()
516    }
517    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
518        self.inner.channel().on_closed()
519    }
520
521    #[cfg(target_os = "fuchsia")]
522    fn signal_peer(
523        &self,
524        clear_mask: zx::Signals,
525        set_mask: zx::Signals,
526    ) -> Result<(), zx_status::Status> {
527        use fidl::Peered;
528        self.inner.channel().signal_peer(clear_mask, set_mask)
529    }
530}
531
532impl BrowseControllerExtControlHandle {}
533
534#[must_use = "FIDL methods require a response to be sent"]
535#[derive(Debug)]
536pub struct BrowseControllerExtIsConnectedResponder {
537    control_handle: std::mem::ManuallyDrop<BrowseControllerExtControlHandle>,
538    tx_id: u32,
539}
540
541/// Set the the channel to be shutdown (see [`BrowseControllerExtControlHandle::shutdown`])
542/// if the responder is dropped without sending a response, so that the client
543/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
544impl std::ops::Drop for BrowseControllerExtIsConnectedResponder {
545    fn drop(&mut self) {
546        self.control_handle.shutdown();
547        // Safety: drops once, never accessed again
548        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
549    }
550}
551
552impl fidl::endpoints::Responder for BrowseControllerExtIsConnectedResponder {
553    type ControlHandle = BrowseControllerExtControlHandle;
554
555    fn control_handle(&self) -> &BrowseControllerExtControlHandle {
556        &self.control_handle
557    }
558
559    fn drop_without_shutdown(mut self) {
560        // Safety: drops once, never accessed again due to mem::forget
561        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
562        // Prevent Drop from running (which would shut down the channel)
563        std::mem::forget(self);
564    }
565}
566
567impl BrowseControllerExtIsConnectedResponder {
568    /// Sends a response to the FIDL transaction.
569    ///
570    /// Sets the channel to shutdown if an error occurs.
571    pub fn send(self, mut connected: bool) -> Result<(), fidl::Error> {
572        let _result = self.send_raw(connected);
573        if _result.is_err() {
574            self.control_handle.shutdown();
575        }
576        self.drop_without_shutdown();
577        _result
578    }
579
580    /// Similar to "send" but does not shutdown the channel if an error occurs.
581    pub fn send_no_shutdown_on_err(self, mut connected: bool) -> Result<(), fidl::Error> {
582        let _result = self.send_raw(connected);
583        self.drop_without_shutdown();
584        _result
585    }
586
587    fn send_raw(&self, mut connected: bool) -> Result<(), fidl::Error> {
588        self.control_handle.inner.send::<BrowseControllerExtIsConnectedResponse>(
589            (connected,),
590            self.tx_id,
591            0x276450990f1915b6,
592            fidl::encoding::DynamicFlags::empty(),
593        )
594    }
595}
596
597#[must_use = "FIDL methods require a response to be sent"]
598#[derive(Debug)]
599pub struct BrowseControllerExtSendRawBrowseCommandResponder {
600    control_handle: std::mem::ManuallyDrop<BrowseControllerExtControlHandle>,
601    tx_id: u32,
602}
603
604/// Set the the channel to be shutdown (see [`BrowseControllerExtControlHandle::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 BrowseControllerExtSendRawBrowseCommandResponder {
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 BrowseControllerExtSendRawBrowseCommandResponder {
616    type ControlHandle = BrowseControllerExtControlHandle;
617
618    fn control_handle(&self) -> &BrowseControllerExtControlHandle {
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 BrowseControllerExtSendRawBrowseCommandResponder {
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<&[u8], fidl_fuchsia_bluetooth_avrcp::BrowseControllerError>,
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<&[u8], fidl_fuchsia_bluetooth_avrcp::BrowseControllerError>,
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<&[u8], fidl_fuchsia_bluetooth_avrcp::BrowseControllerError>,
659    ) -> Result<(), fidl::Error> {
660        self.control_handle.inner.send::<fidl::encoding::ResultType<
661            BrowseControllerExtSendRawBrowseCommandResponse,
662            fidl_fuchsia_bluetooth_avrcp::BrowseControllerError,
663        >>(
664            result.map(|response| (response,)),
665            self.tx_id,
666            0x7346e59b68ac4a71,
667            fidl::encoding::DynamicFlags::empty(),
668        )
669    }
670}
671
672#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
673pub struct ControllerExtMarker;
674
675impl fidl::endpoints::ProtocolMarker for ControllerExtMarker {
676    type Proxy = ControllerExtProxy;
677    type RequestStream = ControllerExtRequestStream;
678    #[cfg(target_os = "fuchsia")]
679    type SynchronousProxy = ControllerExtSynchronousProxy;
680
681    const DEBUG_NAME: &'static str = "(anonymous) ControllerExt";
682}
683pub type ControllerExtGetEventsSupportedResult = Result<
684    Vec<fidl_fuchsia_bluetooth_avrcp::NotificationEvent>,
685    fidl_fuchsia_bluetooth_avrcp::ControllerError,
686>;
687pub type ControllerExtSendRawVendorDependentCommandResult =
688    Result<Vec<u8>, fidl_fuchsia_bluetooth_avrcp::ControllerError>;
689
690pub trait ControllerExtProxyInterface: Send + Sync {
691    type IsConnectedResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
692    fn r#is_connected(&self) -> Self::IsConnectedResponseFut;
693    type GetEventsSupportedResponseFut: std::future::Future<Output = Result<ControllerExtGetEventsSupportedResult, fidl::Error>>
694        + Send;
695    fn r#get_events_supported(&self) -> Self::GetEventsSupportedResponseFut;
696    type SendRawVendorDependentCommandResponseFut: std::future::Future<
697            Output = Result<ControllerExtSendRawVendorDependentCommandResult, fidl::Error>,
698        > + Send;
699    fn r#send_raw_vendor_dependent_command(
700        &self,
701        pdu_id: u8,
702        command: &[u8],
703    ) -> Self::SendRawVendorDependentCommandResponseFut;
704}
705#[derive(Debug)]
706#[cfg(target_os = "fuchsia")]
707pub struct ControllerExtSynchronousProxy {
708    client: fidl::client::sync::Client,
709}
710
711#[cfg(target_os = "fuchsia")]
712impl fidl::endpoints::SynchronousProxy for ControllerExtSynchronousProxy {
713    type Proxy = ControllerExtProxy;
714    type Protocol = ControllerExtMarker;
715
716    fn from_channel(inner: fidl::Channel) -> Self {
717        Self::new(inner)
718    }
719
720    fn into_channel(self) -> fidl::Channel {
721        self.client.into_channel()
722    }
723
724    fn as_channel(&self) -> &fidl::Channel {
725        self.client.as_channel()
726    }
727}
728
729#[cfg(target_os = "fuchsia")]
730impl ControllerExtSynchronousProxy {
731    pub fn new(channel: fidl::Channel) -> Self {
732        let protocol_name = <ControllerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
733        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
734    }
735
736    pub fn into_channel(self) -> fidl::Channel {
737        self.client.into_channel()
738    }
739
740    /// Waits until an event arrives and returns it. It is safe for other
741    /// threads to make concurrent requests while waiting for an event.
742    pub fn wait_for_event(
743        &self,
744        deadline: zx::MonotonicInstant,
745    ) -> Result<ControllerExtEvent, fidl::Error> {
746        ControllerExtEvent::decode(self.client.wait_for_event(deadline)?)
747    }
748
749    /// Returns whether there is an underlying connection open with the remote device currently.
750    pub fn r#is_connected(&self, ___deadline: zx::MonotonicInstant) -> Result<bool, fidl::Error> {
751        let _response = self
752            .client
753            .send_query::<fidl::encoding::EmptyPayload, ControllerExtIsConnectedResponse>(
754                (),
755                0x403f7bc6dbbcfc4f,
756                fidl::encoding::DynamicFlags::empty(),
757                ___deadline,
758            )?;
759        Ok(_response.connected)
760    }
761
762    /// Queries the target and returns what events are supported for notification.
763    /// Sends GetCapabilties(0x03 (`EVENTS_SUPPORTED`)) command for all events supported by
764    /// the negoitated version of AVRCP.
765    pub fn r#get_events_supported(
766        &self,
767        ___deadline: zx::MonotonicInstant,
768    ) -> Result<ControllerExtGetEventsSupportedResult, fidl::Error> {
769        let _response = self
770            .client
771            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
772                ControllerExtGetEventsSupportedResponse,
773                fidl_fuchsia_bluetooth_avrcp::ControllerError,
774            >>(
775                (), 0x13465d8abf04dd26, fidl::encoding::DynamicFlags::empty(), ___deadline
776            )?;
777        Ok(_response.map(|x| x.events_supported))
778    }
779
780    /// Send raw vendor depedent "Control" command packet to a specific PDU on the remote peer.
781    /// Returns the entire response packet including the headers or error if the remote endpoint
782    /// disconnects or does not return a response in set amount of time.
783    pub fn r#send_raw_vendor_dependent_command(
784        &self,
785        mut pdu_id: u8,
786        mut command: &[u8],
787        ___deadline: zx::MonotonicInstant,
788    ) -> Result<ControllerExtSendRawVendorDependentCommandResult, fidl::Error> {
789        let _response = self.client.send_query::<
790            ControllerExtSendRawVendorDependentCommandRequest,
791            fidl::encoding::ResultType<ControllerExtSendRawVendorDependentCommandResponse, fidl_fuchsia_bluetooth_avrcp::ControllerError>,
792        >(
793            (pdu_id, command,),
794            0x48004b651df5f606,
795            fidl::encoding::DynamicFlags::empty(),
796            ___deadline,
797        )?;
798        Ok(_response.map(|x| x.response))
799    }
800}
801
802#[cfg(target_os = "fuchsia")]
803impl From<ControllerExtSynchronousProxy> for zx::Handle {
804    fn from(value: ControllerExtSynchronousProxy) -> Self {
805        value.into_channel().into()
806    }
807}
808
809#[cfg(target_os = "fuchsia")]
810impl From<fidl::Channel> for ControllerExtSynchronousProxy {
811    fn from(value: fidl::Channel) -> Self {
812        Self::new(value)
813    }
814}
815
816#[cfg(target_os = "fuchsia")]
817impl fidl::endpoints::FromClient for ControllerExtSynchronousProxy {
818    type Protocol = ControllerExtMarker;
819
820    fn from_client(value: fidl::endpoints::ClientEnd<ControllerExtMarker>) -> Self {
821        Self::new(value.into_channel())
822    }
823}
824
825#[derive(Debug, Clone)]
826pub struct ControllerExtProxy {
827    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
828}
829
830impl fidl::endpoints::Proxy for ControllerExtProxy {
831    type Protocol = ControllerExtMarker;
832
833    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
834        Self::new(inner)
835    }
836
837    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
838        self.client.into_channel().map_err(|client| Self { client })
839    }
840
841    fn as_channel(&self) -> &::fidl::AsyncChannel {
842        self.client.as_channel()
843    }
844}
845
846impl ControllerExtProxy {
847    /// Create a new Proxy for fuchsia.bluetooth.avrcp.test/ControllerExt.
848    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
849        let protocol_name = <ControllerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
850        Self { client: fidl::client::Client::new(channel, protocol_name) }
851    }
852
853    /// Get a Stream of events from the remote end of the protocol.
854    ///
855    /// # Panics
856    ///
857    /// Panics if the event stream was already taken.
858    pub fn take_event_stream(&self) -> ControllerExtEventStream {
859        ControllerExtEventStream { event_receiver: self.client.take_event_receiver() }
860    }
861
862    /// Returns whether there is an underlying connection open with the remote device currently.
863    pub fn r#is_connected(
864        &self,
865    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
866        ControllerExtProxyInterface::r#is_connected(self)
867    }
868
869    /// Queries the target and returns what events are supported for notification.
870    /// Sends GetCapabilties(0x03 (`EVENTS_SUPPORTED`)) command for all events supported by
871    /// the negoitated version of AVRCP.
872    pub fn r#get_events_supported(
873        &self,
874    ) -> fidl::client::QueryResponseFut<
875        ControllerExtGetEventsSupportedResult,
876        fidl::encoding::DefaultFuchsiaResourceDialect,
877    > {
878        ControllerExtProxyInterface::r#get_events_supported(self)
879    }
880
881    /// Send raw vendor depedent "Control" command packet to a specific PDU on the remote peer.
882    /// Returns the entire response packet including the headers or error if the remote endpoint
883    /// disconnects or does not return a response in set amount of time.
884    pub fn r#send_raw_vendor_dependent_command(
885        &self,
886        mut pdu_id: u8,
887        mut command: &[u8],
888    ) -> fidl::client::QueryResponseFut<
889        ControllerExtSendRawVendorDependentCommandResult,
890        fidl::encoding::DefaultFuchsiaResourceDialect,
891    > {
892        ControllerExtProxyInterface::r#send_raw_vendor_dependent_command(self, pdu_id, command)
893    }
894}
895
896impl ControllerExtProxyInterface for ControllerExtProxy {
897    type IsConnectedResponseFut =
898        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
899    fn r#is_connected(&self) -> Self::IsConnectedResponseFut {
900        fn _decode(
901            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
902        ) -> Result<bool, fidl::Error> {
903            let _response = fidl::client::decode_transaction_body::<
904                ControllerExtIsConnectedResponse,
905                fidl::encoding::DefaultFuchsiaResourceDialect,
906                0x403f7bc6dbbcfc4f,
907            >(_buf?)?;
908            Ok(_response.connected)
909        }
910        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
911            (),
912            0x403f7bc6dbbcfc4f,
913            fidl::encoding::DynamicFlags::empty(),
914            _decode,
915        )
916    }
917
918    type GetEventsSupportedResponseFut = fidl::client::QueryResponseFut<
919        ControllerExtGetEventsSupportedResult,
920        fidl::encoding::DefaultFuchsiaResourceDialect,
921    >;
922    fn r#get_events_supported(&self) -> Self::GetEventsSupportedResponseFut {
923        fn _decode(
924            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
925        ) -> Result<ControllerExtGetEventsSupportedResult, fidl::Error> {
926            let _response = fidl::client::decode_transaction_body::<
927                fidl::encoding::ResultType<
928                    ControllerExtGetEventsSupportedResponse,
929                    fidl_fuchsia_bluetooth_avrcp::ControllerError,
930                >,
931                fidl::encoding::DefaultFuchsiaResourceDialect,
932                0x13465d8abf04dd26,
933            >(_buf?)?;
934            Ok(_response.map(|x| x.events_supported))
935        }
936        self.client.send_query_and_decode::<
937            fidl::encoding::EmptyPayload,
938            ControllerExtGetEventsSupportedResult,
939        >(
940            (),
941            0x13465d8abf04dd26,
942            fidl::encoding::DynamicFlags::empty(),
943            _decode,
944        )
945    }
946
947    type SendRawVendorDependentCommandResponseFut = fidl::client::QueryResponseFut<
948        ControllerExtSendRawVendorDependentCommandResult,
949        fidl::encoding::DefaultFuchsiaResourceDialect,
950    >;
951    fn r#send_raw_vendor_dependent_command(
952        &self,
953        mut pdu_id: u8,
954        mut command: &[u8],
955    ) -> Self::SendRawVendorDependentCommandResponseFut {
956        fn _decode(
957            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
958        ) -> Result<ControllerExtSendRawVendorDependentCommandResult, fidl::Error> {
959            let _response = fidl::client::decode_transaction_body::<
960                fidl::encoding::ResultType<
961                    ControllerExtSendRawVendorDependentCommandResponse,
962                    fidl_fuchsia_bluetooth_avrcp::ControllerError,
963                >,
964                fidl::encoding::DefaultFuchsiaResourceDialect,
965                0x48004b651df5f606,
966            >(_buf?)?;
967            Ok(_response.map(|x| x.response))
968        }
969        self.client.send_query_and_decode::<
970            ControllerExtSendRawVendorDependentCommandRequest,
971            ControllerExtSendRawVendorDependentCommandResult,
972        >(
973            (pdu_id, command,),
974            0x48004b651df5f606,
975            fidl::encoding::DynamicFlags::empty(),
976            _decode,
977        )
978    }
979}
980
981pub struct ControllerExtEventStream {
982    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
983}
984
985impl std::marker::Unpin for ControllerExtEventStream {}
986
987impl futures::stream::FusedStream for ControllerExtEventStream {
988    fn is_terminated(&self) -> bool {
989        self.event_receiver.is_terminated()
990    }
991}
992
993impl futures::Stream for ControllerExtEventStream {
994    type Item = Result<ControllerExtEvent, fidl::Error>;
995
996    fn poll_next(
997        mut self: std::pin::Pin<&mut Self>,
998        cx: &mut std::task::Context<'_>,
999    ) -> std::task::Poll<Option<Self::Item>> {
1000        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1001            &mut self.event_receiver,
1002            cx
1003        )?) {
1004            Some(buf) => std::task::Poll::Ready(Some(ControllerExtEvent::decode(buf))),
1005            None => std::task::Poll::Ready(None),
1006        }
1007    }
1008}
1009
1010#[derive(Debug)]
1011pub enum ControllerExtEvent {}
1012
1013impl ControllerExtEvent {
1014    /// Decodes a message buffer as a [`ControllerExtEvent`].
1015    fn decode(
1016        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1017    ) -> Result<ControllerExtEvent, fidl::Error> {
1018        let (bytes, _handles) = buf.split_mut();
1019        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1020        debug_assert_eq!(tx_header.tx_id, 0);
1021        match tx_header.ordinal {
1022            _ => Err(fidl::Error::UnknownOrdinal {
1023                ordinal: tx_header.ordinal,
1024                protocol_name: <ControllerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1025            }),
1026        }
1027    }
1028}
1029
1030/// A Stream of incoming requests for fuchsia.bluetooth.avrcp.test/ControllerExt.
1031pub struct ControllerExtRequestStream {
1032    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1033    is_terminated: bool,
1034}
1035
1036impl std::marker::Unpin for ControllerExtRequestStream {}
1037
1038impl futures::stream::FusedStream for ControllerExtRequestStream {
1039    fn is_terminated(&self) -> bool {
1040        self.is_terminated
1041    }
1042}
1043
1044impl fidl::endpoints::RequestStream for ControllerExtRequestStream {
1045    type Protocol = ControllerExtMarker;
1046    type ControlHandle = ControllerExtControlHandle;
1047
1048    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1049        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1050    }
1051
1052    fn control_handle(&self) -> Self::ControlHandle {
1053        ControllerExtControlHandle { inner: self.inner.clone() }
1054    }
1055
1056    fn into_inner(
1057        self,
1058    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1059    {
1060        (self.inner, self.is_terminated)
1061    }
1062
1063    fn from_inner(
1064        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1065        is_terminated: bool,
1066    ) -> Self {
1067        Self { inner, is_terminated }
1068    }
1069}
1070
1071impl futures::Stream for ControllerExtRequestStream {
1072    type Item = Result<ControllerExtRequest, fidl::Error>;
1073
1074    fn poll_next(
1075        mut self: std::pin::Pin<&mut Self>,
1076        cx: &mut std::task::Context<'_>,
1077    ) -> std::task::Poll<Option<Self::Item>> {
1078        let this = &mut *self;
1079        if this.inner.check_shutdown(cx) {
1080            this.is_terminated = true;
1081            return std::task::Poll::Ready(None);
1082        }
1083        if this.is_terminated {
1084            panic!("polled ControllerExtRequestStream after completion");
1085        }
1086        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1087            |bytes, handles| {
1088                match this.inner.channel().read_etc(cx, bytes, handles) {
1089                    std::task::Poll::Ready(Ok(())) => {}
1090                    std::task::Poll::Pending => return std::task::Poll::Pending,
1091                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1092                        this.is_terminated = true;
1093                        return std::task::Poll::Ready(None);
1094                    }
1095                    std::task::Poll::Ready(Err(e)) => {
1096                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1097                            e.into(),
1098                        ))))
1099                    }
1100                }
1101
1102                // A message has been received from the channel
1103                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1104
1105                std::task::Poll::Ready(Some(match header.ordinal {
1106                    0x403f7bc6dbbcfc4f => {
1107                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1108                        let mut req = fidl::new_empty!(
1109                            fidl::encoding::EmptyPayload,
1110                            fidl::encoding::DefaultFuchsiaResourceDialect
1111                        );
1112                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1113                        let control_handle =
1114                            ControllerExtControlHandle { inner: this.inner.clone() };
1115                        Ok(ControllerExtRequest::IsConnected {
1116                            responder: ControllerExtIsConnectedResponder {
1117                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1118                                tx_id: header.tx_id,
1119                            },
1120                        })
1121                    }
1122                    0x13465d8abf04dd26 => {
1123                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1124                        let mut req = fidl::new_empty!(
1125                            fidl::encoding::EmptyPayload,
1126                            fidl::encoding::DefaultFuchsiaResourceDialect
1127                        );
1128                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1129                        let control_handle =
1130                            ControllerExtControlHandle { inner: this.inner.clone() };
1131                        Ok(ControllerExtRequest::GetEventsSupported {
1132                            responder: ControllerExtGetEventsSupportedResponder {
1133                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1134                                tx_id: header.tx_id,
1135                            },
1136                        })
1137                    }
1138                    0x48004b651df5f606 => {
1139                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1140                        let mut req = fidl::new_empty!(
1141                            ControllerExtSendRawVendorDependentCommandRequest,
1142                            fidl::encoding::DefaultFuchsiaResourceDialect
1143                        );
1144                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerExtSendRawVendorDependentCommandRequest>(&header, _body_bytes, handles, &mut req)?;
1145                        let control_handle =
1146                            ControllerExtControlHandle { inner: this.inner.clone() };
1147                        Ok(ControllerExtRequest::SendRawVendorDependentCommand {
1148                            pdu_id: req.pdu_id,
1149                            command: req.command,
1150
1151                            responder: ControllerExtSendRawVendorDependentCommandResponder {
1152                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1153                                tx_id: header.tx_id,
1154                            },
1155                        })
1156                    }
1157                    _ => Err(fidl::Error::UnknownOrdinal {
1158                        ordinal: header.ordinal,
1159                        protocol_name:
1160                            <ControllerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1161                    }),
1162                }))
1163            },
1164        )
1165    }
1166}
1167
1168/// Provides additional methods not in `Controller` that are strictly for testing and debug.
1169#[derive(Debug)]
1170pub enum ControllerExtRequest {
1171    /// Returns whether there is an underlying connection open with the remote device currently.
1172    IsConnected { responder: ControllerExtIsConnectedResponder },
1173    /// Queries the target and returns what events are supported for notification.
1174    /// Sends GetCapabilties(0x03 (`EVENTS_SUPPORTED`)) command for all events supported by
1175    /// the negoitated version of AVRCP.
1176    GetEventsSupported { responder: ControllerExtGetEventsSupportedResponder },
1177    /// Send raw vendor depedent "Control" command packet to a specific PDU on the remote peer.
1178    /// Returns the entire response packet including the headers or error if the remote endpoint
1179    /// disconnects or does not return a response in set amount of time.
1180    SendRawVendorDependentCommand {
1181        pdu_id: u8,
1182        command: Vec<u8>,
1183        responder: ControllerExtSendRawVendorDependentCommandResponder,
1184    },
1185}
1186
1187impl ControllerExtRequest {
1188    #[allow(irrefutable_let_patterns)]
1189    pub fn into_is_connected(self) -> Option<(ControllerExtIsConnectedResponder)> {
1190        if let ControllerExtRequest::IsConnected { responder } = self {
1191            Some((responder))
1192        } else {
1193            None
1194        }
1195    }
1196
1197    #[allow(irrefutable_let_patterns)]
1198    pub fn into_get_events_supported(self) -> Option<(ControllerExtGetEventsSupportedResponder)> {
1199        if let ControllerExtRequest::GetEventsSupported { responder } = self {
1200            Some((responder))
1201        } else {
1202            None
1203        }
1204    }
1205
1206    #[allow(irrefutable_let_patterns)]
1207    pub fn into_send_raw_vendor_dependent_command(
1208        self,
1209    ) -> Option<(u8, Vec<u8>, ControllerExtSendRawVendorDependentCommandResponder)> {
1210        if let ControllerExtRequest::SendRawVendorDependentCommand { pdu_id, command, responder } =
1211            self
1212        {
1213            Some((pdu_id, command, responder))
1214        } else {
1215            None
1216        }
1217    }
1218
1219    /// Name of the method defined in FIDL
1220    pub fn method_name(&self) -> &'static str {
1221        match *self {
1222            ControllerExtRequest::IsConnected { .. } => "is_connected",
1223            ControllerExtRequest::GetEventsSupported { .. } => "get_events_supported",
1224            ControllerExtRequest::SendRawVendorDependentCommand { .. } => {
1225                "send_raw_vendor_dependent_command"
1226            }
1227        }
1228    }
1229}
1230
1231#[derive(Debug, Clone)]
1232pub struct ControllerExtControlHandle {
1233    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1234}
1235
1236impl fidl::endpoints::ControlHandle for ControllerExtControlHandle {
1237    fn shutdown(&self) {
1238        self.inner.shutdown()
1239    }
1240    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1241        self.inner.shutdown_with_epitaph(status)
1242    }
1243
1244    fn is_closed(&self) -> bool {
1245        self.inner.channel().is_closed()
1246    }
1247    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1248        self.inner.channel().on_closed()
1249    }
1250
1251    #[cfg(target_os = "fuchsia")]
1252    fn signal_peer(
1253        &self,
1254        clear_mask: zx::Signals,
1255        set_mask: zx::Signals,
1256    ) -> Result<(), zx_status::Status> {
1257        use fidl::Peered;
1258        self.inner.channel().signal_peer(clear_mask, set_mask)
1259    }
1260}
1261
1262impl ControllerExtControlHandle {}
1263
1264#[must_use = "FIDL methods require a response to be sent"]
1265#[derive(Debug)]
1266pub struct ControllerExtIsConnectedResponder {
1267    control_handle: std::mem::ManuallyDrop<ControllerExtControlHandle>,
1268    tx_id: u32,
1269}
1270
1271/// Set the the channel to be shutdown (see [`ControllerExtControlHandle::shutdown`])
1272/// if the responder is dropped without sending a response, so that the client
1273/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1274impl std::ops::Drop for ControllerExtIsConnectedResponder {
1275    fn drop(&mut self) {
1276        self.control_handle.shutdown();
1277        // Safety: drops once, never accessed again
1278        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1279    }
1280}
1281
1282impl fidl::endpoints::Responder for ControllerExtIsConnectedResponder {
1283    type ControlHandle = ControllerExtControlHandle;
1284
1285    fn control_handle(&self) -> &ControllerExtControlHandle {
1286        &self.control_handle
1287    }
1288
1289    fn drop_without_shutdown(mut self) {
1290        // Safety: drops once, never accessed again due to mem::forget
1291        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1292        // Prevent Drop from running (which would shut down the channel)
1293        std::mem::forget(self);
1294    }
1295}
1296
1297impl ControllerExtIsConnectedResponder {
1298    /// Sends a response to the FIDL transaction.
1299    ///
1300    /// Sets the channel to shutdown if an error occurs.
1301    pub fn send(self, mut connected: bool) -> Result<(), fidl::Error> {
1302        let _result = self.send_raw(connected);
1303        if _result.is_err() {
1304            self.control_handle.shutdown();
1305        }
1306        self.drop_without_shutdown();
1307        _result
1308    }
1309
1310    /// Similar to "send" but does not shutdown the channel if an error occurs.
1311    pub fn send_no_shutdown_on_err(self, mut connected: bool) -> Result<(), fidl::Error> {
1312        let _result = self.send_raw(connected);
1313        self.drop_without_shutdown();
1314        _result
1315    }
1316
1317    fn send_raw(&self, mut connected: bool) -> Result<(), fidl::Error> {
1318        self.control_handle.inner.send::<ControllerExtIsConnectedResponse>(
1319            (connected,),
1320            self.tx_id,
1321            0x403f7bc6dbbcfc4f,
1322            fidl::encoding::DynamicFlags::empty(),
1323        )
1324    }
1325}
1326
1327#[must_use = "FIDL methods require a response to be sent"]
1328#[derive(Debug)]
1329pub struct ControllerExtGetEventsSupportedResponder {
1330    control_handle: std::mem::ManuallyDrop<ControllerExtControlHandle>,
1331    tx_id: u32,
1332}
1333
1334/// Set the the channel to be shutdown (see [`ControllerExtControlHandle::shutdown`])
1335/// if the responder is dropped without sending a response, so that the client
1336/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1337impl std::ops::Drop for ControllerExtGetEventsSupportedResponder {
1338    fn drop(&mut self) {
1339        self.control_handle.shutdown();
1340        // Safety: drops once, never accessed again
1341        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1342    }
1343}
1344
1345impl fidl::endpoints::Responder for ControllerExtGetEventsSupportedResponder {
1346    type ControlHandle = ControllerExtControlHandle;
1347
1348    fn control_handle(&self) -> &ControllerExtControlHandle {
1349        &self.control_handle
1350    }
1351
1352    fn drop_without_shutdown(mut self) {
1353        // Safety: drops once, never accessed again due to mem::forget
1354        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1355        // Prevent Drop from running (which would shut down the channel)
1356        std::mem::forget(self);
1357    }
1358}
1359
1360impl ControllerExtGetEventsSupportedResponder {
1361    /// Sends a response to the FIDL transaction.
1362    ///
1363    /// Sets the channel to shutdown if an error occurs.
1364    pub fn send(
1365        self,
1366        mut result: Result<
1367            &[fidl_fuchsia_bluetooth_avrcp::NotificationEvent],
1368            fidl_fuchsia_bluetooth_avrcp::ControllerError,
1369        >,
1370    ) -> Result<(), fidl::Error> {
1371        let _result = self.send_raw(result);
1372        if _result.is_err() {
1373            self.control_handle.shutdown();
1374        }
1375        self.drop_without_shutdown();
1376        _result
1377    }
1378
1379    /// Similar to "send" but does not shutdown the channel if an error occurs.
1380    pub fn send_no_shutdown_on_err(
1381        self,
1382        mut result: Result<
1383            &[fidl_fuchsia_bluetooth_avrcp::NotificationEvent],
1384            fidl_fuchsia_bluetooth_avrcp::ControllerError,
1385        >,
1386    ) -> Result<(), fidl::Error> {
1387        let _result = self.send_raw(result);
1388        self.drop_without_shutdown();
1389        _result
1390    }
1391
1392    fn send_raw(
1393        &self,
1394        mut result: Result<
1395            &[fidl_fuchsia_bluetooth_avrcp::NotificationEvent],
1396            fidl_fuchsia_bluetooth_avrcp::ControllerError,
1397        >,
1398    ) -> Result<(), fidl::Error> {
1399        self.control_handle.inner.send::<fidl::encoding::ResultType<
1400            ControllerExtGetEventsSupportedResponse,
1401            fidl_fuchsia_bluetooth_avrcp::ControllerError,
1402        >>(
1403            result.map(|events_supported| (events_supported,)),
1404            self.tx_id,
1405            0x13465d8abf04dd26,
1406            fidl::encoding::DynamicFlags::empty(),
1407        )
1408    }
1409}
1410
1411#[must_use = "FIDL methods require a response to be sent"]
1412#[derive(Debug)]
1413pub struct ControllerExtSendRawVendorDependentCommandResponder {
1414    control_handle: std::mem::ManuallyDrop<ControllerExtControlHandle>,
1415    tx_id: u32,
1416}
1417
1418/// Set the the channel to be shutdown (see [`ControllerExtControlHandle::shutdown`])
1419/// if the responder is dropped without sending a response, so that the client
1420/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1421impl std::ops::Drop for ControllerExtSendRawVendorDependentCommandResponder {
1422    fn drop(&mut self) {
1423        self.control_handle.shutdown();
1424        // Safety: drops once, never accessed again
1425        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1426    }
1427}
1428
1429impl fidl::endpoints::Responder for ControllerExtSendRawVendorDependentCommandResponder {
1430    type ControlHandle = ControllerExtControlHandle;
1431
1432    fn control_handle(&self) -> &ControllerExtControlHandle {
1433        &self.control_handle
1434    }
1435
1436    fn drop_without_shutdown(mut self) {
1437        // Safety: drops once, never accessed again due to mem::forget
1438        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1439        // Prevent Drop from running (which would shut down the channel)
1440        std::mem::forget(self);
1441    }
1442}
1443
1444impl ControllerExtSendRawVendorDependentCommandResponder {
1445    /// Sends a response to the FIDL transaction.
1446    ///
1447    /// Sets the channel to shutdown if an error occurs.
1448    pub fn send(
1449        self,
1450        mut result: Result<&[u8], fidl_fuchsia_bluetooth_avrcp::ControllerError>,
1451    ) -> Result<(), fidl::Error> {
1452        let _result = self.send_raw(result);
1453        if _result.is_err() {
1454            self.control_handle.shutdown();
1455        }
1456        self.drop_without_shutdown();
1457        _result
1458    }
1459
1460    /// Similar to "send" but does not shutdown the channel if an error occurs.
1461    pub fn send_no_shutdown_on_err(
1462        self,
1463        mut result: Result<&[u8], fidl_fuchsia_bluetooth_avrcp::ControllerError>,
1464    ) -> Result<(), fidl::Error> {
1465        let _result = self.send_raw(result);
1466        self.drop_without_shutdown();
1467        _result
1468    }
1469
1470    fn send_raw(
1471        &self,
1472        mut result: Result<&[u8], fidl_fuchsia_bluetooth_avrcp::ControllerError>,
1473    ) -> Result<(), fidl::Error> {
1474        self.control_handle.inner.send::<fidl::encoding::ResultType<
1475            ControllerExtSendRawVendorDependentCommandResponse,
1476            fidl_fuchsia_bluetooth_avrcp::ControllerError,
1477        >>(
1478            result.map(|response| (response,)),
1479            self.tx_id,
1480            0x48004b651df5f606,
1481            fidl::encoding::DynamicFlags::empty(),
1482        )
1483    }
1484}
1485
1486#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1487pub struct PeerManagerExtMarker;
1488
1489impl fidl::endpoints::ProtocolMarker for PeerManagerExtMarker {
1490    type Proxy = PeerManagerExtProxy;
1491    type RequestStream = PeerManagerExtRequestStream;
1492    #[cfg(target_os = "fuchsia")]
1493    type SynchronousProxy = PeerManagerExtSynchronousProxy;
1494
1495    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.avrcp.test.PeerManagerExt";
1496}
1497impl fidl::endpoints::DiscoverableProtocolMarker for PeerManagerExtMarker {}
1498pub type PeerManagerExtGetBrowseControllerForTargetResult = Result<(), i32>;
1499pub type PeerManagerExtGetControllerForTargetResult = Result<(), i32>;
1500
1501pub trait PeerManagerExtProxyInterface: Send + Sync {
1502    type GetBrowseControllerForTargetResponseFut: std::future::Future<
1503            Output = Result<PeerManagerExtGetBrowseControllerForTargetResult, fidl::Error>,
1504        > + Send;
1505    fn r#get_browse_controller_for_target(
1506        &self,
1507        peer_id: &fidl_fuchsia_bluetooth::PeerId,
1508        client: fidl::endpoints::ServerEnd<BrowseControllerExtMarker>,
1509    ) -> Self::GetBrowseControllerForTargetResponseFut;
1510    type GetControllerForTargetResponseFut: std::future::Future<
1511            Output = Result<PeerManagerExtGetControllerForTargetResult, fidl::Error>,
1512        > + Send;
1513    fn r#get_controller_for_target(
1514        &self,
1515        peer_id: &fidl_fuchsia_bluetooth::PeerId,
1516        client: fidl::endpoints::ServerEnd<ControllerExtMarker>,
1517    ) -> Self::GetControllerForTargetResponseFut;
1518}
1519#[derive(Debug)]
1520#[cfg(target_os = "fuchsia")]
1521pub struct PeerManagerExtSynchronousProxy {
1522    client: fidl::client::sync::Client,
1523}
1524
1525#[cfg(target_os = "fuchsia")]
1526impl fidl::endpoints::SynchronousProxy for PeerManagerExtSynchronousProxy {
1527    type Proxy = PeerManagerExtProxy;
1528    type Protocol = PeerManagerExtMarker;
1529
1530    fn from_channel(inner: fidl::Channel) -> Self {
1531        Self::new(inner)
1532    }
1533
1534    fn into_channel(self) -> fidl::Channel {
1535        self.client.into_channel()
1536    }
1537
1538    fn as_channel(&self) -> &fidl::Channel {
1539        self.client.as_channel()
1540    }
1541}
1542
1543#[cfg(target_os = "fuchsia")]
1544impl PeerManagerExtSynchronousProxy {
1545    pub fn new(channel: fidl::Channel) -> Self {
1546        let protocol_name = <PeerManagerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1547        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1548    }
1549
1550    pub fn into_channel(self) -> fidl::Channel {
1551        self.client.into_channel()
1552    }
1553
1554    /// Waits until an event arrives and returns it. It is safe for other
1555    /// threads to make concurrent requests while waiting for an event.
1556    pub fn wait_for_event(
1557        &self,
1558        deadline: zx::MonotonicInstant,
1559    ) -> Result<PeerManagerExtEvent, fidl::Error> {
1560        PeerManagerExtEvent::decode(self.client.wait_for_event(deadline)?)
1561    }
1562
1563    /// Returns a test browse controller client to a remote target service at
1564    /// the peer specified by `peer_id`. This client is to be used alongside the
1565    /// primary browse controller client.
1566    pub fn r#get_browse_controller_for_target(
1567        &self,
1568        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1569        mut client: fidl::endpoints::ServerEnd<BrowseControllerExtMarker>,
1570        ___deadline: zx::MonotonicInstant,
1571    ) -> Result<PeerManagerExtGetBrowseControllerForTargetResult, fidl::Error> {
1572        let _response = self.client.send_query::<
1573            PeerManagerExtGetBrowseControllerForTargetRequest,
1574            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1575        >(
1576            (peer_id, client,),
1577            0x3b838b67d5a5aeac,
1578            fidl::encoding::DynamicFlags::empty(),
1579            ___deadline,
1580        )?;
1581        Ok(_response.map(|x| x))
1582    }
1583
1584    /// Returns a test controller client to a remote target service at the
1585    /// peer specified by `peer_id`. This client is to be used alongside the
1586    /// primary controller client.
1587    pub fn r#get_controller_for_target(
1588        &self,
1589        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1590        mut client: fidl::endpoints::ServerEnd<ControllerExtMarker>,
1591        ___deadline: zx::MonotonicInstant,
1592    ) -> Result<PeerManagerExtGetControllerForTargetResult, fidl::Error> {
1593        let _response = self.client.send_query::<
1594            PeerManagerExtGetControllerForTargetRequest,
1595            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1596        >(
1597            (peer_id, client,),
1598            0x39448b0c65966553,
1599            fidl::encoding::DynamicFlags::empty(),
1600            ___deadline,
1601        )?;
1602        Ok(_response.map(|x| x))
1603    }
1604}
1605
1606#[cfg(target_os = "fuchsia")]
1607impl From<PeerManagerExtSynchronousProxy> for zx::Handle {
1608    fn from(value: PeerManagerExtSynchronousProxy) -> Self {
1609        value.into_channel().into()
1610    }
1611}
1612
1613#[cfg(target_os = "fuchsia")]
1614impl From<fidl::Channel> for PeerManagerExtSynchronousProxy {
1615    fn from(value: fidl::Channel) -> Self {
1616        Self::new(value)
1617    }
1618}
1619
1620#[cfg(target_os = "fuchsia")]
1621impl fidl::endpoints::FromClient for PeerManagerExtSynchronousProxy {
1622    type Protocol = PeerManagerExtMarker;
1623
1624    fn from_client(value: fidl::endpoints::ClientEnd<PeerManagerExtMarker>) -> Self {
1625        Self::new(value.into_channel())
1626    }
1627}
1628
1629#[derive(Debug, Clone)]
1630pub struct PeerManagerExtProxy {
1631    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1632}
1633
1634impl fidl::endpoints::Proxy for PeerManagerExtProxy {
1635    type Protocol = PeerManagerExtMarker;
1636
1637    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1638        Self::new(inner)
1639    }
1640
1641    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1642        self.client.into_channel().map_err(|client| Self { client })
1643    }
1644
1645    fn as_channel(&self) -> &::fidl::AsyncChannel {
1646        self.client.as_channel()
1647    }
1648}
1649
1650impl PeerManagerExtProxy {
1651    /// Create a new Proxy for fuchsia.bluetooth.avrcp.test/PeerManagerExt.
1652    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1653        let protocol_name = <PeerManagerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1654        Self { client: fidl::client::Client::new(channel, protocol_name) }
1655    }
1656
1657    /// Get a Stream of events from the remote end of the protocol.
1658    ///
1659    /// # Panics
1660    ///
1661    /// Panics if the event stream was already taken.
1662    pub fn take_event_stream(&self) -> PeerManagerExtEventStream {
1663        PeerManagerExtEventStream { event_receiver: self.client.take_event_receiver() }
1664    }
1665
1666    /// Returns a test browse controller client to a remote target service at
1667    /// the peer specified by `peer_id`. This client is to be used alongside the
1668    /// primary browse controller client.
1669    pub fn r#get_browse_controller_for_target(
1670        &self,
1671        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1672        mut client: fidl::endpoints::ServerEnd<BrowseControllerExtMarker>,
1673    ) -> fidl::client::QueryResponseFut<
1674        PeerManagerExtGetBrowseControllerForTargetResult,
1675        fidl::encoding::DefaultFuchsiaResourceDialect,
1676    > {
1677        PeerManagerExtProxyInterface::r#get_browse_controller_for_target(self, peer_id, client)
1678    }
1679
1680    /// Returns a test controller client to a remote target service at the
1681    /// peer specified by `peer_id`. This client is to be used alongside the
1682    /// primary controller client.
1683    pub fn r#get_controller_for_target(
1684        &self,
1685        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1686        mut client: fidl::endpoints::ServerEnd<ControllerExtMarker>,
1687    ) -> fidl::client::QueryResponseFut<
1688        PeerManagerExtGetControllerForTargetResult,
1689        fidl::encoding::DefaultFuchsiaResourceDialect,
1690    > {
1691        PeerManagerExtProxyInterface::r#get_controller_for_target(self, peer_id, client)
1692    }
1693}
1694
1695impl PeerManagerExtProxyInterface for PeerManagerExtProxy {
1696    type GetBrowseControllerForTargetResponseFut = fidl::client::QueryResponseFut<
1697        PeerManagerExtGetBrowseControllerForTargetResult,
1698        fidl::encoding::DefaultFuchsiaResourceDialect,
1699    >;
1700    fn r#get_browse_controller_for_target(
1701        &self,
1702        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1703        mut client: fidl::endpoints::ServerEnd<BrowseControllerExtMarker>,
1704    ) -> Self::GetBrowseControllerForTargetResponseFut {
1705        fn _decode(
1706            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1707        ) -> Result<PeerManagerExtGetBrowseControllerForTargetResult, fidl::Error> {
1708            let _response = fidl::client::decode_transaction_body::<
1709                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1710                fidl::encoding::DefaultFuchsiaResourceDialect,
1711                0x3b838b67d5a5aeac,
1712            >(_buf?)?;
1713            Ok(_response.map(|x| x))
1714        }
1715        self.client.send_query_and_decode::<
1716            PeerManagerExtGetBrowseControllerForTargetRequest,
1717            PeerManagerExtGetBrowseControllerForTargetResult,
1718        >(
1719            (peer_id, client,),
1720            0x3b838b67d5a5aeac,
1721            fidl::encoding::DynamicFlags::empty(),
1722            _decode,
1723        )
1724    }
1725
1726    type GetControllerForTargetResponseFut = fidl::client::QueryResponseFut<
1727        PeerManagerExtGetControllerForTargetResult,
1728        fidl::encoding::DefaultFuchsiaResourceDialect,
1729    >;
1730    fn r#get_controller_for_target(
1731        &self,
1732        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1733        mut client: fidl::endpoints::ServerEnd<ControllerExtMarker>,
1734    ) -> Self::GetControllerForTargetResponseFut {
1735        fn _decode(
1736            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1737        ) -> Result<PeerManagerExtGetControllerForTargetResult, fidl::Error> {
1738            let _response = fidl::client::decode_transaction_body::<
1739                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1740                fidl::encoding::DefaultFuchsiaResourceDialect,
1741                0x39448b0c65966553,
1742            >(_buf?)?;
1743            Ok(_response.map(|x| x))
1744        }
1745        self.client.send_query_and_decode::<
1746            PeerManagerExtGetControllerForTargetRequest,
1747            PeerManagerExtGetControllerForTargetResult,
1748        >(
1749            (peer_id, client,),
1750            0x39448b0c65966553,
1751            fidl::encoding::DynamicFlags::empty(),
1752            _decode,
1753        )
1754    }
1755}
1756
1757pub struct PeerManagerExtEventStream {
1758    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1759}
1760
1761impl std::marker::Unpin for PeerManagerExtEventStream {}
1762
1763impl futures::stream::FusedStream for PeerManagerExtEventStream {
1764    fn is_terminated(&self) -> bool {
1765        self.event_receiver.is_terminated()
1766    }
1767}
1768
1769impl futures::Stream for PeerManagerExtEventStream {
1770    type Item = Result<PeerManagerExtEvent, fidl::Error>;
1771
1772    fn poll_next(
1773        mut self: std::pin::Pin<&mut Self>,
1774        cx: &mut std::task::Context<'_>,
1775    ) -> std::task::Poll<Option<Self::Item>> {
1776        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1777            &mut self.event_receiver,
1778            cx
1779        )?) {
1780            Some(buf) => std::task::Poll::Ready(Some(PeerManagerExtEvent::decode(buf))),
1781            None => std::task::Poll::Ready(None),
1782        }
1783    }
1784}
1785
1786#[derive(Debug)]
1787pub enum PeerManagerExtEvent {}
1788
1789impl PeerManagerExtEvent {
1790    /// Decodes a message buffer as a [`PeerManagerExtEvent`].
1791    fn decode(
1792        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1793    ) -> Result<PeerManagerExtEvent, fidl::Error> {
1794        let (bytes, _handles) = buf.split_mut();
1795        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1796        debug_assert_eq!(tx_header.tx_id, 0);
1797        match tx_header.ordinal {
1798            _ => Err(fidl::Error::UnknownOrdinal {
1799                ordinal: tx_header.ordinal,
1800                protocol_name:
1801                    <PeerManagerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1802            }),
1803        }
1804    }
1805}
1806
1807/// A Stream of incoming requests for fuchsia.bluetooth.avrcp.test/PeerManagerExt.
1808pub struct PeerManagerExtRequestStream {
1809    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1810    is_terminated: bool,
1811}
1812
1813impl std::marker::Unpin for PeerManagerExtRequestStream {}
1814
1815impl futures::stream::FusedStream for PeerManagerExtRequestStream {
1816    fn is_terminated(&self) -> bool {
1817        self.is_terminated
1818    }
1819}
1820
1821impl fidl::endpoints::RequestStream for PeerManagerExtRequestStream {
1822    type Protocol = PeerManagerExtMarker;
1823    type ControlHandle = PeerManagerExtControlHandle;
1824
1825    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1826        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1827    }
1828
1829    fn control_handle(&self) -> Self::ControlHandle {
1830        PeerManagerExtControlHandle { inner: self.inner.clone() }
1831    }
1832
1833    fn into_inner(
1834        self,
1835    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1836    {
1837        (self.inner, self.is_terminated)
1838    }
1839
1840    fn from_inner(
1841        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1842        is_terminated: bool,
1843    ) -> Self {
1844        Self { inner, is_terminated }
1845    }
1846}
1847
1848impl futures::Stream for PeerManagerExtRequestStream {
1849    type Item = Result<PeerManagerExtRequest, fidl::Error>;
1850
1851    fn poll_next(
1852        mut self: std::pin::Pin<&mut Self>,
1853        cx: &mut std::task::Context<'_>,
1854    ) -> std::task::Poll<Option<Self::Item>> {
1855        let this = &mut *self;
1856        if this.inner.check_shutdown(cx) {
1857            this.is_terminated = true;
1858            return std::task::Poll::Ready(None);
1859        }
1860        if this.is_terminated {
1861            panic!("polled PeerManagerExtRequestStream after completion");
1862        }
1863        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1864            |bytes, handles| {
1865                match this.inner.channel().read_etc(cx, bytes, handles) {
1866                    std::task::Poll::Ready(Ok(())) => {}
1867                    std::task::Poll::Pending => return std::task::Poll::Pending,
1868                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1869                        this.is_terminated = true;
1870                        return std::task::Poll::Ready(None);
1871                    }
1872                    std::task::Poll::Ready(Err(e)) => {
1873                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1874                            e.into(),
1875                        ))))
1876                    }
1877                }
1878
1879                // A message has been received from the channel
1880                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1881
1882                std::task::Poll::Ready(Some(match header.ordinal {
1883                    0x3b838b67d5a5aeac => {
1884                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1885                        let mut req = fidl::new_empty!(
1886                            PeerManagerExtGetBrowseControllerForTargetRequest,
1887                            fidl::encoding::DefaultFuchsiaResourceDialect
1888                        );
1889                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerManagerExtGetBrowseControllerForTargetRequest>(&header, _body_bytes, handles, &mut req)?;
1890                        let control_handle =
1891                            PeerManagerExtControlHandle { inner: this.inner.clone() };
1892                        Ok(PeerManagerExtRequest::GetBrowseControllerForTarget {
1893                            peer_id: req.peer_id,
1894                            client: req.client,
1895
1896                            responder: PeerManagerExtGetBrowseControllerForTargetResponder {
1897                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1898                                tx_id: header.tx_id,
1899                            },
1900                        })
1901                    }
1902                    0x39448b0c65966553 => {
1903                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1904                        let mut req = fidl::new_empty!(
1905                            PeerManagerExtGetControllerForTargetRequest,
1906                            fidl::encoding::DefaultFuchsiaResourceDialect
1907                        );
1908                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerManagerExtGetControllerForTargetRequest>(&header, _body_bytes, handles, &mut req)?;
1909                        let control_handle =
1910                            PeerManagerExtControlHandle { inner: this.inner.clone() };
1911                        Ok(PeerManagerExtRequest::GetControllerForTarget {
1912                            peer_id: req.peer_id,
1913                            client: req.client,
1914
1915                            responder: PeerManagerExtGetControllerForTargetResponder {
1916                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1917                                tx_id: header.tx_id,
1918                            },
1919                        })
1920                    }
1921                    _ => Err(fidl::Error::UnknownOrdinal {
1922                        ordinal: header.ordinal,
1923                        protocol_name:
1924                            <PeerManagerExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1925                    }),
1926                }))
1927            },
1928        )
1929    }
1930}
1931
1932/// NOTE: The test controller protocols returned by the
1933/// `Get{Browse|}ControllerForTarget` methods provide additional methods not
1934/// exposed by primary controller protocol that are designed to be used
1935/// for PTS qualification testing and debugging purposes only.
1936/// WARNING: This test controller protocol client can cause breaking
1937/// side-effects for other controller clients connected to this the same peer.
1938/// Use with caution and avoid having additional primary controller
1939/// clients interacting with the same remote peer while using the test
1940/// controller.
1941#[derive(Debug)]
1942pub enum PeerManagerExtRequest {
1943    /// Returns a test browse controller client to a remote target service at
1944    /// the peer specified by `peer_id`. This client is to be used alongside the
1945    /// primary browse controller client.
1946    GetBrowseControllerForTarget {
1947        peer_id: fidl_fuchsia_bluetooth::PeerId,
1948        client: fidl::endpoints::ServerEnd<BrowseControllerExtMarker>,
1949        responder: PeerManagerExtGetBrowseControllerForTargetResponder,
1950    },
1951    /// Returns a test controller client to a remote target service at the
1952    /// peer specified by `peer_id`. This client is to be used alongside the
1953    /// primary controller client.
1954    GetControllerForTarget {
1955        peer_id: fidl_fuchsia_bluetooth::PeerId,
1956        client: fidl::endpoints::ServerEnd<ControllerExtMarker>,
1957        responder: PeerManagerExtGetControllerForTargetResponder,
1958    },
1959}
1960
1961impl PeerManagerExtRequest {
1962    #[allow(irrefutable_let_patterns)]
1963    pub fn into_get_browse_controller_for_target(
1964        self,
1965    ) -> Option<(
1966        fidl_fuchsia_bluetooth::PeerId,
1967        fidl::endpoints::ServerEnd<BrowseControllerExtMarker>,
1968        PeerManagerExtGetBrowseControllerForTargetResponder,
1969    )> {
1970        if let PeerManagerExtRequest::GetBrowseControllerForTarget { peer_id, client, responder } =
1971            self
1972        {
1973            Some((peer_id, client, responder))
1974        } else {
1975            None
1976        }
1977    }
1978
1979    #[allow(irrefutable_let_patterns)]
1980    pub fn into_get_controller_for_target(
1981        self,
1982    ) -> Option<(
1983        fidl_fuchsia_bluetooth::PeerId,
1984        fidl::endpoints::ServerEnd<ControllerExtMarker>,
1985        PeerManagerExtGetControllerForTargetResponder,
1986    )> {
1987        if let PeerManagerExtRequest::GetControllerForTarget { peer_id, client, responder } = self {
1988            Some((peer_id, client, responder))
1989        } else {
1990            None
1991        }
1992    }
1993
1994    /// Name of the method defined in FIDL
1995    pub fn method_name(&self) -> &'static str {
1996        match *self {
1997            PeerManagerExtRequest::GetBrowseControllerForTarget { .. } => {
1998                "get_browse_controller_for_target"
1999            }
2000            PeerManagerExtRequest::GetControllerForTarget { .. } => "get_controller_for_target",
2001        }
2002    }
2003}
2004
2005#[derive(Debug, Clone)]
2006pub struct PeerManagerExtControlHandle {
2007    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2008}
2009
2010impl fidl::endpoints::ControlHandle for PeerManagerExtControlHandle {
2011    fn shutdown(&self) {
2012        self.inner.shutdown()
2013    }
2014    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2015        self.inner.shutdown_with_epitaph(status)
2016    }
2017
2018    fn is_closed(&self) -> bool {
2019        self.inner.channel().is_closed()
2020    }
2021    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2022        self.inner.channel().on_closed()
2023    }
2024
2025    #[cfg(target_os = "fuchsia")]
2026    fn signal_peer(
2027        &self,
2028        clear_mask: zx::Signals,
2029        set_mask: zx::Signals,
2030    ) -> Result<(), zx_status::Status> {
2031        use fidl::Peered;
2032        self.inner.channel().signal_peer(clear_mask, set_mask)
2033    }
2034}
2035
2036impl PeerManagerExtControlHandle {}
2037
2038#[must_use = "FIDL methods require a response to be sent"]
2039#[derive(Debug)]
2040pub struct PeerManagerExtGetBrowseControllerForTargetResponder {
2041    control_handle: std::mem::ManuallyDrop<PeerManagerExtControlHandle>,
2042    tx_id: u32,
2043}
2044
2045/// Set the the channel to be shutdown (see [`PeerManagerExtControlHandle::shutdown`])
2046/// if the responder is dropped without sending a response, so that the client
2047/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2048impl std::ops::Drop for PeerManagerExtGetBrowseControllerForTargetResponder {
2049    fn drop(&mut self) {
2050        self.control_handle.shutdown();
2051        // Safety: drops once, never accessed again
2052        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2053    }
2054}
2055
2056impl fidl::endpoints::Responder for PeerManagerExtGetBrowseControllerForTargetResponder {
2057    type ControlHandle = PeerManagerExtControlHandle;
2058
2059    fn control_handle(&self) -> &PeerManagerExtControlHandle {
2060        &self.control_handle
2061    }
2062
2063    fn drop_without_shutdown(mut self) {
2064        // Safety: drops once, never accessed again due to mem::forget
2065        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2066        // Prevent Drop from running (which would shut down the channel)
2067        std::mem::forget(self);
2068    }
2069}
2070
2071impl PeerManagerExtGetBrowseControllerForTargetResponder {
2072    /// Sends a response to the FIDL transaction.
2073    ///
2074    /// Sets the channel to shutdown if an error occurs.
2075    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2076        let _result = self.send_raw(result);
2077        if _result.is_err() {
2078            self.control_handle.shutdown();
2079        }
2080        self.drop_without_shutdown();
2081        _result
2082    }
2083
2084    /// Similar to "send" but does not shutdown the channel if an error occurs.
2085    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2086        let _result = self.send_raw(result);
2087        self.drop_without_shutdown();
2088        _result
2089    }
2090
2091    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2092        self.control_handle
2093            .inner
2094            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2095                result,
2096                self.tx_id,
2097                0x3b838b67d5a5aeac,
2098                fidl::encoding::DynamicFlags::empty(),
2099            )
2100    }
2101}
2102
2103#[must_use = "FIDL methods require a response to be sent"]
2104#[derive(Debug)]
2105pub struct PeerManagerExtGetControllerForTargetResponder {
2106    control_handle: std::mem::ManuallyDrop<PeerManagerExtControlHandle>,
2107    tx_id: u32,
2108}
2109
2110/// Set the the channel to be shutdown (see [`PeerManagerExtControlHandle::shutdown`])
2111/// if the responder is dropped without sending a response, so that the client
2112/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2113impl std::ops::Drop for PeerManagerExtGetControllerForTargetResponder {
2114    fn drop(&mut self) {
2115        self.control_handle.shutdown();
2116        // Safety: drops once, never accessed again
2117        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2118    }
2119}
2120
2121impl fidl::endpoints::Responder for PeerManagerExtGetControllerForTargetResponder {
2122    type ControlHandle = PeerManagerExtControlHandle;
2123
2124    fn control_handle(&self) -> &PeerManagerExtControlHandle {
2125        &self.control_handle
2126    }
2127
2128    fn drop_without_shutdown(mut self) {
2129        // Safety: drops once, never accessed again due to mem::forget
2130        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2131        // Prevent Drop from running (which would shut down the channel)
2132        std::mem::forget(self);
2133    }
2134}
2135
2136impl PeerManagerExtGetControllerForTargetResponder {
2137    /// Sends a response to the FIDL transaction.
2138    ///
2139    /// Sets the channel to shutdown if an error occurs.
2140    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2141        let _result = self.send_raw(result);
2142        if _result.is_err() {
2143            self.control_handle.shutdown();
2144        }
2145        self.drop_without_shutdown();
2146        _result
2147    }
2148
2149    /// Similar to "send" but does not shutdown the channel if an error occurs.
2150    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2151        let _result = self.send_raw(result);
2152        self.drop_without_shutdown();
2153        _result
2154    }
2155
2156    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2157        self.control_handle
2158            .inner
2159            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2160                result,
2161                self.tx_id,
2162                0x39448b0c65966553,
2163                fidl::encoding::DynamicFlags::empty(),
2164            )
2165    }
2166}
2167
2168mod internal {
2169    use super::*;
2170
2171    impl fidl::encoding::ResourceTypeMarker for PeerManagerExtGetBrowseControllerForTargetRequest {
2172        type Borrowed<'a> = &'a mut Self;
2173        fn take_or_borrow<'a>(
2174            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2175        ) -> Self::Borrowed<'a> {
2176            value
2177        }
2178    }
2179
2180    unsafe impl fidl::encoding::TypeMarker for PeerManagerExtGetBrowseControllerForTargetRequest {
2181        type Owned = Self;
2182
2183        #[inline(always)]
2184        fn inline_align(_context: fidl::encoding::Context) -> usize {
2185            8
2186        }
2187
2188        #[inline(always)]
2189        fn inline_size(_context: fidl::encoding::Context) -> usize {
2190            16
2191        }
2192    }
2193
2194    unsafe impl
2195        fidl::encoding::Encode<
2196            PeerManagerExtGetBrowseControllerForTargetRequest,
2197            fidl::encoding::DefaultFuchsiaResourceDialect,
2198        > for &mut PeerManagerExtGetBrowseControllerForTargetRequest
2199    {
2200        #[inline]
2201        unsafe fn encode(
2202            self,
2203            encoder: &mut fidl::encoding::Encoder<
2204                '_,
2205                fidl::encoding::DefaultFuchsiaResourceDialect,
2206            >,
2207            offset: usize,
2208            _depth: fidl::encoding::Depth,
2209        ) -> fidl::Result<()> {
2210            encoder.debug_check_bounds::<PeerManagerExtGetBrowseControllerForTargetRequest>(offset);
2211            // Delegate to tuple encoding.
2212            fidl::encoding::Encode::<PeerManagerExtGetBrowseControllerForTargetRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2213                (
2214                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.peer_id),
2215                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BrowseControllerExtMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.client),
2216                ),
2217                encoder, offset, _depth
2218            )
2219        }
2220    }
2221    unsafe impl<
2222            T0: fidl::encoding::Encode<
2223                fidl_fuchsia_bluetooth::PeerId,
2224                fidl::encoding::DefaultFuchsiaResourceDialect,
2225            >,
2226            T1: fidl::encoding::Encode<
2227                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BrowseControllerExtMarker>>,
2228                fidl::encoding::DefaultFuchsiaResourceDialect,
2229            >,
2230        >
2231        fidl::encoding::Encode<
2232            PeerManagerExtGetBrowseControllerForTargetRequest,
2233            fidl::encoding::DefaultFuchsiaResourceDialect,
2234        > for (T0, T1)
2235    {
2236        #[inline]
2237        unsafe fn encode(
2238            self,
2239            encoder: &mut fidl::encoding::Encoder<
2240                '_,
2241                fidl::encoding::DefaultFuchsiaResourceDialect,
2242            >,
2243            offset: usize,
2244            depth: fidl::encoding::Depth,
2245        ) -> fidl::Result<()> {
2246            encoder.debug_check_bounds::<PeerManagerExtGetBrowseControllerForTargetRequest>(offset);
2247            // Zero out padding regions. There's no need to apply masks
2248            // because the unmasked parts will be overwritten by fields.
2249            unsafe {
2250                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
2251                (ptr as *mut u64).write_unaligned(0);
2252            }
2253            // Write the fields.
2254            self.0.encode(encoder, offset + 0, depth)?;
2255            self.1.encode(encoder, offset + 8, depth)?;
2256            Ok(())
2257        }
2258    }
2259
2260    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2261        for PeerManagerExtGetBrowseControllerForTargetRequest
2262    {
2263        #[inline(always)]
2264        fn new_empty() -> Self {
2265            Self {
2266                peer_id: fidl::new_empty!(
2267                    fidl_fuchsia_bluetooth::PeerId,
2268                    fidl::encoding::DefaultFuchsiaResourceDialect
2269                ),
2270                client: fidl::new_empty!(
2271                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BrowseControllerExtMarker>>,
2272                    fidl::encoding::DefaultFuchsiaResourceDialect
2273                ),
2274            }
2275        }
2276
2277        #[inline]
2278        unsafe fn decode(
2279            &mut self,
2280            decoder: &mut fidl::encoding::Decoder<
2281                '_,
2282                fidl::encoding::DefaultFuchsiaResourceDialect,
2283            >,
2284            offset: usize,
2285            _depth: fidl::encoding::Depth,
2286        ) -> fidl::Result<()> {
2287            decoder.debug_check_bounds::<Self>(offset);
2288            // Verify that padding bytes are zero.
2289            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
2290            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2291            let mask = 0xffffffff00000000u64;
2292            let maskedval = padval & mask;
2293            if maskedval != 0 {
2294                return Err(fidl::Error::NonZeroPadding {
2295                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
2296                });
2297            }
2298            fidl::decode!(
2299                fidl_fuchsia_bluetooth::PeerId,
2300                fidl::encoding::DefaultFuchsiaResourceDialect,
2301                &mut self.peer_id,
2302                decoder,
2303                offset + 0,
2304                _depth
2305            )?;
2306            fidl::decode!(
2307                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BrowseControllerExtMarker>>,
2308                fidl::encoding::DefaultFuchsiaResourceDialect,
2309                &mut self.client,
2310                decoder,
2311                offset + 8,
2312                _depth
2313            )?;
2314            Ok(())
2315        }
2316    }
2317
2318    impl fidl::encoding::ResourceTypeMarker for PeerManagerExtGetControllerForTargetRequest {
2319        type Borrowed<'a> = &'a mut Self;
2320        fn take_or_borrow<'a>(
2321            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2322        ) -> Self::Borrowed<'a> {
2323            value
2324        }
2325    }
2326
2327    unsafe impl fidl::encoding::TypeMarker for PeerManagerExtGetControllerForTargetRequest {
2328        type Owned = Self;
2329
2330        #[inline(always)]
2331        fn inline_align(_context: fidl::encoding::Context) -> usize {
2332            8
2333        }
2334
2335        #[inline(always)]
2336        fn inline_size(_context: fidl::encoding::Context) -> usize {
2337            16
2338        }
2339    }
2340
2341    unsafe impl
2342        fidl::encoding::Encode<
2343            PeerManagerExtGetControllerForTargetRequest,
2344            fidl::encoding::DefaultFuchsiaResourceDialect,
2345        > for &mut PeerManagerExtGetControllerForTargetRequest
2346    {
2347        #[inline]
2348        unsafe fn encode(
2349            self,
2350            encoder: &mut fidl::encoding::Encoder<
2351                '_,
2352                fidl::encoding::DefaultFuchsiaResourceDialect,
2353            >,
2354            offset: usize,
2355            _depth: fidl::encoding::Depth,
2356        ) -> fidl::Result<()> {
2357            encoder.debug_check_bounds::<PeerManagerExtGetControllerForTargetRequest>(offset);
2358            // Delegate to tuple encoding.
2359            fidl::encoding::Encode::<PeerManagerExtGetControllerForTargetRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2360                (
2361                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.peer_id),
2362                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControllerExtMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.client),
2363                ),
2364                encoder, offset, _depth
2365            )
2366        }
2367    }
2368    unsafe impl<
2369            T0: fidl::encoding::Encode<
2370                fidl_fuchsia_bluetooth::PeerId,
2371                fidl::encoding::DefaultFuchsiaResourceDialect,
2372            >,
2373            T1: fidl::encoding::Encode<
2374                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControllerExtMarker>>,
2375                fidl::encoding::DefaultFuchsiaResourceDialect,
2376            >,
2377        >
2378        fidl::encoding::Encode<
2379            PeerManagerExtGetControllerForTargetRequest,
2380            fidl::encoding::DefaultFuchsiaResourceDialect,
2381        > for (T0, T1)
2382    {
2383        #[inline]
2384        unsafe fn encode(
2385            self,
2386            encoder: &mut fidl::encoding::Encoder<
2387                '_,
2388                fidl::encoding::DefaultFuchsiaResourceDialect,
2389            >,
2390            offset: usize,
2391            depth: fidl::encoding::Depth,
2392        ) -> fidl::Result<()> {
2393            encoder.debug_check_bounds::<PeerManagerExtGetControllerForTargetRequest>(offset);
2394            // Zero out padding regions. There's no need to apply masks
2395            // because the unmasked parts will be overwritten by fields.
2396            unsafe {
2397                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
2398                (ptr as *mut u64).write_unaligned(0);
2399            }
2400            // Write the fields.
2401            self.0.encode(encoder, offset + 0, depth)?;
2402            self.1.encode(encoder, offset + 8, depth)?;
2403            Ok(())
2404        }
2405    }
2406
2407    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2408        for PeerManagerExtGetControllerForTargetRequest
2409    {
2410        #[inline(always)]
2411        fn new_empty() -> Self {
2412            Self {
2413                peer_id: fidl::new_empty!(
2414                    fidl_fuchsia_bluetooth::PeerId,
2415                    fidl::encoding::DefaultFuchsiaResourceDialect
2416                ),
2417                client: fidl::new_empty!(
2418                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControllerExtMarker>>,
2419                    fidl::encoding::DefaultFuchsiaResourceDialect
2420                ),
2421            }
2422        }
2423
2424        #[inline]
2425        unsafe fn decode(
2426            &mut self,
2427            decoder: &mut fidl::encoding::Decoder<
2428                '_,
2429                fidl::encoding::DefaultFuchsiaResourceDialect,
2430            >,
2431            offset: usize,
2432            _depth: fidl::encoding::Depth,
2433        ) -> fidl::Result<()> {
2434            decoder.debug_check_bounds::<Self>(offset);
2435            // Verify that padding bytes are zero.
2436            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
2437            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2438            let mask = 0xffffffff00000000u64;
2439            let maskedval = padval & mask;
2440            if maskedval != 0 {
2441                return Err(fidl::Error::NonZeroPadding {
2442                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
2443                });
2444            }
2445            fidl::decode!(
2446                fidl_fuchsia_bluetooth::PeerId,
2447                fidl::encoding::DefaultFuchsiaResourceDialect,
2448                &mut self.peer_id,
2449                decoder,
2450                offset + 0,
2451                _depth
2452            )?;
2453            fidl::decode!(
2454                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControllerExtMarker>>,
2455                fidl::encoding::DefaultFuchsiaResourceDialect,
2456                &mut self.client,
2457                decoder,
2458                offset + 8,
2459                _depth
2460            )?;
2461            Ok(())
2462        }
2463    }
2464}