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