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_fastpair_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ProviderEnableRequest {
16 pub watcher: fidl::endpoints::ClientEnd<ProviderWatcherMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProviderEnableRequest {}
20
21#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
22pub struct ProviderMarker;
23
24impl fidl::endpoints::ProtocolMarker for ProviderMarker {
25 type Proxy = ProviderProxy;
26 type RequestStream = ProviderRequestStream;
27 #[cfg(target_os = "fuchsia")]
28 type SynchronousProxy = ProviderSynchronousProxy;
29
30 const DEBUG_NAME: &'static str = "fuchsia.bluetooth.fastpair.Provider";
31}
32impl fidl::endpoints::DiscoverableProtocolMarker for ProviderMarker {}
33pub type ProviderEnableResult = Result<(), i32>;
34
35pub trait ProviderProxyInterface: Send + Sync {
36 type EnableResponseFut: std::future::Future<Output = Result<ProviderEnableResult, fidl::Error>>
37 + Send;
38 fn r#enable(
39 &self,
40 watcher: fidl::endpoints::ClientEnd<ProviderWatcherMarker>,
41 ) -> Self::EnableResponseFut;
42}
43#[derive(Debug)]
44#[cfg(target_os = "fuchsia")]
45pub struct ProviderSynchronousProxy {
46 client: fidl::client::sync::Client,
47}
48
49#[cfg(target_os = "fuchsia")]
50impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
51 type Proxy = ProviderProxy;
52 type Protocol = ProviderMarker;
53
54 fn from_channel(inner: fidl::Channel) -> Self {
55 Self::new(inner)
56 }
57
58 fn into_channel(self) -> fidl::Channel {
59 self.client.into_channel()
60 }
61
62 fn as_channel(&self) -> &fidl::Channel {
63 self.client.as_channel()
64 }
65}
66
67#[cfg(target_os = "fuchsia")]
68impl ProviderSynchronousProxy {
69 pub fn new(channel: fidl::Channel) -> Self {
70 let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
71 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
72 }
73
74 pub fn into_channel(self) -> fidl::Channel {
75 self.client.into_channel()
76 }
77
78 pub fn wait_for_event(
81 &self,
82 deadline: zx::MonotonicInstant,
83 ) -> Result<ProviderEvent, fidl::Error> {
84 ProviderEvent::decode(self.client.wait_for_event(deadline)?)
85 }
86
87 pub fn r#enable(
102 &self,
103 mut watcher: fidl::endpoints::ClientEnd<ProviderWatcherMarker>,
104 ___deadline: zx::MonotonicInstant,
105 ) -> Result<ProviderEnableResult, fidl::Error> {
106 let _response = self.client.send_query::<
107 ProviderEnableRequest,
108 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
109 >(
110 (watcher,),
111 0x141c1c4f3b6645ad,
112 fidl::encoding::DynamicFlags::empty(),
113 ___deadline,
114 )?;
115 Ok(_response.map(|x| x))
116 }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl From<ProviderSynchronousProxy> for zx::Handle {
121 fn from(value: ProviderSynchronousProxy) -> Self {
122 value.into_channel().into()
123 }
124}
125
126#[cfg(target_os = "fuchsia")]
127impl From<fidl::Channel> for ProviderSynchronousProxy {
128 fn from(value: fidl::Channel) -> Self {
129 Self::new(value)
130 }
131}
132
133#[derive(Debug, Clone)]
134pub struct ProviderProxy {
135 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
136}
137
138impl fidl::endpoints::Proxy for ProviderProxy {
139 type Protocol = ProviderMarker;
140
141 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
142 Self::new(inner)
143 }
144
145 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
146 self.client.into_channel().map_err(|client| Self { client })
147 }
148
149 fn as_channel(&self) -> &::fidl::AsyncChannel {
150 self.client.as_channel()
151 }
152}
153
154impl ProviderProxy {
155 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
157 let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
158 Self { client: fidl::client::Client::new(channel, protocol_name) }
159 }
160
161 pub fn take_event_stream(&self) -> ProviderEventStream {
167 ProviderEventStream { event_receiver: self.client.take_event_receiver() }
168 }
169
170 pub fn r#enable(
185 &self,
186 mut watcher: fidl::endpoints::ClientEnd<ProviderWatcherMarker>,
187 ) -> fidl::client::QueryResponseFut<
188 ProviderEnableResult,
189 fidl::encoding::DefaultFuchsiaResourceDialect,
190 > {
191 ProviderProxyInterface::r#enable(self, watcher)
192 }
193}
194
195impl ProviderProxyInterface for ProviderProxy {
196 type EnableResponseFut = fidl::client::QueryResponseFut<
197 ProviderEnableResult,
198 fidl::encoding::DefaultFuchsiaResourceDialect,
199 >;
200 fn r#enable(
201 &self,
202 mut watcher: fidl::endpoints::ClientEnd<ProviderWatcherMarker>,
203 ) -> Self::EnableResponseFut {
204 fn _decode(
205 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
206 ) -> Result<ProviderEnableResult, fidl::Error> {
207 let _response = fidl::client::decode_transaction_body::<
208 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
209 fidl::encoding::DefaultFuchsiaResourceDialect,
210 0x141c1c4f3b6645ad,
211 >(_buf?)?;
212 Ok(_response.map(|x| x))
213 }
214 self.client.send_query_and_decode::<ProviderEnableRequest, ProviderEnableResult>(
215 (watcher,),
216 0x141c1c4f3b6645ad,
217 fidl::encoding::DynamicFlags::empty(),
218 _decode,
219 )
220 }
221}
222
223pub struct ProviderEventStream {
224 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
225}
226
227impl std::marker::Unpin for ProviderEventStream {}
228
229impl futures::stream::FusedStream for ProviderEventStream {
230 fn is_terminated(&self) -> bool {
231 self.event_receiver.is_terminated()
232 }
233}
234
235impl futures::Stream for ProviderEventStream {
236 type Item = Result<ProviderEvent, fidl::Error>;
237
238 fn poll_next(
239 mut self: std::pin::Pin<&mut Self>,
240 cx: &mut std::task::Context<'_>,
241 ) -> std::task::Poll<Option<Self::Item>> {
242 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
243 &mut self.event_receiver,
244 cx
245 )?) {
246 Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
247 None => std::task::Poll::Ready(None),
248 }
249 }
250}
251
252#[derive(Debug)]
253pub enum ProviderEvent {}
254
255impl ProviderEvent {
256 fn decode(
258 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
259 ) -> Result<ProviderEvent, fidl::Error> {
260 let (bytes, _handles) = buf.split_mut();
261 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
262 debug_assert_eq!(tx_header.tx_id, 0);
263 match tx_header.ordinal {
264 _ => Err(fidl::Error::UnknownOrdinal {
265 ordinal: tx_header.ordinal,
266 protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
267 }),
268 }
269 }
270}
271
272pub struct ProviderRequestStream {
274 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
275 is_terminated: bool,
276}
277
278impl std::marker::Unpin for ProviderRequestStream {}
279
280impl futures::stream::FusedStream for ProviderRequestStream {
281 fn is_terminated(&self) -> bool {
282 self.is_terminated
283 }
284}
285
286impl fidl::endpoints::RequestStream for ProviderRequestStream {
287 type Protocol = ProviderMarker;
288 type ControlHandle = ProviderControlHandle;
289
290 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
291 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
292 }
293
294 fn control_handle(&self) -> Self::ControlHandle {
295 ProviderControlHandle { inner: self.inner.clone() }
296 }
297
298 fn into_inner(
299 self,
300 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
301 {
302 (self.inner, self.is_terminated)
303 }
304
305 fn from_inner(
306 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
307 is_terminated: bool,
308 ) -> Self {
309 Self { inner, is_terminated }
310 }
311}
312
313impl futures::Stream for ProviderRequestStream {
314 type Item = Result<ProviderRequest, fidl::Error>;
315
316 fn poll_next(
317 mut self: std::pin::Pin<&mut Self>,
318 cx: &mut std::task::Context<'_>,
319 ) -> std::task::Poll<Option<Self::Item>> {
320 let this = &mut *self;
321 if this.inner.check_shutdown(cx) {
322 this.is_terminated = true;
323 return std::task::Poll::Ready(None);
324 }
325 if this.is_terminated {
326 panic!("polled ProviderRequestStream after completion");
327 }
328 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
329 |bytes, handles| {
330 match this.inner.channel().read_etc(cx, bytes, handles) {
331 std::task::Poll::Ready(Ok(())) => {}
332 std::task::Poll::Pending => return std::task::Poll::Pending,
333 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
334 this.is_terminated = true;
335 return std::task::Poll::Ready(None);
336 }
337 std::task::Poll::Ready(Err(e)) => {
338 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
339 e.into(),
340 ))))
341 }
342 }
343
344 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
346
347 std::task::Poll::Ready(Some(match header.ordinal {
348 0x141c1c4f3b6645ad => {
349 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
350 let mut req = fidl::new_empty!(
351 ProviderEnableRequest,
352 fidl::encoding::DefaultFuchsiaResourceDialect
353 );
354 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderEnableRequest>(&header, _body_bytes, handles, &mut req)?;
355 let control_handle = ProviderControlHandle { inner: this.inner.clone() };
356 Ok(ProviderRequest::Enable {
357 watcher: req.watcher,
358
359 responder: ProviderEnableResponder {
360 control_handle: std::mem::ManuallyDrop::new(control_handle),
361 tx_id: header.tx_id,
362 },
363 })
364 }
365 _ => Err(fidl::Error::UnknownOrdinal {
366 ordinal: header.ordinal,
367 protocol_name:
368 <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
369 }),
370 }))
371 },
372 )
373 }
374}
375
376#[derive(Debug)]
378pub enum ProviderRequest {
379 Enable {
394 watcher: fidl::endpoints::ClientEnd<ProviderWatcherMarker>,
395 responder: ProviderEnableResponder,
396 },
397}
398
399impl ProviderRequest {
400 #[allow(irrefutable_let_patterns)]
401 pub fn into_enable(
402 self,
403 ) -> Option<(fidl::endpoints::ClientEnd<ProviderWatcherMarker>, ProviderEnableResponder)> {
404 if let ProviderRequest::Enable { watcher, responder } = self {
405 Some((watcher, responder))
406 } else {
407 None
408 }
409 }
410
411 pub fn method_name(&self) -> &'static str {
413 match *self {
414 ProviderRequest::Enable { .. } => "enable",
415 }
416 }
417}
418
419#[derive(Debug, Clone)]
420pub struct ProviderControlHandle {
421 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
422}
423
424impl fidl::endpoints::ControlHandle for ProviderControlHandle {
425 fn shutdown(&self) {
426 self.inner.shutdown()
427 }
428 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
429 self.inner.shutdown_with_epitaph(status)
430 }
431
432 fn is_closed(&self) -> bool {
433 self.inner.channel().is_closed()
434 }
435 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
436 self.inner.channel().on_closed()
437 }
438
439 #[cfg(target_os = "fuchsia")]
440 fn signal_peer(
441 &self,
442 clear_mask: zx::Signals,
443 set_mask: zx::Signals,
444 ) -> Result<(), zx_status::Status> {
445 use fidl::Peered;
446 self.inner.channel().signal_peer(clear_mask, set_mask)
447 }
448}
449
450impl ProviderControlHandle {}
451
452#[must_use = "FIDL methods require a response to be sent"]
453#[derive(Debug)]
454pub struct ProviderEnableResponder {
455 control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
456 tx_id: u32,
457}
458
459impl std::ops::Drop for ProviderEnableResponder {
463 fn drop(&mut self) {
464 self.control_handle.shutdown();
465 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
467 }
468}
469
470impl fidl::endpoints::Responder for ProviderEnableResponder {
471 type ControlHandle = ProviderControlHandle;
472
473 fn control_handle(&self) -> &ProviderControlHandle {
474 &self.control_handle
475 }
476
477 fn drop_without_shutdown(mut self) {
478 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
480 std::mem::forget(self);
482 }
483}
484
485impl ProviderEnableResponder {
486 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
490 let _result = self.send_raw(result);
491 if _result.is_err() {
492 self.control_handle.shutdown();
493 }
494 self.drop_without_shutdown();
495 _result
496 }
497
498 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
500 let _result = self.send_raw(result);
501 self.drop_without_shutdown();
502 _result
503 }
504
505 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
506 self.control_handle
507 .inner
508 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
509 result,
510 self.tx_id,
511 0x141c1c4f3b6645ad,
512 fidl::encoding::DynamicFlags::empty(),
513 )
514 }
515}
516
517#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
518pub struct ProviderWatcherMarker;
519
520impl fidl::endpoints::ProtocolMarker for ProviderWatcherMarker {
521 type Proxy = ProviderWatcherProxy;
522 type RequestStream = ProviderWatcherRequestStream;
523 #[cfg(target_os = "fuchsia")]
524 type SynchronousProxy = ProviderWatcherSynchronousProxy;
525
526 const DEBUG_NAME: &'static str = "(anonymous) ProviderWatcher";
527}
528
529pub trait ProviderWatcherProxyInterface: Send + Sync {
530 type OnPairingCompleteResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
531 fn r#on_pairing_complete(
532 &self,
533 id: &fidl_fuchsia_bluetooth::PeerId,
534 ) -> Self::OnPairingCompleteResponseFut;
535}
536#[derive(Debug)]
537#[cfg(target_os = "fuchsia")]
538pub struct ProviderWatcherSynchronousProxy {
539 client: fidl::client::sync::Client,
540}
541
542#[cfg(target_os = "fuchsia")]
543impl fidl::endpoints::SynchronousProxy for ProviderWatcherSynchronousProxy {
544 type Proxy = ProviderWatcherProxy;
545 type Protocol = ProviderWatcherMarker;
546
547 fn from_channel(inner: fidl::Channel) -> Self {
548 Self::new(inner)
549 }
550
551 fn into_channel(self) -> fidl::Channel {
552 self.client.into_channel()
553 }
554
555 fn as_channel(&self) -> &fidl::Channel {
556 self.client.as_channel()
557 }
558}
559
560#[cfg(target_os = "fuchsia")]
561impl ProviderWatcherSynchronousProxy {
562 pub fn new(channel: fidl::Channel) -> Self {
563 let protocol_name = <ProviderWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
564 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
565 }
566
567 pub fn into_channel(self) -> fidl::Channel {
568 self.client.into_channel()
569 }
570
571 pub fn wait_for_event(
574 &self,
575 deadline: zx::MonotonicInstant,
576 ) -> Result<ProviderWatcherEvent, fidl::Error> {
577 ProviderWatcherEvent::decode(self.client.wait_for_event(deadline)?)
578 }
579
580 pub fn r#on_pairing_complete(
585 &self,
586 mut id: &fidl_fuchsia_bluetooth::PeerId,
587 ___deadline: zx::MonotonicInstant,
588 ) -> Result<(), fidl::Error> {
589 let _response = self
590 .client
591 .send_query::<ProviderWatcherOnPairingCompleteRequest, fidl::encoding::EmptyPayload>(
592 (id,),
593 0x7a918bb5f1ca3581,
594 fidl::encoding::DynamicFlags::empty(),
595 ___deadline,
596 )?;
597 Ok(_response)
598 }
599}
600
601#[cfg(target_os = "fuchsia")]
602impl From<ProviderWatcherSynchronousProxy> for zx::Handle {
603 fn from(value: ProviderWatcherSynchronousProxy) -> Self {
604 value.into_channel().into()
605 }
606}
607
608#[cfg(target_os = "fuchsia")]
609impl From<fidl::Channel> for ProviderWatcherSynchronousProxy {
610 fn from(value: fidl::Channel) -> Self {
611 Self::new(value)
612 }
613}
614
615#[derive(Debug, Clone)]
616pub struct ProviderWatcherProxy {
617 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
618}
619
620impl fidl::endpoints::Proxy for ProviderWatcherProxy {
621 type Protocol = ProviderWatcherMarker;
622
623 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
624 Self::new(inner)
625 }
626
627 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
628 self.client.into_channel().map_err(|client| Self { client })
629 }
630
631 fn as_channel(&self) -> &::fidl::AsyncChannel {
632 self.client.as_channel()
633 }
634}
635
636impl ProviderWatcherProxy {
637 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
639 let protocol_name = <ProviderWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
640 Self { client: fidl::client::Client::new(channel, protocol_name) }
641 }
642
643 pub fn take_event_stream(&self) -> ProviderWatcherEventStream {
649 ProviderWatcherEventStream { event_receiver: self.client.take_event_receiver() }
650 }
651
652 pub fn r#on_pairing_complete(
657 &self,
658 mut id: &fidl_fuchsia_bluetooth::PeerId,
659 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
660 ProviderWatcherProxyInterface::r#on_pairing_complete(self, id)
661 }
662}
663
664impl ProviderWatcherProxyInterface for ProviderWatcherProxy {
665 type OnPairingCompleteResponseFut =
666 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
667 fn r#on_pairing_complete(
668 &self,
669 mut id: &fidl_fuchsia_bluetooth::PeerId,
670 ) -> Self::OnPairingCompleteResponseFut {
671 fn _decode(
672 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
673 ) -> Result<(), fidl::Error> {
674 let _response = fidl::client::decode_transaction_body::<
675 fidl::encoding::EmptyPayload,
676 fidl::encoding::DefaultFuchsiaResourceDialect,
677 0x7a918bb5f1ca3581,
678 >(_buf?)?;
679 Ok(_response)
680 }
681 self.client.send_query_and_decode::<ProviderWatcherOnPairingCompleteRequest, ()>(
682 (id,),
683 0x7a918bb5f1ca3581,
684 fidl::encoding::DynamicFlags::empty(),
685 _decode,
686 )
687 }
688}
689
690pub struct ProviderWatcherEventStream {
691 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
692}
693
694impl std::marker::Unpin for ProviderWatcherEventStream {}
695
696impl futures::stream::FusedStream for ProviderWatcherEventStream {
697 fn is_terminated(&self) -> bool {
698 self.event_receiver.is_terminated()
699 }
700}
701
702impl futures::Stream for ProviderWatcherEventStream {
703 type Item = Result<ProviderWatcherEvent, fidl::Error>;
704
705 fn poll_next(
706 mut self: std::pin::Pin<&mut Self>,
707 cx: &mut std::task::Context<'_>,
708 ) -> std::task::Poll<Option<Self::Item>> {
709 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
710 &mut self.event_receiver,
711 cx
712 )?) {
713 Some(buf) => std::task::Poll::Ready(Some(ProviderWatcherEvent::decode(buf))),
714 None => std::task::Poll::Ready(None),
715 }
716 }
717}
718
719#[derive(Debug)]
720pub enum ProviderWatcherEvent {}
721
722impl ProviderWatcherEvent {
723 fn decode(
725 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
726 ) -> Result<ProviderWatcherEvent, fidl::Error> {
727 let (bytes, _handles) = buf.split_mut();
728 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
729 debug_assert_eq!(tx_header.tx_id, 0);
730 match tx_header.ordinal {
731 _ => Err(fidl::Error::UnknownOrdinal {
732 ordinal: tx_header.ordinal,
733 protocol_name:
734 <ProviderWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
735 }),
736 }
737 }
738}
739
740pub struct ProviderWatcherRequestStream {
742 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
743 is_terminated: bool,
744}
745
746impl std::marker::Unpin for ProviderWatcherRequestStream {}
747
748impl futures::stream::FusedStream for ProviderWatcherRequestStream {
749 fn is_terminated(&self) -> bool {
750 self.is_terminated
751 }
752}
753
754impl fidl::endpoints::RequestStream for ProviderWatcherRequestStream {
755 type Protocol = ProviderWatcherMarker;
756 type ControlHandle = ProviderWatcherControlHandle;
757
758 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
759 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
760 }
761
762 fn control_handle(&self) -> Self::ControlHandle {
763 ProviderWatcherControlHandle { inner: self.inner.clone() }
764 }
765
766 fn into_inner(
767 self,
768 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
769 {
770 (self.inner, self.is_terminated)
771 }
772
773 fn from_inner(
774 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
775 is_terminated: bool,
776 ) -> Self {
777 Self { inner, is_terminated }
778 }
779}
780
781impl futures::Stream for ProviderWatcherRequestStream {
782 type Item = Result<ProviderWatcherRequest, fidl::Error>;
783
784 fn poll_next(
785 mut self: std::pin::Pin<&mut Self>,
786 cx: &mut std::task::Context<'_>,
787 ) -> std::task::Poll<Option<Self::Item>> {
788 let this = &mut *self;
789 if this.inner.check_shutdown(cx) {
790 this.is_terminated = true;
791 return std::task::Poll::Ready(None);
792 }
793 if this.is_terminated {
794 panic!("polled ProviderWatcherRequestStream after completion");
795 }
796 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
797 |bytes, handles| {
798 match this.inner.channel().read_etc(cx, bytes, handles) {
799 std::task::Poll::Ready(Ok(())) => {}
800 std::task::Poll::Pending => return std::task::Poll::Pending,
801 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
802 this.is_terminated = true;
803 return std::task::Poll::Ready(None);
804 }
805 std::task::Poll::Ready(Err(e)) => {
806 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
807 e.into(),
808 ))))
809 }
810 }
811
812 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
814
815 std::task::Poll::Ready(Some(match header.ordinal {
816 0x7a918bb5f1ca3581 => {
817 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
818 let mut req = fidl::new_empty!(
819 ProviderWatcherOnPairingCompleteRequest,
820 fidl::encoding::DefaultFuchsiaResourceDialect
821 );
822 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderWatcherOnPairingCompleteRequest>(&header, _body_bytes, handles, &mut req)?;
823 let control_handle =
824 ProviderWatcherControlHandle { inner: this.inner.clone() };
825 Ok(ProviderWatcherRequest::OnPairingComplete {
826 id: req.id,
827
828 responder: ProviderWatcherOnPairingCompleteResponder {
829 control_handle: std::mem::ManuallyDrop::new(control_handle),
830 tx_id: header.tx_id,
831 },
832 })
833 }
834 _ => Err(fidl::Error::UnknownOrdinal {
835 ordinal: header.ordinal,
836 protocol_name:
837 <ProviderWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
838 }),
839 }))
840 },
841 )
842 }
843}
844
845#[derive(Debug)]
853pub enum ProviderWatcherRequest {
854 OnPairingComplete {
859 id: fidl_fuchsia_bluetooth::PeerId,
860 responder: ProviderWatcherOnPairingCompleteResponder,
861 },
862}
863
864impl ProviderWatcherRequest {
865 #[allow(irrefutable_let_patterns)]
866 pub fn into_on_pairing_complete(
867 self,
868 ) -> Option<(fidl_fuchsia_bluetooth::PeerId, ProviderWatcherOnPairingCompleteResponder)> {
869 if let ProviderWatcherRequest::OnPairingComplete { id, responder } = self {
870 Some((id, responder))
871 } else {
872 None
873 }
874 }
875
876 pub fn method_name(&self) -> &'static str {
878 match *self {
879 ProviderWatcherRequest::OnPairingComplete { .. } => "on_pairing_complete",
880 }
881 }
882}
883
884#[derive(Debug, Clone)]
885pub struct ProviderWatcherControlHandle {
886 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
887}
888
889impl fidl::endpoints::ControlHandle for ProviderWatcherControlHandle {
890 fn shutdown(&self) {
891 self.inner.shutdown()
892 }
893 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
894 self.inner.shutdown_with_epitaph(status)
895 }
896
897 fn is_closed(&self) -> bool {
898 self.inner.channel().is_closed()
899 }
900 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
901 self.inner.channel().on_closed()
902 }
903
904 #[cfg(target_os = "fuchsia")]
905 fn signal_peer(
906 &self,
907 clear_mask: zx::Signals,
908 set_mask: zx::Signals,
909 ) -> Result<(), zx_status::Status> {
910 use fidl::Peered;
911 self.inner.channel().signal_peer(clear_mask, set_mask)
912 }
913}
914
915impl ProviderWatcherControlHandle {}
916
917#[must_use = "FIDL methods require a response to be sent"]
918#[derive(Debug)]
919pub struct ProviderWatcherOnPairingCompleteResponder {
920 control_handle: std::mem::ManuallyDrop<ProviderWatcherControlHandle>,
921 tx_id: u32,
922}
923
924impl std::ops::Drop for ProviderWatcherOnPairingCompleteResponder {
928 fn drop(&mut self) {
929 self.control_handle.shutdown();
930 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
932 }
933}
934
935impl fidl::endpoints::Responder for ProviderWatcherOnPairingCompleteResponder {
936 type ControlHandle = ProviderWatcherControlHandle;
937
938 fn control_handle(&self) -> &ProviderWatcherControlHandle {
939 &self.control_handle
940 }
941
942 fn drop_without_shutdown(mut self) {
943 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
945 std::mem::forget(self);
947 }
948}
949
950impl ProviderWatcherOnPairingCompleteResponder {
951 pub fn send(self) -> Result<(), fidl::Error> {
955 let _result = self.send_raw();
956 if _result.is_err() {
957 self.control_handle.shutdown();
958 }
959 self.drop_without_shutdown();
960 _result
961 }
962
963 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
965 let _result = self.send_raw();
966 self.drop_without_shutdown();
967 _result
968 }
969
970 fn send_raw(&self) -> Result<(), fidl::Error> {
971 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
972 (),
973 self.tx_id,
974 0x7a918bb5f1ca3581,
975 fidl::encoding::DynamicFlags::empty(),
976 )
977 }
978}
979
980mod internal {
981 use super::*;
982
983 impl fidl::encoding::ResourceTypeMarker for ProviderEnableRequest {
984 type Borrowed<'a> = &'a mut Self;
985 fn take_or_borrow<'a>(
986 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
987 ) -> Self::Borrowed<'a> {
988 value
989 }
990 }
991
992 unsafe impl fidl::encoding::TypeMarker for ProviderEnableRequest {
993 type Owned = Self;
994
995 #[inline(always)]
996 fn inline_align(_context: fidl::encoding::Context) -> usize {
997 4
998 }
999
1000 #[inline(always)]
1001 fn inline_size(_context: fidl::encoding::Context) -> usize {
1002 4
1003 }
1004 }
1005
1006 unsafe impl
1007 fidl::encoding::Encode<ProviderEnableRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1008 for &mut ProviderEnableRequest
1009 {
1010 #[inline]
1011 unsafe fn encode(
1012 self,
1013 encoder: &mut fidl::encoding::Encoder<
1014 '_,
1015 fidl::encoding::DefaultFuchsiaResourceDialect,
1016 >,
1017 offset: usize,
1018 _depth: fidl::encoding::Depth,
1019 ) -> fidl::Result<()> {
1020 encoder.debug_check_bounds::<ProviderEnableRequest>(offset);
1021 fidl::encoding::Encode::<ProviderEnableRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1023 (
1024 <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
1025 ),
1026 encoder, offset, _depth
1027 )
1028 }
1029 }
1030 unsafe impl<
1031 T0: fidl::encoding::Encode<
1032 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderWatcherMarker>>,
1033 fidl::encoding::DefaultFuchsiaResourceDialect,
1034 >,
1035 >
1036 fidl::encoding::Encode<ProviderEnableRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1037 for (T0,)
1038 {
1039 #[inline]
1040 unsafe fn encode(
1041 self,
1042 encoder: &mut fidl::encoding::Encoder<
1043 '_,
1044 fidl::encoding::DefaultFuchsiaResourceDialect,
1045 >,
1046 offset: usize,
1047 depth: fidl::encoding::Depth,
1048 ) -> fidl::Result<()> {
1049 encoder.debug_check_bounds::<ProviderEnableRequest>(offset);
1050 self.0.encode(encoder, offset + 0, depth)?;
1054 Ok(())
1055 }
1056 }
1057
1058 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1059 for ProviderEnableRequest
1060 {
1061 #[inline(always)]
1062 fn new_empty() -> Self {
1063 Self {
1064 watcher: fidl::new_empty!(
1065 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderWatcherMarker>>,
1066 fidl::encoding::DefaultFuchsiaResourceDialect
1067 ),
1068 }
1069 }
1070
1071 #[inline]
1072 unsafe fn decode(
1073 &mut self,
1074 decoder: &mut fidl::encoding::Decoder<
1075 '_,
1076 fidl::encoding::DefaultFuchsiaResourceDialect,
1077 >,
1078 offset: usize,
1079 _depth: fidl::encoding::Depth,
1080 ) -> fidl::Result<()> {
1081 decoder.debug_check_bounds::<Self>(offset);
1082 fidl::decode!(
1084 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderWatcherMarker>>,
1085 fidl::encoding::DefaultFuchsiaResourceDialect,
1086 &mut self.watcher,
1087 decoder,
1088 offset + 0,
1089 _depth
1090 )?;
1091 Ok(())
1092 }
1093 }
1094}