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