fidl_fuchsia_bluetooth_avrcp_test/
fidl_fuchsia_bluetooth_avrcp_test.rs

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