fidl_fuchsia_bluetooth_bredr_test/
fidl_fuchsia_bluetooth_bredr_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_bredr_test__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct MockPeerConnectProxyRequest {
16    pub interface: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for MockPeerConnectProxyRequest
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct ProfileTestRegisterPeerRequest {
26    pub peer_id: fidl_fuchsia_bluetooth::PeerId,
27    pub peer: fidl::endpoints::ServerEnd<MockPeerMarker>,
28    pub observer: fidl::endpoints::ClientEnd<PeerObserverMarker>,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for ProfileTestRegisterPeerRequest
33{
34}
35
36#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
37pub struct MockPeerMarker;
38
39impl fidl::endpoints::ProtocolMarker for MockPeerMarker {
40    type Proxy = MockPeerProxy;
41    type RequestStream = MockPeerRequestStream;
42    #[cfg(target_os = "fuchsia")]
43    type SynchronousProxy = MockPeerSynchronousProxy;
44
45    const DEBUG_NAME: &'static str = "(anonymous) MockPeer";
46}
47
48pub trait MockPeerProxyInterface: Send + Sync {
49    type ConnectProxy_ResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
50    fn r#connect_proxy_(
51        &self,
52        interface: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
53    ) -> Self::ConnectProxy_ResponseFut;
54}
55#[derive(Debug)]
56#[cfg(target_os = "fuchsia")]
57pub struct MockPeerSynchronousProxy {
58    client: fidl::client::sync::Client,
59}
60
61#[cfg(target_os = "fuchsia")]
62impl fidl::endpoints::SynchronousProxy for MockPeerSynchronousProxy {
63    type Proxy = MockPeerProxy;
64    type Protocol = MockPeerMarker;
65
66    fn from_channel(inner: fidl::Channel) -> Self {
67        Self::new(inner)
68    }
69
70    fn into_channel(self) -> fidl::Channel {
71        self.client.into_channel()
72    }
73
74    fn as_channel(&self) -> &fidl::Channel {
75        self.client.as_channel()
76    }
77}
78
79#[cfg(target_os = "fuchsia")]
80impl MockPeerSynchronousProxy {
81    pub fn new(channel: fidl::Channel) -> Self {
82        let protocol_name = <MockPeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
83        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
84    }
85
86    pub fn into_channel(self) -> fidl::Channel {
87        self.client.into_channel()
88    }
89
90    /// Waits until an event arrives and returns it. It is safe for other
91    /// threads to make concurrent requests while waiting for an event.
92    pub fn wait_for_event(
93        &self,
94        deadline: zx::MonotonicInstant,
95    ) -> Result<MockPeerEvent, fidl::Error> {
96        MockPeerEvent::decode(self.client.wait_for_event(deadline)?)
97    }
98
99    /// Connect a channel to the [`fuchsia.bluetooth.bredr.Profile`] protocol for
100    /// manipulation of the mock peer.
101    ///
102    /// It is valid to connect multiple proxies to a `MockPeer`.
103    ///
104    /// This parallels the current behavior of the bluetooth profile components.
105    /// Specifically, profiles internally use the [`fuchsia.bluetooth.bredr.Profile`]
106    /// service to register, search, and connect services. `ConnectProxy` provides a way
107    /// for the test client to do the same for a given mock peer.
108    ///
109    /// If the `interface` is not connectable, it will be dropped with an epitaph
110    /// signaling the failure.
111    ///
112    /// + request `interface` Interface to drive mock peer behavior.
113    pub fn r#connect_proxy_(
114        &self,
115        mut interface: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
116        ___deadline: zx::MonotonicInstant,
117    ) -> Result<(), fidl::Error> {
118        let _response =
119            self.client.send_query::<MockPeerConnectProxyRequest, fidl::encoding::EmptyPayload>(
120                (interface,),
121                0x578ee1f7ee6dd9d8,
122                fidl::encoding::DynamicFlags::empty(),
123                ___deadline,
124            )?;
125        Ok(_response)
126    }
127}
128
129#[cfg(target_os = "fuchsia")]
130impl From<MockPeerSynchronousProxy> for zx::Handle {
131    fn from(value: MockPeerSynchronousProxy) -> Self {
132        value.into_channel().into()
133    }
134}
135
136#[cfg(target_os = "fuchsia")]
137impl From<fidl::Channel> for MockPeerSynchronousProxy {
138    fn from(value: fidl::Channel) -> Self {
139        Self::new(value)
140    }
141}
142
143#[cfg(target_os = "fuchsia")]
144impl fidl::endpoints::FromClient for MockPeerSynchronousProxy {
145    type Protocol = MockPeerMarker;
146
147    fn from_client(value: fidl::endpoints::ClientEnd<MockPeerMarker>) -> Self {
148        Self::new(value.into_channel())
149    }
150}
151
152#[derive(Debug, Clone)]
153pub struct MockPeerProxy {
154    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
155}
156
157impl fidl::endpoints::Proxy for MockPeerProxy {
158    type Protocol = MockPeerMarker;
159
160    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
161        Self::new(inner)
162    }
163
164    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
165        self.client.into_channel().map_err(|client| Self { client })
166    }
167
168    fn as_channel(&self) -> &::fidl::AsyncChannel {
169        self.client.as_channel()
170    }
171}
172
173impl MockPeerProxy {
174    /// Create a new Proxy for fuchsia.bluetooth.bredr.test/MockPeer.
175    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
176        let protocol_name = <MockPeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
177        Self { client: fidl::client::Client::new(channel, protocol_name) }
178    }
179
180    /// Get a Stream of events from the remote end of the protocol.
181    ///
182    /// # Panics
183    ///
184    /// Panics if the event stream was already taken.
185    pub fn take_event_stream(&self) -> MockPeerEventStream {
186        MockPeerEventStream { event_receiver: self.client.take_event_receiver() }
187    }
188
189    /// Connect a channel to the [`fuchsia.bluetooth.bredr.Profile`] protocol for
190    /// manipulation of the mock peer.
191    ///
192    /// It is valid to connect multiple proxies to a `MockPeer`.
193    ///
194    /// This parallels the current behavior of the bluetooth profile components.
195    /// Specifically, profiles internally use the [`fuchsia.bluetooth.bredr.Profile`]
196    /// service to register, search, and connect services. `ConnectProxy` provides a way
197    /// for the test client to do the same for a given mock peer.
198    ///
199    /// If the `interface` is not connectable, it will be dropped with an epitaph
200    /// signaling the failure.
201    ///
202    /// + request `interface` Interface to drive mock peer behavior.
203    pub fn r#connect_proxy_(
204        &self,
205        mut interface: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
206    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
207        MockPeerProxyInterface::r#connect_proxy_(self, interface)
208    }
209}
210
211impl MockPeerProxyInterface for MockPeerProxy {
212    type ConnectProxy_ResponseFut =
213        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
214    fn r#connect_proxy_(
215        &self,
216        mut interface: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
217    ) -> Self::ConnectProxy_ResponseFut {
218        fn _decode(
219            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
220        ) -> Result<(), fidl::Error> {
221            let _response = fidl::client::decode_transaction_body::<
222                fidl::encoding::EmptyPayload,
223                fidl::encoding::DefaultFuchsiaResourceDialect,
224                0x578ee1f7ee6dd9d8,
225            >(_buf?)?;
226            Ok(_response)
227        }
228        self.client.send_query_and_decode::<MockPeerConnectProxyRequest, ()>(
229            (interface,),
230            0x578ee1f7ee6dd9d8,
231            fidl::encoding::DynamicFlags::empty(),
232            _decode,
233        )
234    }
235}
236
237pub struct MockPeerEventStream {
238    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
239}
240
241impl std::marker::Unpin for MockPeerEventStream {}
242
243impl futures::stream::FusedStream for MockPeerEventStream {
244    fn is_terminated(&self) -> bool {
245        self.event_receiver.is_terminated()
246    }
247}
248
249impl futures::Stream for MockPeerEventStream {
250    type Item = Result<MockPeerEvent, fidl::Error>;
251
252    fn poll_next(
253        mut self: std::pin::Pin<&mut Self>,
254        cx: &mut std::task::Context<'_>,
255    ) -> std::task::Poll<Option<Self::Item>> {
256        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
257            &mut self.event_receiver,
258            cx
259        )?) {
260            Some(buf) => std::task::Poll::Ready(Some(MockPeerEvent::decode(buf))),
261            None => std::task::Poll::Ready(None),
262        }
263    }
264}
265
266#[derive(Debug)]
267pub enum MockPeerEvent {}
268
269impl MockPeerEvent {
270    /// Decodes a message buffer as a [`MockPeerEvent`].
271    fn decode(
272        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
273    ) -> Result<MockPeerEvent, fidl::Error> {
274        let (bytes, _handles) = buf.split_mut();
275        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
276        debug_assert_eq!(tx_header.tx_id, 0);
277        match tx_header.ordinal {
278            _ => Err(fidl::Error::UnknownOrdinal {
279                ordinal: tx_header.ordinal,
280                protocol_name: <MockPeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
281            }),
282        }
283    }
284}
285
286/// A Stream of incoming requests for fuchsia.bluetooth.bredr.test/MockPeer.
287pub struct MockPeerRequestStream {
288    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
289    is_terminated: bool,
290}
291
292impl std::marker::Unpin for MockPeerRequestStream {}
293
294impl futures::stream::FusedStream for MockPeerRequestStream {
295    fn is_terminated(&self) -> bool {
296        self.is_terminated
297    }
298}
299
300impl fidl::endpoints::RequestStream for MockPeerRequestStream {
301    type Protocol = MockPeerMarker;
302    type ControlHandle = MockPeerControlHandle;
303
304    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
305        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
306    }
307
308    fn control_handle(&self) -> Self::ControlHandle {
309        MockPeerControlHandle { inner: self.inner.clone() }
310    }
311
312    fn into_inner(
313        self,
314    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
315    {
316        (self.inner, self.is_terminated)
317    }
318
319    fn from_inner(
320        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
321        is_terminated: bool,
322    ) -> Self {
323        Self { inner, is_terminated }
324    }
325}
326
327impl futures::Stream for MockPeerRequestStream {
328    type Item = Result<MockPeerRequest, fidl::Error>;
329
330    fn poll_next(
331        mut self: std::pin::Pin<&mut Self>,
332        cx: &mut std::task::Context<'_>,
333    ) -> std::task::Poll<Option<Self::Item>> {
334        let this = &mut *self;
335        if this.inner.check_shutdown(cx) {
336            this.is_terminated = true;
337            return std::task::Poll::Ready(None);
338        }
339        if this.is_terminated {
340            panic!("polled MockPeerRequestStream after completion");
341        }
342        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
343            |bytes, handles| {
344                match this.inner.channel().read_etc(cx, bytes, handles) {
345                    std::task::Poll::Ready(Ok(())) => {}
346                    std::task::Poll::Pending => return std::task::Poll::Pending,
347                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
348                        this.is_terminated = true;
349                        return std::task::Poll::Ready(None);
350                    }
351                    std::task::Poll::Ready(Err(e)) => {
352                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
353                            e.into(),
354                        ))))
355                    }
356                }
357
358                // A message has been received from the channel
359                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
360
361                std::task::Poll::Ready(Some(match header.ordinal {
362                    0x578ee1f7ee6dd9d8 => {
363                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
364                        let mut req = fidl::new_empty!(
365                            MockPeerConnectProxyRequest,
366                            fidl::encoding::DefaultFuchsiaResourceDialect
367                        );
368                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MockPeerConnectProxyRequest>(&header, _body_bytes, handles, &mut req)?;
369                        let control_handle = MockPeerControlHandle { inner: this.inner.clone() };
370                        Ok(MockPeerRequest::ConnectProxy_ {
371                            interface: req.interface,
372
373                            responder: MockPeerConnectProxy_Responder {
374                                control_handle: std::mem::ManuallyDrop::new(control_handle),
375                                tx_id: header.tx_id,
376                            },
377                        })
378                    }
379                    _ => Err(fidl::Error::UnknownOrdinal {
380                        ordinal: header.ordinal,
381                        protocol_name:
382                            <MockPeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
383                    }),
384                }))
385            },
386        )
387    }
388}
389
390/// `MockPeer` provides an interface for managing the lifetime of a mock peer in the piconet.
391/// Dropping `MockPeer` will unregister the peer from the Profile Test Server database.
392///   - Any launched components associated with the mock peer will be terminated.
393///   - Any actively connected `ProfileProxy` will be disconnected and dropped.
394#[derive(Debug)]
395pub enum MockPeerRequest {
396    /// Connect a channel to the [`fuchsia.bluetooth.bredr.Profile`] protocol for
397    /// manipulation of the mock peer.
398    ///
399    /// It is valid to connect multiple proxies to a `MockPeer`.
400    ///
401    /// This parallels the current behavior of the bluetooth profile components.
402    /// Specifically, profiles internally use the [`fuchsia.bluetooth.bredr.Profile`]
403    /// service to register, search, and connect services. `ConnectProxy` provides a way
404    /// for the test client to do the same for a given mock peer.
405    ///
406    /// If the `interface` is not connectable, it will be dropped with an epitaph
407    /// signaling the failure.
408    ///
409    /// + request `interface` Interface to drive mock peer behavior.
410    ConnectProxy_ {
411        interface: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
412        responder: MockPeerConnectProxy_Responder,
413    },
414}
415
416impl MockPeerRequest {
417    #[allow(irrefutable_let_patterns)]
418    pub fn into_connect_proxy_(
419        self,
420    ) -> Option<(
421        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
422        MockPeerConnectProxy_Responder,
423    )> {
424        if let MockPeerRequest::ConnectProxy_ { interface, responder } = self {
425            Some((interface, responder))
426        } else {
427            None
428        }
429    }
430
431    /// Name of the method defined in FIDL
432    pub fn method_name(&self) -> &'static str {
433        match *self {
434            MockPeerRequest::ConnectProxy_ { .. } => "connect_proxy_",
435        }
436    }
437}
438
439#[derive(Debug, Clone)]
440pub struct MockPeerControlHandle {
441    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
442}
443
444impl fidl::endpoints::ControlHandle for MockPeerControlHandle {
445    fn shutdown(&self) {
446        self.inner.shutdown()
447    }
448    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
449        self.inner.shutdown_with_epitaph(status)
450    }
451
452    fn is_closed(&self) -> bool {
453        self.inner.channel().is_closed()
454    }
455    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
456        self.inner.channel().on_closed()
457    }
458
459    #[cfg(target_os = "fuchsia")]
460    fn signal_peer(
461        &self,
462        clear_mask: zx::Signals,
463        set_mask: zx::Signals,
464    ) -> Result<(), zx_status::Status> {
465        use fidl::Peered;
466        self.inner.channel().signal_peer(clear_mask, set_mask)
467    }
468}
469
470impl MockPeerControlHandle {}
471
472#[must_use = "FIDL methods require a response to be sent"]
473#[derive(Debug)]
474pub struct MockPeerConnectProxy_Responder {
475    control_handle: std::mem::ManuallyDrop<MockPeerControlHandle>,
476    tx_id: u32,
477}
478
479/// Set the the channel to be shutdown (see [`MockPeerControlHandle::shutdown`])
480/// if the responder is dropped without sending a response, so that the client
481/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
482impl std::ops::Drop for MockPeerConnectProxy_Responder {
483    fn drop(&mut self) {
484        self.control_handle.shutdown();
485        // Safety: drops once, never accessed again
486        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
487    }
488}
489
490impl fidl::endpoints::Responder for MockPeerConnectProxy_Responder {
491    type ControlHandle = MockPeerControlHandle;
492
493    fn control_handle(&self) -> &MockPeerControlHandle {
494        &self.control_handle
495    }
496
497    fn drop_without_shutdown(mut self) {
498        // Safety: drops once, never accessed again due to mem::forget
499        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
500        // Prevent Drop from running (which would shut down the channel)
501        std::mem::forget(self);
502    }
503}
504
505impl MockPeerConnectProxy_Responder {
506    /// Sends a response to the FIDL transaction.
507    ///
508    /// Sets the channel to shutdown if an error occurs.
509    pub fn send(self) -> Result<(), fidl::Error> {
510        let _result = self.send_raw();
511        if _result.is_err() {
512            self.control_handle.shutdown();
513        }
514        self.drop_without_shutdown();
515        _result
516    }
517
518    /// Similar to "send" but does not shutdown the channel if an error occurs.
519    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
520        let _result = self.send_raw();
521        self.drop_without_shutdown();
522        _result
523    }
524
525    fn send_raw(&self) -> Result<(), fidl::Error> {
526        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
527            (),
528            self.tx_id,
529            0x578ee1f7ee6dd9d8,
530            fidl::encoding::DynamicFlags::empty(),
531        )
532    }
533}
534
535#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
536pub struct PeerObserverMarker;
537
538impl fidl::endpoints::ProtocolMarker for PeerObserverMarker {
539    type Proxy = PeerObserverProxy;
540    type RequestStream = PeerObserverRequestStream;
541    #[cfg(target_os = "fuchsia")]
542    type SynchronousProxy = PeerObserverSynchronousProxy;
543
544    const DEBUG_NAME: &'static str = "(anonymous) PeerObserver";
545}
546
547pub trait PeerObserverProxyInterface: Send + Sync {
548    type ServiceFoundResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
549    fn r#service_found(
550        &self,
551        peer_id: &fidl_fuchsia_bluetooth::PeerId,
552        protocol: Option<&[fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor]>,
553        attributes: &[fidl_fuchsia_bluetooth_bredr::Attribute],
554    ) -> Self::ServiceFoundResponseFut;
555    type PeerConnectedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
556    fn r#peer_connected(
557        &self,
558        peer_id: &fidl_fuchsia_bluetooth::PeerId,
559        protocol: &[fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor],
560    ) -> Self::PeerConnectedResponseFut;
561}
562#[derive(Debug)]
563#[cfg(target_os = "fuchsia")]
564pub struct PeerObserverSynchronousProxy {
565    client: fidl::client::sync::Client,
566}
567
568#[cfg(target_os = "fuchsia")]
569impl fidl::endpoints::SynchronousProxy for PeerObserverSynchronousProxy {
570    type Proxy = PeerObserverProxy;
571    type Protocol = PeerObserverMarker;
572
573    fn from_channel(inner: fidl::Channel) -> Self {
574        Self::new(inner)
575    }
576
577    fn into_channel(self) -> fidl::Channel {
578        self.client.into_channel()
579    }
580
581    fn as_channel(&self) -> &fidl::Channel {
582        self.client.as_channel()
583    }
584}
585
586#[cfg(target_os = "fuchsia")]
587impl PeerObserverSynchronousProxy {
588    pub fn new(channel: fidl::Channel) -> Self {
589        let protocol_name = <PeerObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
590        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
591    }
592
593    pub fn into_channel(self) -> fidl::Channel {
594        self.client.into_channel()
595    }
596
597    /// Waits until an event arrives and returns it. It is safe for other
598    /// threads to make concurrent requests while waiting for an event.
599    pub fn wait_for_event(
600        &self,
601        deadline: zx::MonotonicInstant,
602    ) -> Result<PeerObserverEvent, fidl::Error> {
603        PeerObserverEvent::decode(self.client.wait_for_event(deadline)?)
604    }
605
606    /// The peer discovered the services of another peer in the piconet.
607    ///
608    /// + request `peer_id` The peer the service was found on.
609    /// + request `protocol` Includes the ProtocolDescriptorList in the service record.
610    /// + request `attributes` Contains all attributes requested from the search that
611    ///                        are present on the peer record.
612    pub fn r#service_found(
613        &self,
614        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
615        mut protocol: Option<&[fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor]>,
616        mut attributes: &[fidl_fuchsia_bluetooth_bredr::Attribute],
617        ___deadline: zx::MonotonicInstant,
618    ) -> Result<(), fidl::Error> {
619        let _response = self
620            .client
621            .send_query::<PeerObserverServiceFoundRequest, fidl::encoding::EmptyPayload>(
622                (peer_id, protocol, attributes),
623                0x3b990da866718b5c,
624                fidl::encoding::DynamicFlags::empty(),
625                ___deadline,
626            )?;
627        Ok(_response)
628    }
629
630    /// Called when a peer has connected to a service.
631    ///
632    /// + request `peer_id` The peer that connected to the service.
633    /// + request `protocol` Contains the protocol list of the connection.
634    pub fn r#peer_connected(
635        &self,
636        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
637        mut protocol: &[fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor],
638        ___deadline: zx::MonotonicInstant,
639    ) -> Result<(), fidl::Error> {
640        let _response = self
641            .client
642            .send_query::<PeerObserverPeerConnectedRequest, fidl::encoding::EmptyPayload>(
643                (peer_id, protocol),
644                0x77ce6712cb60d46c,
645                fidl::encoding::DynamicFlags::empty(),
646                ___deadline,
647            )?;
648        Ok(_response)
649    }
650}
651
652#[cfg(target_os = "fuchsia")]
653impl From<PeerObserverSynchronousProxy> for zx::Handle {
654    fn from(value: PeerObserverSynchronousProxy) -> Self {
655        value.into_channel().into()
656    }
657}
658
659#[cfg(target_os = "fuchsia")]
660impl From<fidl::Channel> for PeerObserverSynchronousProxy {
661    fn from(value: fidl::Channel) -> Self {
662        Self::new(value)
663    }
664}
665
666#[cfg(target_os = "fuchsia")]
667impl fidl::endpoints::FromClient for PeerObserverSynchronousProxy {
668    type Protocol = PeerObserverMarker;
669
670    fn from_client(value: fidl::endpoints::ClientEnd<PeerObserverMarker>) -> Self {
671        Self::new(value.into_channel())
672    }
673}
674
675#[derive(Debug, Clone)]
676pub struct PeerObserverProxy {
677    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
678}
679
680impl fidl::endpoints::Proxy for PeerObserverProxy {
681    type Protocol = PeerObserverMarker;
682
683    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
684        Self::new(inner)
685    }
686
687    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
688        self.client.into_channel().map_err(|client| Self { client })
689    }
690
691    fn as_channel(&self) -> &::fidl::AsyncChannel {
692        self.client.as_channel()
693    }
694}
695
696impl PeerObserverProxy {
697    /// Create a new Proxy for fuchsia.bluetooth.bredr.test/PeerObserver.
698    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
699        let protocol_name = <PeerObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
700        Self { client: fidl::client::Client::new(channel, protocol_name) }
701    }
702
703    /// Get a Stream of events from the remote end of the protocol.
704    ///
705    /// # Panics
706    ///
707    /// Panics if the event stream was already taken.
708    pub fn take_event_stream(&self) -> PeerObserverEventStream {
709        PeerObserverEventStream { event_receiver: self.client.take_event_receiver() }
710    }
711
712    /// The peer discovered the services of another peer in the piconet.
713    ///
714    /// + request `peer_id` The peer the service was found on.
715    /// + request `protocol` Includes the ProtocolDescriptorList in the service record.
716    /// + request `attributes` Contains all attributes requested from the search that
717    ///                        are present on the peer record.
718    pub fn r#service_found(
719        &self,
720        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
721        mut protocol: Option<&[fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor]>,
722        mut attributes: &[fidl_fuchsia_bluetooth_bredr::Attribute],
723    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
724        PeerObserverProxyInterface::r#service_found(self, peer_id, protocol, attributes)
725    }
726
727    /// Called when a peer has connected to a service.
728    ///
729    /// + request `peer_id` The peer that connected to the service.
730    /// + request `protocol` Contains the protocol list of the connection.
731    pub fn r#peer_connected(
732        &self,
733        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
734        mut protocol: &[fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor],
735    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
736        PeerObserverProxyInterface::r#peer_connected(self, peer_id, protocol)
737    }
738}
739
740impl PeerObserverProxyInterface for PeerObserverProxy {
741    type ServiceFoundResponseFut =
742        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
743    fn r#service_found(
744        &self,
745        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
746        mut protocol: Option<&[fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor]>,
747        mut attributes: &[fidl_fuchsia_bluetooth_bredr::Attribute],
748    ) -> Self::ServiceFoundResponseFut {
749        fn _decode(
750            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
751        ) -> Result<(), fidl::Error> {
752            let _response = fidl::client::decode_transaction_body::<
753                fidl::encoding::EmptyPayload,
754                fidl::encoding::DefaultFuchsiaResourceDialect,
755                0x3b990da866718b5c,
756            >(_buf?)?;
757            Ok(_response)
758        }
759        self.client.send_query_and_decode::<PeerObserverServiceFoundRequest, ()>(
760            (peer_id, protocol, attributes),
761            0x3b990da866718b5c,
762            fidl::encoding::DynamicFlags::empty(),
763            _decode,
764        )
765    }
766
767    type PeerConnectedResponseFut =
768        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
769    fn r#peer_connected(
770        &self,
771        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
772        mut protocol: &[fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor],
773    ) -> Self::PeerConnectedResponseFut {
774        fn _decode(
775            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
776        ) -> Result<(), fidl::Error> {
777            let _response = fidl::client::decode_transaction_body::<
778                fidl::encoding::EmptyPayload,
779                fidl::encoding::DefaultFuchsiaResourceDialect,
780                0x77ce6712cb60d46c,
781            >(_buf?)?;
782            Ok(_response)
783        }
784        self.client.send_query_and_decode::<PeerObserverPeerConnectedRequest, ()>(
785            (peer_id, protocol),
786            0x77ce6712cb60d46c,
787            fidl::encoding::DynamicFlags::empty(),
788            _decode,
789        )
790    }
791}
792
793pub struct PeerObserverEventStream {
794    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
795}
796
797impl std::marker::Unpin for PeerObserverEventStream {}
798
799impl futures::stream::FusedStream for PeerObserverEventStream {
800    fn is_terminated(&self) -> bool {
801        self.event_receiver.is_terminated()
802    }
803}
804
805impl futures::Stream for PeerObserverEventStream {
806    type Item = Result<PeerObserverEvent, fidl::Error>;
807
808    fn poll_next(
809        mut self: std::pin::Pin<&mut Self>,
810        cx: &mut std::task::Context<'_>,
811    ) -> std::task::Poll<Option<Self::Item>> {
812        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
813            &mut self.event_receiver,
814            cx
815        )?) {
816            Some(buf) => std::task::Poll::Ready(Some(PeerObserverEvent::decode(buf))),
817            None => std::task::Poll::Ready(None),
818        }
819    }
820}
821
822#[derive(Debug)]
823pub enum PeerObserverEvent {}
824
825impl PeerObserverEvent {
826    /// Decodes a message buffer as a [`PeerObserverEvent`].
827    fn decode(
828        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
829    ) -> Result<PeerObserverEvent, fidl::Error> {
830        let (bytes, _handles) = buf.split_mut();
831        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
832        debug_assert_eq!(tx_header.tx_id, 0);
833        match tx_header.ordinal {
834            _ => Err(fidl::Error::UnknownOrdinal {
835                ordinal: tx_header.ordinal,
836                protocol_name: <PeerObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
837            }),
838        }
839    }
840}
841
842/// A Stream of incoming requests for fuchsia.bluetooth.bredr.test/PeerObserver.
843pub struct PeerObserverRequestStream {
844    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
845    is_terminated: bool,
846}
847
848impl std::marker::Unpin for PeerObserverRequestStream {}
849
850impl futures::stream::FusedStream for PeerObserverRequestStream {
851    fn is_terminated(&self) -> bool {
852        self.is_terminated
853    }
854}
855
856impl fidl::endpoints::RequestStream for PeerObserverRequestStream {
857    type Protocol = PeerObserverMarker;
858    type ControlHandle = PeerObserverControlHandle;
859
860    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
861        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
862    }
863
864    fn control_handle(&self) -> Self::ControlHandle {
865        PeerObserverControlHandle { inner: self.inner.clone() }
866    }
867
868    fn into_inner(
869        self,
870    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
871    {
872        (self.inner, self.is_terminated)
873    }
874
875    fn from_inner(
876        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
877        is_terminated: bool,
878    ) -> Self {
879        Self { inner, is_terminated }
880    }
881}
882
883impl futures::Stream for PeerObserverRequestStream {
884    type Item = Result<PeerObserverRequest, fidl::Error>;
885
886    fn poll_next(
887        mut self: std::pin::Pin<&mut Self>,
888        cx: &mut std::task::Context<'_>,
889    ) -> std::task::Poll<Option<Self::Item>> {
890        let this = &mut *self;
891        if this.inner.check_shutdown(cx) {
892            this.is_terminated = true;
893            return std::task::Poll::Ready(None);
894        }
895        if this.is_terminated {
896            panic!("polled PeerObserverRequestStream after completion");
897        }
898        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
899            |bytes, handles| {
900                match this.inner.channel().read_etc(cx, bytes, handles) {
901                    std::task::Poll::Ready(Ok(())) => {}
902                    std::task::Poll::Pending => return std::task::Poll::Pending,
903                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
904                        this.is_terminated = true;
905                        return std::task::Poll::Ready(None);
906                    }
907                    std::task::Poll::Ready(Err(e)) => {
908                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
909                            e.into(),
910                        ))))
911                    }
912                }
913
914                // A message has been received from the channel
915                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
916
917                std::task::Poll::Ready(Some(match header.ordinal {
918                    0x3b990da866718b5c => {
919                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
920                        let mut req = fidl::new_empty!(
921                            PeerObserverServiceFoundRequest,
922                            fidl::encoding::DefaultFuchsiaResourceDialect
923                        );
924                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerObserverServiceFoundRequest>(&header, _body_bytes, handles, &mut req)?;
925                        let control_handle =
926                            PeerObserverControlHandle { inner: this.inner.clone() };
927                        Ok(PeerObserverRequest::ServiceFound {
928                            peer_id: req.peer_id,
929                            protocol: req.protocol,
930                            attributes: req.attributes,
931
932                            responder: PeerObserverServiceFoundResponder {
933                                control_handle: std::mem::ManuallyDrop::new(control_handle),
934                                tx_id: header.tx_id,
935                            },
936                        })
937                    }
938                    0x77ce6712cb60d46c => {
939                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
940                        let mut req = fidl::new_empty!(
941                            PeerObserverPeerConnectedRequest,
942                            fidl::encoding::DefaultFuchsiaResourceDialect
943                        );
944                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerObserverPeerConnectedRequest>(&header, _body_bytes, handles, &mut req)?;
945                        let control_handle =
946                            PeerObserverControlHandle { inner: this.inner.clone() };
947                        Ok(PeerObserverRequest::PeerConnected {
948                            peer_id: req.peer_id,
949                            protocol: req.protocol,
950
951                            responder: PeerObserverPeerConnectedResponder {
952                                control_handle: std::mem::ManuallyDrop::new(control_handle),
953                                tx_id: header.tx_id,
954                            },
955                        })
956                    }
957                    _ => Err(fidl::Error::UnknownOrdinal {
958                        ordinal: header.ordinal,
959                        protocol_name:
960                            <PeerObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
961                    }),
962                }))
963            },
964        )
965    }
966}
967
968/// `PeerObserver` provides the integration test client with a way to validate the
969/// behavior of a peer in the piconet.
970/// Dropping `PeerObserver` will stop any subsequent updates for the peer.
971#[derive(Debug)]
972pub enum PeerObserverRequest {
973    /// The peer discovered the services of another peer in the piconet.
974    ///
975    /// + request `peer_id` The peer the service was found on.
976    /// + request `protocol` Includes the ProtocolDescriptorList in the service record.
977    /// + request `attributes` Contains all attributes requested from the search that
978    ///                        are present on the peer record.
979    ServiceFound {
980        peer_id: fidl_fuchsia_bluetooth::PeerId,
981        protocol: Option<Vec<fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor>>,
982        attributes: Vec<fidl_fuchsia_bluetooth_bredr::Attribute>,
983        responder: PeerObserverServiceFoundResponder,
984    },
985    /// Called when a peer has connected to a service.
986    ///
987    /// + request `peer_id` The peer that connected to the service.
988    /// + request `protocol` Contains the protocol list of the connection.
989    PeerConnected {
990        peer_id: fidl_fuchsia_bluetooth::PeerId,
991        protocol: Vec<fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor>,
992        responder: PeerObserverPeerConnectedResponder,
993    },
994}
995
996impl PeerObserverRequest {
997    #[allow(irrefutable_let_patterns)]
998    pub fn into_service_found(
999        self,
1000    ) -> Option<(
1001        fidl_fuchsia_bluetooth::PeerId,
1002        Option<Vec<fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor>>,
1003        Vec<fidl_fuchsia_bluetooth_bredr::Attribute>,
1004        PeerObserverServiceFoundResponder,
1005    )> {
1006        if let PeerObserverRequest::ServiceFound { peer_id, protocol, attributes, responder } = self
1007        {
1008            Some((peer_id, protocol, attributes, responder))
1009        } else {
1010            None
1011        }
1012    }
1013
1014    #[allow(irrefutable_let_patterns)]
1015    pub fn into_peer_connected(
1016        self,
1017    ) -> Option<(
1018        fidl_fuchsia_bluetooth::PeerId,
1019        Vec<fidl_fuchsia_bluetooth_bredr::ProtocolDescriptor>,
1020        PeerObserverPeerConnectedResponder,
1021    )> {
1022        if let PeerObserverRequest::PeerConnected { peer_id, protocol, responder } = self {
1023            Some((peer_id, protocol, responder))
1024        } else {
1025            None
1026        }
1027    }
1028
1029    /// Name of the method defined in FIDL
1030    pub fn method_name(&self) -> &'static str {
1031        match *self {
1032            PeerObserverRequest::ServiceFound { .. } => "service_found",
1033            PeerObserverRequest::PeerConnected { .. } => "peer_connected",
1034        }
1035    }
1036}
1037
1038#[derive(Debug, Clone)]
1039pub struct PeerObserverControlHandle {
1040    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1041}
1042
1043impl fidl::endpoints::ControlHandle for PeerObserverControlHandle {
1044    fn shutdown(&self) {
1045        self.inner.shutdown()
1046    }
1047    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1048        self.inner.shutdown_with_epitaph(status)
1049    }
1050
1051    fn is_closed(&self) -> bool {
1052        self.inner.channel().is_closed()
1053    }
1054    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1055        self.inner.channel().on_closed()
1056    }
1057
1058    #[cfg(target_os = "fuchsia")]
1059    fn signal_peer(
1060        &self,
1061        clear_mask: zx::Signals,
1062        set_mask: zx::Signals,
1063    ) -> Result<(), zx_status::Status> {
1064        use fidl::Peered;
1065        self.inner.channel().signal_peer(clear_mask, set_mask)
1066    }
1067}
1068
1069impl PeerObserverControlHandle {}
1070
1071#[must_use = "FIDL methods require a response to be sent"]
1072#[derive(Debug)]
1073pub struct PeerObserverServiceFoundResponder {
1074    control_handle: std::mem::ManuallyDrop<PeerObserverControlHandle>,
1075    tx_id: u32,
1076}
1077
1078/// Set the the channel to be shutdown (see [`PeerObserverControlHandle::shutdown`])
1079/// if the responder is dropped without sending a response, so that the client
1080/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1081impl std::ops::Drop for PeerObserverServiceFoundResponder {
1082    fn drop(&mut self) {
1083        self.control_handle.shutdown();
1084        // Safety: drops once, never accessed again
1085        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1086    }
1087}
1088
1089impl fidl::endpoints::Responder for PeerObserverServiceFoundResponder {
1090    type ControlHandle = PeerObserverControlHandle;
1091
1092    fn control_handle(&self) -> &PeerObserverControlHandle {
1093        &self.control_handle
1094    }
1095
1096    fn drop_without_shutdown(mut self) {
1097        // Safety: drops once, never accessed again due to mem::forget
1098        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1099        // Prevent Drop from running (which would shut down the channel)
1100        std::mem::forget(self);
1101    }
1102}
1103
1104impl PeerObserverServiceFoundResponder {
1105    /// Sends a response to the FIDL transaction.
1106    ///
1107    /// Sets the channel to shutdown if an error occurs.
1108    pub fn send(self) -> Result<(), fidl::Error> {
1109        let _result = self.send_raw();
1110        if _result.is_err() {
1111            self.control_handle.shutdown();
1112        }
1113        self.drop_without_shutdown();
1114        _result
1115    }
1116
1117    /// Similar to "send" but does not shutdown the channel if an error occurs.
1118    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1119        let _result = self.send_raw();
1120        self.drop_without_shutdown();
1121        _result
1122    }
1123
1124    fn send_raw(&self) -> Result<(), fidl::Error> {
1125        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1126            (),
1127            self.tx_id,
1128            0x3b990da866718b5c,
1129            fidl::encoding::DynamicFlags::empty(),
1130        )
1131    }
1132}
1133
1134#[must_use = "FIDL methods require a response to be sent"]
1135#[derive(Debug)]
1136pub struct PeerObserverPeerConnectedResponder {
1137    control_handle: std::mem::ManuallyDrop<PeerObserverControlHandle>,
1138    tx_id: u32,
1139}
1140
1141/// Set the the channel to be shutdown (see [`PeerObserverControlHandle::shutdown`])
1142/// if the responder is dropped without sending a response, so that the client
1143/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1144impl std::ops::Drop for PeerObserverPeerConnectedResponder {
1145    fn drop(&mut self) {
1146        self.control_handle.shutdown();
1147        // Safety: drops once, never accessed again
1148        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1149    }
1150}
1151
1152impl fidl::endpoints::Responder for PeerObserverPeerConnectedResponder {
1153    type ControlHandle = PeerObserverControlHandle;
1154
1155    fn control_handle(&self) -> &PeerObserverControlHandle {
1156        &self.control_handle
1157    }
1158
1159    fn drop_without_shutdown(mut self) {
1160        // Safety: drops once, never accessed again due to mem::forget
1161        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1162        // Prevent Drop from running (which would shut down the channel)
1163        std::mem::forget(self);
1164    }
1165}
1166
1167impl PeerObserverPeerConnectedResponder {
1168    /// Sends a response to the FIDL transaction.
1169    ///
1170    /// Sets the channel to shutdown if an error occurs.
1171    pub fn send(self) -> Result<(), fidl::Error> {
1172        let _result = self.send_raw();
1173        if _result.is_err() {
1174            self.control_handle.shutdown();
1175        }
1176        self.drop_without_shutdown();
1177        _result
1178    }
1179
1180    /// Similar to "send" but does not shutdown the channel if an error occurs.
1181    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1182        let _result = self.send_raw();
1183        self.drop_without_shutdown();
1184        _result
1185    }
1186
1187    fn send_raw(&self) -> Result<(), fidl::Error> {
1188        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1189            (),
1190            self.tx_id,
1191            0x77ce6712cb60d46c,
1192            fidl::encoding::DynamicFlags::empty(),
1193        )
1194    }
1195}
1196
1197#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1198pub struct ProfileTestMarker;
1199
1200impl fidl::endpoints::ProtocolMarker for ProfileTestMarker {
1201    type Proxy = ProfileTestProxy;
1202    type RequestStream = ProfileTestRequestStream;
1203    #[cfg(target_os = "fuchsia")]
1204    type SynchronousProxy = ProfileTestSynchronousProxy;
1205
1206    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.bredr.test.ProfileTest";
1207}
1208impl fidl::endpoints::DiscoverableProtocolMarker for ProfileTestMarker {}
1209
1210pub trait ProfileTestProxyInterface: Send + Sync {
1211    type RegisterPeerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1212    fn r#register_peer(
1213        &self,
1214        peer_id: &fidl_fuchsia_bluetooth::PeerId,
1215        peer: fidl::endpoints::ServerEnd<MockPeerMarker>,
1216        observer: fidl::endpoints::ClientEnd<PeerObserverMarker>,
1217    ) -> Self::RegisterPeerResponseFut;
1218}
1219#[derive(Debug)]
1220#[cfg(target_os = "fuchsia")]
1221pub struct ProfileTestSynchronousProxy {
1222    client: fidl::client::sync::Client,
1223}
1224
1225#[cfg(target_os = "fuchsia")]
1226impl fidl::endpoints::SynchronousProxy for ProfileTestSynchronousProxy {
1227    type Proxy = ProfileTestProxy;
1228    type Protocol = ProfileTestMarker;
1229
1230    fn from_channel(inner: fidl::Channel) -> Self {
1231        Self::new(inner)
1232    }
1233
1234    fn into_channel(self) -> fidl::Channel {
1235        self.client.into_channel()
1236    }
1237
1238    fn as_channel(&self) -> &fidl::Channel {
1239        self.client.as_channel()
1240    }
1241}
1242
1243#[cfg(target_os = "fuchsia")]
1244impl ProfileTestSynchronousProxy {
1245    pub fn new(channel: fidl::Channel) -> Self {
1246        let protocol_name = <ProfileTestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1247        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1248    }
1249
1250    pub fn into_channel(self) -> fidl::Channel {
1251        self.client.into_channel()
1252    }
1253
1254    /// Waits until an event arrives and returns it. It is safe for other
1255    /// threads to make concurrent requests while waiting for an event.
1256    pub fn wait_for_event(
1257        &self,
1258        deadline: zx::MonotonicInstant,
1259    ) -> Result<ProfileTestEvent, fidl::Error> {
1260        ProfileTestEvent::decode(self.client.wait_for_event(deadline)?)
1261    }
1262
1263    /// Creates a new fake peer in the Profile Test Server database. An empty response is
1264    /// sent to indicate when registration is complete.
1265    ///
1266    /// Use the provided [`PeerObserver`] interface to observe behavior of the registered peer.
1267    /// Dropping the `observer` will cease the updates from the server for the associated peer.
1268    ///
1269    /// If registration is unsuccessful, the `peer` and `observer` will be closed.
1270    ///
1271    /// + request `peer_id` Identifier for the created peer.
1272    /// + request `peer` Handle that can be used to drive peer behavior using the
1273    ///                  [`fuchsia.blueooth.bredr.MockPeer`] interface.
1274    /// + request `observer` Relay for communicating updates from the mock peer.
1275    pub fn r#register_peer(
1276        &self,
1277        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1278        mut peer: fidl::endpoints::ServerEnd<MockPeerMarker>,
1279        mut observer: fidl::endpoints::ClientEnd<PeerObserverMarker>,
1280        ___deadline: zx::MonotonicInstant,
1281    ) -> Result<(), fidl::Error> {
1282        let _response = self
1283            .client
1284            .send_query::<ProfileTestRegisterPeerRequest, fidl::encoding::EmptyPayload>(
1285                (peer_id, peer, observer),
1286                0x4cb156cd976ac1a8,
1287                fidl::encoding::DynamicFlags::empty(),
1288                ___deadline,
1289            )?;
1290        Ok(_response)
1291    }
1292}
1293
1294#[cfg(target_os = "fuchsia")]
1295impl From<ProfileTestSynchronousProxy> for zx::Handle {
1296    fn from(value: ProfileTestSynchronousProxy) -> Self {
1297        value.into_channel().into()
1298    }
1299}
1300
1301#[cfg(target_os = "fuchsia")]
1302impl From<fidl::Channel> for ProfileTestSynchronousProxy {
1303    fn from(value: fidl::Channel) -> Self {
1304        Self::new(value)
1305    }
1306}
1307
1308#[cfg(target_os = "fuchsia")]
1309impl fidl::endpoints::FromClient for ProfileTestSynchronousProxy {
1310    type Protocol = ProfileTestMarker;
1311
1312    fn from_client(value: fidl::endpoints::ClientEnd<ProfileTestMarker>) -> Self {
1313        Self::new(value.into_channel())
1314    }
1315}
1316
1317#[derive(Debug, Clone)]
1318pub struct ProfileTestProxy {
1319    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1320}
1321
1322impl fidl::endpoints::Proxy for ProfileTestProxy {
1323    type Protocol = ProfileTestMarker;
1324
1325    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1326        Self::new(inner)
1327    }
1328
1329    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1330        self.client.into_channel().map_err(|client| Self { client })
1331    }
1332
1333    fn as_channel(&self) -> &::fidl::AsyncChannel {
1334        self.client.as_channel()
1335    }
1336}
1337
1338impl ProfileTestProxy {
1339    /// Create a new Proxy for fuchsia.bluetooth.bredr.test/ProfileTest.
1340    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1341        let protocol_name = <ProfileTestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1342        Self { client: fidl::client::Client::new(channel, protocol_name) }
1343    }
1344
1345    /// Get a Stream of events from the remote end of the protocol.
1346    ///
1347    /// # Panics
1348    ///
1349    /// Panics if the event stream was already taken.
1350    pub fn take_event_stream(&self) -> ProfileTestEventStream {
1351        ProfileTestEventStream { event_receiver: self.client.take_event_receiver() }
1352    }
1353
1354    /// Creates a new fake peer in the Profile Test Server database. An empty response is
1355    /// sent to indicate when registration is complete.
1356    ///
1357    /// Use the provided [`PeerObserver`] interface to observe behavior of the registered peer.
1358    /// Dropping the `observer` will cease the updates from the server for the associated peer.
1359    ///
1360    /// If registration is unsuccessful, the `peer` and `observer` will be closed.
1361    ///
1362    /// + request `peer_id` Identifier for the created peer.
1363    /// + request `peer` Handle that can be used to drive peer behavior using the
1364    ///                  [`fuchsia.blueooth.bredr.MockPeer`] interface.
1365    /// + request `observer` Relay for communicating updates from the mock peer.
1366    pub fn r#register_peer(
1367        &self,
1368        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1369        mut peer: fidl::endpoints::ServerEnd<MockPeerMarker>,
1370        mut observer: fidl::endpoints::ClientEnd<PeerObserverMarker>,
1371    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1372        ProfileTestProxyInterface::r#register_peer(self, peer_id, peer, observer)
1373    }
1374}
1375
1376impl ProfileTestProxyInterface for ProfileTestProxy {
1377    type RegisterPeerResponseFut =
1378        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1379    fn r#register_peer(
1380        &self,
1381        mut peer_id: &fidl_fuchsia_bluetooth::PeerId,
1382        mut peer: fidl::endpoints::ServerEnd<MockPeerMarker>,
1383        mut observer: fidl::endpoints::ClientEnd<PeerObserverMarker>,
1384    ) -> Self::RegisterPeerResponseFut {
1385        fn _decode(
1386            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1387        ) -> Result<(), fidl::Error> {
1388            let _response = fidl::client::decode_transaction_body::<
1389                fidl::encoding::EmptyPayload,
1390                fidl::encoding::DefaultFuchsiaResourceDialect,
1391                0x4cb156cd976ac1a8,
1392            >(_buf?)?;
1393            Ok(_response)
1394        }
1395        self.client.send_query_and_decode::<ProfileTestRegisterPeerRequest, ()>(
1396            (peer_id, peer, observer),
1397            0x4cb156cd976ac1a8,
1398            fidl::encoding::DynamicFlags::empty(),
1399            _decode,
1400        )
1401    }
1402}
1403
1404pub struct ProfileTestEventStream {
1405    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1406}
1407
1408impl std::marker::Unpin for ProfileTestEventStream {}
1409
1410impl futures::stream::FusedStream for ProfileTestEventStream {
1411    fn is_terminated(&self) -> bool {
1412        self.event_receiver.is_terminated()
1413    }
1414}
1415
1416impl futures::Stream for ProfileTestEventStream {
1417    type Item = Result<ProfileTestEvent, fidl::Error>;
1418
1419    fn poll_next(
1420        mut self: std::pin::Pin<&mut Self>,
1421        cx: &mut std::task::Context<'_>,
1422    ) -> std::task::Poll<Option<Self::Item>> {
1423        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1424            &mut self.event_receiver,
1425            cx
1426        )?) {
1427            Some(buf) => std::task::Poll::Ready(Some(ProfileTestEvent::decode(buf))),
1428            None => std::task::Poll::Ready(None),
1429        }
1430    }
1431}
1432
1433#[derive(Debug)]
1434pub enum ProfileTestEvent {}
1435
1436impl ProfileTestEvent {
1437    /// Decodes a message buffer as a [`ProfileTestEvent`].
1438    fn decode(
1439        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1440    ) -> Result<ProfileTestEvent, fidl::Error> {
1441        let (bytes, _handles) = buf.split_mut();
1442        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1443        debug_assert_eq!(tx_header.tx_id, 0);
1444        match tx_header.ordinal {
1445            _ => Err(fidl::Error::UnknownOrdinal {
1446                ordinal: tx_header.ordinal,
1447                protocol_name: <ProfileTestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1448            }),
1449        }
1450    }
1451}
1452
1453/// A Stream of incoming requests for fuchsia.bluetooth.bredr.test/ProfileTest.
1454pub struct ProfileTestRequestStream {
1455    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1456    is_terminated: bool,
1457}
1458
1459impl std::marker::Unpin for ProfileTestRequestStream {}
1460
1461impl futures::stream::FusedStream for ProfileTestRequestStream {
1462    fn is_terminated(&self) -> bool {
1463        self.is_terminated
1464    }
1465}
1466
1467impl fidl::endpoints::RequestStream for ProfileTestRequestStream {
1468    type Protocol = ProfileTestMarker;
1469    type ControlHandle = ProfileTestControlHandle;
1470
1471    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1472        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1473    }
1474
1475    fn control_handle(&self) -> Self::ControlHandle {
1476        ProfileTestControlHandle { inner: self.inner.clone() }
1477    }
1478
1479    fn into_inner(
1480        self,
1481    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1482    {
1483        (self.inner, self.is_terminated)
1484    }
1485
1486    fn from_inner(
1487        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1488        is_terminated: bool,
1489    ) -> Self {
1490        Self { inner, is_terminated }
1491    }
1492}
1493
1494impl futures::Stream for ProfileTestRequestStream {
1495    type Item = Result<ProfileTestRequest, fidl::Error>;
1496
1497    fn poll_next(
1498        mut self: std::pin::Pin<&mut Self>,
1499        cx: &mut std::task::Context<'_>,
1500    ) -> std::task::Poll<Option<Self::Item>> {
1501        let this = &mut *self;
1502        if this.inner.check_shutdown(cx) {
1503            this.is_terminated = true;
1504            return std::task::Poll::Ready(None);
1505        }
1506        if this.is_terminated {
1507            panic!("polled ProfileTestRequestStream after completion");
1508        }
1509        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1510            |bytes, handles| {
1511                match this.inner.channel().read_etc(cx, bytes, handles) {
1512                    std::task::Poll::Ready(Ok(())) => {}
1513                    std::task::Poll::Pending => return std::task::Poll::Pending,
1514                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1515                        this.is_terminated = true;
1516                        return std::task::Poll::Ready(None);
1517                    }
1518                    std::task::Poll::Ready(Err(e)) => {
1519                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1520                            e.into(),
1521                        ))))
1522                    }
1523                }
1524
1525                // A message has been received from the channel
1526                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1527
1528                std::task::Poll::Ready(Some(match header.ordinal {
1529                    0x4cb156cd976ac1a8 => {
1530                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1531                        let mut req = fidl::new_empty!(
1532                            ProfileTestRegisterPeerRequest,
1533                            fidl::encoding::DefaultFuchsiaResourceDialect
1534                        );
1535                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileTestRegisterPeerRequest>(&header, _body_bytes, handles, &mut req)?;
1536                        let control_handle = ProfileTestControlHandle { inner: this.inner.clone() };
1537                        Ok(ProfileTestRequest::RegisterPeer {
1538                            peer_id: req.peer_id,
1539                            peer: req.peer,
1540                            observer: req.observer,
1541
1542                            responder: ProfileTestRegisterPeerResponder {
1543                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1544                                tx_id: header.tx_id,
1545                            },
1546                        })
1547                    }
1548                    _ => Err(fidl::Error::UnknownOrdinal {
1549                        ordinal: header.ordinal,
1550                        protocol_name:
1551                            <ProfileTestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1552                    }),
1553                }))
1554            },
1555        )
1556    }
1557}
1558
1559/// The `ProfileTest` interface should be used to validate behavior of Bluetooth Profiles
1560/// that use the [`fuchsia.bluetooth.bredr.Profile`] service.
1561///
1562/// The ProfileTest interface is used to create and manage fake peers.
1563/// A mock piconet is created in which registered peers can discover and interact with
1564/// each other.
1565#[derive(Debug)]
1566pub enum ProfileTestRequest {
1567    /// Creates a new fake peer in the Profile Test Server database. An empty response is
1568    /// sent to indicate when registration is complete.
1569    ///
1570    /// Use the provided [`PeerObserver`] interface to observe behavior of the registered peer.
1571    /// Dropping the `observer` will cease the updates from the server for the associated peer.
1572    ///
1573    /// If registration is unsuccessful, the `peer` and `observer` will be closed.
1574    ///
1575    /// + request `peer_id` Identifier for the created peer.
1576    /// + request `peer` Handle that can be used to drive peer behavior using the
1577    ///                  [`fuchsia.blueooth.bredr.MockPeer`] interface.
1578    /// + request `observer` Relay for communicating updates from the mock peer.
1579    RegisterPeer {
1580        peer_id: fidl_fuchsia_bluetooth::PeerId,
1581        peer: fidl::endpoints::ServerEnd<MockPeerMarker>,
1582        observer: fidl::endpoints::ClientEnd<PeerObserverMarker>,
1583        responder: ProfileTestRegisterPeerResponder,
1584    },
1585}
1586
1587impl ProfileTestRequest {
1588    #[allow(irrefutable_let_patterns)]
1589    pub fn into_register_peer(
1590        self,
1591    ) -> Option<(
1592        fidl_fuchsia_bluetooth::PeerId,
1593        fidl::endpoints::ServerEnd<MockPeerMarker>,
1594        fidl::endpoints::ClientEnd<PeerObserverMarker>,
1595        ProfileTestRegisterPeerResponder,
1596    )> {
1597        if let ProfileTestRequest::RegisterPeer { peer_id, peer, observer, responder } = self {
1598            Some((peer_id, peer, observer, responder))
1599        } else {
1600            None
1601        }
1602    }
1603
1604    /// Name of the method defined in FIDL
1605    pub fn method_name(&self) -> &'static str {
1606        match *self {
1607            ProfileTestRequest::RegisterPeer { .. } => "register_peer",
1608        }
1609    }
1610}
1611
1612#[derive(Debug, Clone)]
1613pub struct ProfileTestControlHandle {
1614    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1615}
1616
1617impl fidl::endpoints::ControlHandle for ProfileTestControlHandle {
1618    fn shutdown(&self) {
1619        self.inner.shutdown()
1620    }
1621    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1622        self.inner.shutdown_with_epitaph(status)
1623    }
1624
1625    fn is_closed(&self) -> bool {
1626        self.inner.channel().is_closed()
1627    }
1628    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1629        self.inner.channel().on_closed()
1630    }
1631
1632    #[cfg(target_os = "fuchsia")]
1633    fn signal_peer(
1634        &self,
1635        clear_mask: zx::Signals,
1636        set_mask: zx::Signals,
1637    ) -> Result<(), zx_status::Status> {
1638        use fidl::Peered;
1639        self.inner.channel().signal_peer(clear_mask, set_mask)
1640    }
1641}
1642
1643impl ProfileTestControlHandle {}
1644
1645#[must_use = "FIDL methods require a response to be sent"]
1646#[derive(Debug)]
1647pub struct ProfileTestRegisterPeerResponder {
1648    control_handle: std::mem::ManuallyDrop<ProfileTestControlHandle>,
1649    tx_id: u32,
1650}
1651
1652/// Set the the channel to be shutdown (see [`ProfileTestControlHandle::shutdown`])
1653/// if the responder is dropped without sending a response, so that the client
1654/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1655impl std::ops::Drop for ProfileTestRegisterPeerResponder {
1656    fn drop(&mut self) {
1657        self.control_handle.shutdown();
1658        // Safety: drops once, never accessed again
1659        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1660    }
1661}
1662
1663impl fidl::endpoints::Responder for ProfileTestRegisterPeerResponder {
1664    type ControlHandle = ProfileTestControlHandle;
1665
1666    fn control_handle(&self) -> &ProfileTestControlHandle {
1667        &self.control_handle
1668    }
1669
1670    fn drop_without_shutdown(mut self) {
1671        // Safety: drops once, never accessed again due to mem::forget
1672        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1673        // Prevent Drop from running (which would shut down the channel)
1674        std::mem::forget(self);
1675    }
1676}
1677
1678impl ProfileTestRegisterPeerResponder {
1679    /// Sends a response to the FIDL transaction.
1680    ///
1681    /// Sets the channel to shutdown if an error occurs.
1682    pub fn send(self) -> Result<(), fidl::Error> {
1683        let _result = self.send_raw();
1684        if _result.is_err() {
1685            self.control_handle.shutdown();
1686        }
1687        self.drop_without_shutdown();
1688        _result
1689    }
1690
1691    /// Similar to "send" but does not shutdown the channel if an error occurs.
1692    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1693        let _result = self.send_raw();
1694        self.drop_without_shutdown();
1695        _result
1696    }
1697
1698    fn send_raw(&self) -> Result<(), fidl::Error> {
1699        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1700            (),
1701            self.tx_id,
1702            0x4cb156cd976ac1a8,
1703            fidl::encoding::DynamicFlags::empty(),
1704        )
1705    }
1706}
1707
1708mod internal {
1709    use super::*;
1710
1711    impl fidl::encoding::ResourceTypeMarker for MockPeerConnectProxyRequest {
1712        type Borrowed<'a> = &'a mut Self;
1713        fn take_or_borrow<'a>(
1714            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1715        ) -> Self::Borrowed<'a> {
1716            value
1717        }
1718    }
1719
1720    unsafe impl fidl::encoding::TypeMarker for MockPeerConnectProxyRequest {
1721        type Owned = Self;
1722
1723        #[inline(always)]
1724        fn inline_align(_context: fidl::encoding::Context) -> usize {
1725            4
1726        }
1727
1728        #[inline(always)]
1729        fn inline_size(_context: fidl::encoding::Context) -> usize {
1730            4
1731        }
1732    }
1733
1734    unsafe impl
1735        fidl::encoding::Encode<
1736            MockPeerConnectProxyRequest,
1737            fidl::encoding::DefaultFuchsiaResourceDialect,
1738        > for &mut MockPeerConnectProxyRequest
1739    {
1740        #[inline]
1741        unsafe fn encode(
1742            self,
1743            encoder: &mut fidl::encoding::Encoder<
1744                '_,
1745                fidl::encoding::DefaultFuchsiaResourceDialect,
1746            >,
1747            offset: usize,
1748            _depth: fidl::encoding::Depth,
1749        ) -> fidl::Result<()> {
1750            encoder.debug_check_bounds::<MockPeerConnectProxyRequest>(offset);
1751            // Delegate to tuple encoding.
1752            fidl::encoding::Encode::<
1753                MockPeerConnectProxyRequest,
1754                fidl::encoding::DefaultFuchsiaResourceDialect,
1755            >::encode(
1756                (<fidl::encoding::Endpoint<
1757                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
1758                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1759                    &mut self.interface
1760                ),),
1761                encoder,
1762                offset,
1763                _depth,
1764            )
1765        }
1766    }
1767    unsafe impl<
1768            T0: fidl::encoding::Encode<
1769                fidl::encoding::Endpoint<
1770                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
1771                >,
1772                fidl::encoding::DefaultFuchsiaResourceDialect,
1773            >,
1774        >
1775        fidl::encoding::Encode<
1776            MockPeerConnectProxyRequest,
1777            fidl::encoding::DefaultFuchsiaResourceDialect,
1778        > for (T0,)
1779    {
1780        #[inline]
1781        unsafe fn encode(
1782            self,
1783            encoder: &mut fidl::encoding::Encoder<
1784                '_,
1785                fidl::encoding::DefaultFuchsiaResourceDialect,
1786            >,
1787            offset: usize,
1788            depth: fidl::encoding::Depth,
1789        ) -> fidl::Result<()> {
1790            encoder.debug_check_bounds::<MockPeerConnectProxyRequest>(offset);
1791            // Zero out padding regions. There's no need to apply masks
1792            // because the unmasked parts will be overwritten by fields.
1793            // Write the fields.
1794            self.0.encode(encoder, offset + 0, depth)?;
1795            Ok(())
1796        }
1797    }
1798
1799    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1800        for MockPeerConnectProxyRequest
1801    {
1802        #[inline(always)]
1803        fn new_empty() -> Self {
1804            Self {
1805                interface: fidl::new_empty!(
1806                    fidl::encoding::Endpoint<
1807                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
1808                    >,
1809                    fidl::encoding::DefaultFuchsiaResourceDialect
1810                ),
1811            }
1812        }
1813
1814        #[inline]
1815        unsafe fn decode(
1816            &mut self,
1817            decoder: &mut fidl::encoding::Decoder<
1818                '_,
1819                fidl::encoding::DefaultFuchsiaResourceDialect,
1820            >,
1821            offset: usize,
1822            _depth: fidl::encoding::Depth,
1823        ) -> fidl::Result<()> {
1824            decoder.debug_check_bounds::<Self>(offset);
1825            // Verify that padding bytes are zero.
1826            fidl::decode!(
1827                fidl::encoding::Endpoint<
1828                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
1829                >,
1830                fidl::encoding::DefaultFuchsiaResourceDialect,
1831                &mut self.interface,
1832                decoder,
1833                offset + 0,
1834                _depth
1835            )?;
1836            Ok(())
1837        }
1838    }
1839
1840    impl fidl::encoding::ResourceTypeMarker for ProfileTestRegisterPeerRequest {
1841        type Borrowed<'a> = &'a mut Self;
1842        fn take_or_borrow<'a>(
1843            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1844        ) -> Self::Borrowed<'a> {
1845            value
1846        }
1847    }
1848
1849    unsafe impl fidl::encoding::TypeMarker for ProfileTestRegisterPeerRequest {
1850        type Owned = Self;
1851
1852        #[inline(always)]
1853        fn inline_align(_context: fidl::encoding::Context) -> usize {
1854            8
1855        }
1856
1857        #[inline(always)]
1858        fn inline_size(_context: fidl::encoding::Context) -> usize {
1859            16
1860        }
1861    }
1862
1863    unsafe impl
1864        fidl::encoding::Encode<
1865            ProfileTestRegisterPeerRequest,
1866            fidl::encoding::DefaultFuchsiaResourceDialect,
1867        > for &mut ProfileTestRegisterPeerRequest
1868    {
1869        #[inline]
1870        unsafe fn encode(
1871            self,
1872            encoder: &mut fidl::encoding::Encoder<
1873                '_,
1874                fidl::encoding::DefaultFuchsiaResourceDialect,
1875            >,
1876            offset: usize,
1877            _depth: fidl::encoding::Depth,
1878        ) -> fidl::Result<()> {
1879            encoder.debug_check_bounds::<ProfileTestRegisterPeerRequest>(offset);
1880            // Delegate to tuple encoding.
1881            fidl::encoding::Encode::<ProfileTestRegisterPeerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1882                (
1883                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.peer_id),
1884                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MockPeerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.peer),
1885                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerObserverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.observer),
1886                ),
1887                encoder, offset, _depth
1888            )
1889        }
1890    }
1891    unsafe impl<
1892            T0: fidl::encoding::Encode<
1893                fidl_fuchsia_bluetooth::PeerId,
1894                fidl::encoding::DefaultFuchsiaResourceDialect,
1895            >,
1896            T1: fidl::encoding::Encode<
1897                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MockPeerMarker>>,
1898                fidl::encoding::DefaultFuchsiaResourceDialect,
1899            >,
1900            T2: fidl::encoding::Encode<
1901                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerObserverMarker>>,
1902                fidl::encoding::DefaultFuchsiaResourceDialect,
1903            >,
1904        >
1905        fidl::encoding::Encode<
1906            ProfileTestRegisterPeerRequest,
1907            fidl::encoding::DefaultFuchsiaResourceDialect,
1908        > for (T0, T1, T2)
1909    {
1910        #[inline]
1911        unsafe fn encode(
1912            self,
1913            encoder: &mut fidl::encoding::Encoder<
1914                '_,
1915                fidl::encoding::DefaultFuchsiaResourceDialect,
1916            >,
1917            offset: usize,
1918            depth: fidl::encoding::Depth,
1919        ) -> fidl::Result<()> {
1920            encoder.debug_check_bounds::<ProfileTestRegisterPeerRequest>(offset);
1921            // Zero out padding regions. There's no need to apply masks
1922            // because the unmasked parts will be overwritten by fields.
1923            // Write the fields.
1924            self.0.encode(encoder, offset + 0, depth)?;
1925            self.1.encode(encoder, offset + 8, depth)?;
1926            self.2.encode(encoder, offset + 12, depth)?;
1927            Ok(())
1928        }
1929    }
1930
1931    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1932        for ProfileTestRegisterPeerRequest
1933    {
1934        #[inline(always)]
1935        fn new_empty() -> Self {
1936            Self {
1937                peer_id: fidl::new_empty!(
1938                    fidl_fuchsia_bluetooth::PeerId,
1939                    fidl::encoding::DefaultFuchsiaResourceDialect
1940                ),
1941                peer: fidl::new_empty!(
1942                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MockPeerMarker>>,
1943                    fidl::encoding::DefaultFuchsiaResourceDialect
1944                ),
1945                observer: fidl::new_empty!(
1946                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerObserverMarker>>,
1947                    fidl::encoding::DefaultFuchsiaResourceDialect
1948                ),
1949            }
1950        }
1951
1952        #[inline]
1953        unsafe fn decode(
1954            &mut self,
1955            decoder: &mut fidl::encoding::Decoder<
1956                '_,
1957                fidl::encoding::DefaultFuchsiaResourceDialect,
1958            >,
1959            offset: usize,
1960            _depth: fidl::encoding::Depth,
1961        ) -> fidl::Result<()> {
1962            decoder.debug_check_bounds::<Self>(offset);
1963            // Verify that padding bytes are zero.
1964            fidl::decode!(
1965                fidl_fuchsia_bluetooth::PeerId,
1966                fidl::encoding::DefaultFuchsiaResourceDialect,
1967                &mut self.peer_id,
1968                decoder,
1969                offset + 0,
1970                _depth
1971            )?;
1972            fidl::decode!(
1973                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MockPeerMarker>>,
1974                fidl::encoding::DefaultFuchsiaResourceDialect,
1975                &mut self.peer,
1976                decoder,
1977                offset + 8,
1978                _depth
1979            )?;
1980            fidl::decode!(
1981                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerObserverMarker>>,
1982                fidl::encoding::DefaultFuchsiaResourceDialect,
1983                &mut self.observer,
1984                decoder,
1985                offset + 12,
1986                _depth
1987            )?;
1988            Ok(())
1989        }
1990    }
1991}