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