Skip to main content

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