Skip to main content

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