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