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#[derive(Debug, Clone)]
120pub struct ProviderProxy {
121 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
122}
123
124impl fidl::endpoints::Proxy for ProviderProxy {
125 type Protocol = ProviderMarker;
126
127 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
128 Self::new(inner)
129 }
130
131 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
132 self.client.into_channel().map_err(|client| Self { client })
133 }
134
135 fn as_channel(&self) -> &::fidl::AsyncChannel {
136 self.client.as_channel()
137 }
138}
139
140impl ProviderProxy {
141 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
143 let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
144 Self { client: fidl::client::Client::new(channel, protocol_name) }
145 }
146
147 pub fn take_event_stream(&self) -> ProviderEventStream {
153 ProviderEventStream { event_receiver: self.client.take_event_receiver() }
154 }
155
156 pub fn r#enable(
171 &self,
172 mut watcher: fidl::endpoints::ClientEnd<ProviderWatcherMarker>,
173 ) -> fidl::client::QueryResponseFut<
174 ProviderEnableResult,
175 fidl::encoding::DefaultFuchsiaResourceDialect,
176 > {
177 ProviderProxyInterface::r#enable(self, watcher)
178 }
179}
180
181impl ProviderProxyInterface for ProviderProxy {
182 type EnableResponseFut = fidl::client::QueryResponseFut<
183 ProviderEnableResult,
184 fidl::encoding::DefaultFuchsiaResourceDialect,
185 >;
186 fn r#enable(
187 &self,
188 mut watcher: fidl::endpoints::ClientEnd<ProviderWatcherMarker>,
189 ) -> Self::EnableResponseFut {
190 fn _decode(
191 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
192 ) -> Result<ProviderEnableResult, fidl::Error> {
193 let _response = fidl::client::decode_transaction_body::<
194 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
195 fidl::encoding::DefaultFuchsiaResourceDialect,
196 0x141c1c4f3b6645ad,
197 >(_buf?)?;
198 Ok(_response.map(|x| x))
199 }
200 self.client.send_query_and_decode::<ProviderEnableRequest, ProviderEnableResult>(
201 (watcher,),
202 0x141c1c4f3b6645ad,
203 fidl::encoding::DynamicFlags::empty(),
204 _decode,
205 )
206 }
207}
208
209pub struct ProviderEventStream {
210 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
211}
212
213impl std::marker::Unpin for ProviderEventStream {}
214
215impl futures::stream::FusedStream for ProviderEventStream {
216 fn is_terminated(&self) -> bool {
217 self.event_receiver.is_terminated()
218 }
219}
220
221impl futures::Stream for ProviderEventStream {
222 type Item = Result<ProviderEvent, fidl::Error>;
223
224 fn poll_next(
225 mut self: std::pin::Pin<&mut Self>,
226 cx: &mut std::task::Context<'_>,
227 ) -> std::task::Poll<Option<Self::Item>> {
228 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
229 &mut self.event_receiver,
230 cx
231 )?) {
232 Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
233 None => std::task::Poll::Ready(None),
234 }
235 }
236}
237
238#[derive(Debug)]
239pub enum ProviderEvent {}
240
241impl ProviderEvent {
242 fn decode(
244 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
245 ) -> Result<ProviderEvent, fidl::Error> {
246 let (bytes, _handles) = buf.split_mut();
247 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
248 debug_assert_eq!(tx_header.tx_id, 0);
249 match tx_header.ordinal {
250 _ => Err(fidl::Error::UnknownOrdinal {
251 ordinal: tx_header.ordinal,
252 protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
253 }),
254 }
255 }
256}
257
258pub struct ProviderRequestStream {
260 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
261 is_terminated: bool,
262}
263
264impl std::marker::Unpin for ProviderRequestStream {}
265
266impl futures::stream::FusedStream for ProviderRequestStream {
267 fn is_terminated(&self) -> bool {
268 self.is_terminated
269 }
270}
271
272impl fidl::endpoints::RequestStream for ProviderRequestStream {
273 type Protocol = ProviderMarker;
274 type ControlHandle = ProviderControlHandle;
275
276 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
277 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
278 }
279
280 fn control_handle(&self) -> Self::ControlHandle {
281 ProviderControlHandle { inner: self.inner.clone() }
282 }
283
284 fn into_inner(
285 self,
286 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
287 {
288 (self.inner, self.is_terminated)
289 }
290
291 fn from_inner(
292 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
293 is_terminated: bool,
294 ) -> Self {
295 Self { inner, is_terminated }
296 }
297}
298
299impl futures::Stream for ProviderRequestStream {
300 type Item = Result<ProviderRequest, fidl::Error>;
301
302 fn poll_next(
303 mut self: std::pin::Pin<&mut Self>,
304 cx: &mut std::task::Context<'_>,
305 ) -> std::task::Poll<Option<Self::Item>> {
306 let this = &mut *self;
307 if this.inner.check_shutdown(cx) {
308 this.is_terminated = true;
309 return std::task::Poll::Ready(None);
310 }
311 if this.is_terminated {
312 panic!("polled ProviderRequestStream after completion");
313 }
314 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
315 |bytes, handles| {
316 match this.inner.channel().read_etc(cx, bytes, handles) {
317 std::task::Poll::Ready(Ok(())) => {}
318 std::task::Poll::Pending => return std::task::Poll::Pending,
319 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
320 this.is_terminated = true;
321 return std::task::Poll::Ready(None);
322 }
323 std::task::Poll::Ready(Err(e)) => {
324 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
325 e.into(),
326 ))))
327 }
328 }
329
330 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
332
333 std::task::Poll::Ready(Some(match header.ordinal {
334 0x141c1c4f3b6645ad => {
335 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
336 let mut req = fidl::new_empty!(
337 ProviderEnableRequest,
338 fidl::encoding::DefaultFuchsiaResourceDialect
339 );
340 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderEnableRequest>(&header, _body_bytes, handles, &mut req)?;
341 let control_handle = ProviderControlHandle { inner: this.inner.clone() };
342 Ok(ProviderRequest::Enable {
343 watcher: req.watcher,
344
345 responder: ProviderEnableResponder {
346 control_handle: std::mem::ManuallyDrop::new(control_handle),
347 tx_id: header.tx_id,
348 },
349 })
350 }
351 _ => Err(fidl::Error::UnknownOrdinal {
352 ordinal: header.ordinal,
353 protocol_name:
354 <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
355 }),
356 }))
357 },
358 )
359 }
360}
361
362#[derive(Debug)]
364pub enum ProviderRequest {
365 Enable {
380 watcher: fidl::endpoints::ClientEnd<ProviderWatcherMarker>,
381 responder: ProviderEnableResponder,
382 },
383}
384
385impl ProviderRequest {
386 #[allow(irrefutable_let_patterns)]
387 pub fn into_enable(
388 self,
389 ) -> Option<(fidl::endpoints::ClientEnd<ProviderWatcherMarker>, ProviderEnableResponder)> {
390 if let ProviderRequest::Enable { watcher, responder } = self {
391 Some((watcher, responder))
392 } else {
393 None
394 }
395 }
396
397 pub fn method_name(&self) -> &'static str {
399 match *self {
400 ProviderRequest::Enable { .. } => "enable",
401 }
402 }
403}
404
405#[derive(Debug, Clone)]
406pub struct ProviderControlHandle {
407 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
408}
409
410impl fidl::endpoints::ControlHandle for ProviderControlHandle {
411 fn shutdown(&self) {
412 self.inner.shutdown()
413 }
414 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
415 self.inner.shutdown_with_epitaph(status)
416 }
417
418 fn is_closed(&self) -> bool {
419 self.inner.channel().is_closed()
420 }
421 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
422 self.inner.channel().on_closed()
423 }
424
425 #[cfg(target_os = "fuchsia")]
426 fn signal_peer(
427 &self,
428 clear_mask: zx::Signals,
429 set_mask: zx::Signals,
430 ) -> Result<(), zx_status::Status> {
431 use fidl::Peered;
432 self.inner.channel().signal_peer(clear_mask, set_mask)
433 }
434}
435
436impl ProviderControlHandle {}
437
438#[must_use = "FIDL methods require a response to be sent"]
439#[derive(Debug)]
440pub struct ProviderEnableResponder {
441 control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
442 tx_id: u32,
443}
444
445impl std::ops::Drop for ProviderEnableResponder {
449 fn drop(&mut self) {
450 self.control_handle.shutdown();
451 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
453 }
454}
455
456impl fidl::endpoints::Responder for ProviderEnableResponder {
457 type ControlHandle = ProviderControlHandle;
458
459 fn control_handle(&self) -> &ProviderControlHandle {
460 &self.control_handle
461 }
462
463 fn drop_without_shutdown(mut self) {
464 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
466 std::mem::forget(self);
468 }
469}
470
471impl ProviderEnableResponder {
472 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
476 let _result = self.send_raw(result);
477 if _result.is_err() {
478 self.control_handle.shutdown();
479 }
480 self.drop_without_shutdown();
481 _result
482 }
483
484 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
486 let _result = self.send_raw(result);
487 self.drop_without_shutdown();
488 _result
489 }
490
491 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
492 self.control_handle
493 .inner
494 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
495 result,
496 self.tx_id,
497 0x141c1c4f3b6645ad,
498 fidl::encoding::DynamicFlags::empty(),
499 )
500 }
501}
502
503#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
504pub struct ProviderWatcherMarker;
505
506impl fidl::endpoints::ProtocolMarker for ProviderWatcherMarker {
507 type Proxy = ProviderWatcherProxy;
508 type RequestStream = ProviderWatcherRequestStream;
509 #[cfg(target_os = "fuchsia")]
510 type SynchronousProxy = ProviderWatcherSynchronousProxy;
511
512 const DEBUG_NAME: &'static str = "(anonymous) ProviderWatcher";
513}
514
515pub trait ProviderWatcherProxyInterface: Send + Sync {
516 type OnPairingCompleteResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
517 fn r#on_pairing_complete(
518 &self,
519 id: &fidl_fuchsia_bluetooth::PeerId,
520 ) -> Self::OnPairingCompleteResponseFut;
521}
522#[derive(Debug)]
523#[cfg(target_os = "fuchsia")]
524pub struct ProviderWatcherSynchronousProxy {
525 client: fidl::client::sync::Client,
526}
527
528#[cfg(target_os = "fuchsia")]
529impl fidl::endpoints::SynchronousProxy for ProviderWatcherSynchronousProxy {
530 type Proxy = ProviderWatcherProxy;
531 type Protocol = ProviderWatcherMarker;
532
533 fn from_channel(inner: fidl::Channel) -> Self {
534 Self::new(inner)
535 }
536
537 fn into_channel(self) -> fidl::Channel {
538 self.client.into_channel()
539 }
540
541 fn as_channel(&self) -> &fidl::Channel {
542 self.client.as_channel()
543 }
544}
545
546#[cfg(target_os = "fuchsia")]
547impl ProviderWatcherSynchronousProxy {
548 pub fn new(channel: fidl::Channel) -> Self {
549 let protocol_name = <ProviderWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
550 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
551 }
552
553 pub fn into_channel(self) -> fidl::Channel {
554 self.client.into_channel()
555 }
556
557 pub fn wait_for_event(
560 &self,
561 deadline: zx::MonotonicInstant,
562 ) -> Result<ProviderWatcherEvent, fidl::Error> {
563 ProviderWatcherEvent::decode(self.client.wait_for_event(deadline)?)
564 }
565
566 pub fn r#on_pairing_complete(
571 &self,
572 mut id: &fidl_fuchsia_bluetooth::PeerId,
573 ___deadline: zx::MonotonicInstant,
574 ) -> Result<(), fidl::Error> {
575 let _response = self
576 .client
577 .send_query::<ProviderWatcherOnPairingCompleteRequest, fidl::encoding::EmptyPayload>(
578 (id,),
579 0x7a918bb5f1ca3581,
580 fidl::encoding::DynamicFlags::empty(),
581 ___deadline,
582 )?;
583 Ok(_response)
584 }
585}
586
587#[derive(Debug, Clone)]
588pub struct ProviderWatcherProxy {
589 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
590}
591
592impl fidl::endpoints::Proxy for ProviderWatcherProxy {
593 type Protocol = ProviderWatcherMarker;
594
595 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
596 Self::new(inner)
597 }
598
599 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
600 self.client.into_channel().map_err(|client| Self { client })
601 }
602
603 fn as_channel(&self) -> &::fidl::AsyncChannel {
604 self.client.as_channel()
605 }
606}
607
608impl ProviderWatcherProxy {
609 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
611 let protocol_name = <ProviderWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
612 Self { client: fidl::client::Client::new(channel, protocol_name) }
613 }
614
615 pub fn take_event_stream(&self) -> ProviderWatcherEventStream {
621 ProviderWatcherEventStream { event_receiver: self.client.take_event_receiver() }
622 }
623
624 pub fn r#on_pairing_complete(
629 &self,
630 mut id: &fidl_fuchsia_bluetooth::PeerId,
631 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
632 ProviderWatcherProxyInterface::r#on_pairing_complete(self, id)
633 }
634}
635
636impl ProviderWatcherProxyInterface for ProviderWatcherProxy {
637 type OnPairingCompleteResponseFut =
638 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
639 fn r#on_pairing_complete(
640 &self,
641 mut id: &fidl_fuchsia_bluetooth::PeerId,
642 ) -> Self::OnPairingCompleteResponseFut {
643 fn _decode(
644 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
645 ) -> Result<(), fidl::Error> {
646 let _response = fidl::client::decode_transaction_body::<
647 fidl::encoding::EmptyPayload,
648 fidl::encoding::DefaultFuchsiaResourceDialect,
649 0x7a918bb5f1ca3581,
650 >(_buf?)?;
651 Ok(_response)
652 }
653 self.client.send_query_and_decode::<ProviderWatcherOnPairingCompleteRequest, ()>(
654 (id,),
655 0x7a918bb5f1ca3581,
656 fidl::encoding::DynamicFlags::empty(),
657 _decode,
658 )
659 }
660}
661
662pub struct ProviderWatcherEventStream {
663 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
664}
665
666impl std::marker::Unpin for ProviderWatcherEventStream {}
667
668impl futures::stream::FusedStream for ProviderWatcherEventStream {
669 fn is_terminated(&self) -> bool {
670 self.event_receiver.is_terminated()
671 }
672}
673
674impl futures::Stream for ProviderWatcherEventStream {
675 type Item = Result<ProviderWatcherEvent, fidl::Error>;
676
677 fn poll_next(
678 mut self: std::pin::Pin<&mut Self>,
679 cx: &mut std::task::Context<'_>,
680 ) -> std::task::Poll<Option<Self::Item>> {
681 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
682 &mut self.event_receiver,
683 cx
684 )?) {
685 Some(buf) => std::task::Poll::Ready(Some(ProviderWatcherEvent::decode(buf))),
686 None => std::task::Poll::Ready(None),
687 }
688 }
689}
690
691#[derive(Debug)]
692pub enum ProviderWatcherEvent {}
693
694impl ProviderWatcherEvent {
695 fn decode(
697 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
698 ) -> Result<ProviderWatcherEvent, fidl::Error> {
699 let (bytes, _handles) = buf.split_mut();
700 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
701 debug_assert_eq!(tx_header.tx_id, 0);
702 match tx_header.ordinal {
703 _ => Err(fidl::Error::UnknownOrdinal {
704 ordinal: tx_header.ordinal,
705 protocol_name:
706 <ProviderWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
707 }),
708 }
709 }
710}
711
712pub struct ProviderWatcherRequestStream {
714 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
715 is_terminated: bool,
716}
717
718impl std::marker::Unpin for ProviderWatcherRequestStream {}
719
720impl futures::stream::FusedStream for ProviderWatcherRequestStream {
721 fn is_terminated(&self) -> bool {
722 self.is_terminated
723 }
724}
725
726impl fidl::endpoints::RequestStream for ProviderWatcherRequestStream {
727 type Protocol = ProviderWatcherMarker;
728 type ControlHandle = ProviderWatcherControlHandle;
729
730 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
731 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
732 }
733
734 fn control_handle(&self) -> Self::ControlHandle {
735 ProviderWatcherControlHandle { inner: self.inner.clone() }
736 }
737
738 fn into_inner(
739 self,
740 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
741 {
742 (self.inner, self.is_terminated)
743 }
744
745 fn from_inner(
746 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
747 is_terminated: bool,
748 ) -> Self {
749 Self { inner, is_terminated }
750 }
751}
752
753impl futures::Stream for ProviderWatcherRequestStream {
754 type Item = Result<ProviderWatcherRequest, fidl::Error>;
755
756 fn poll_next(
757 mut self: std::pin::Pin<&mut Self>,
758 cx: &mut std::task::Context<'_>,
759 ) -> std::task::Poll<Option<Self::Item>> {
760 let this = &mut *self;
761 if this.inner.check_shutdown(cx) {
762 this.is_terminated = true;
763 return std::task::Poll::Ready(None);
764 }
765 if this.is_terminated {
766 panic!("polled ProviderWatcherRequestStream after completion");
767 }
768 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
769 |bytes, handles| {
770 match this.inner.channel().read_etc(cx, bytes, handles) {
771 std::task::Poll::Ready(Ok(())) => {}
772 std::task::Poll::Pending => return std::task::Poll::Pending,
773 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
774 this.is_terminated = true;
775 return std::task::Poll::Ready(None);
776 }
777 std::task::Poll::Ready(Err(e)) => {
778 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
779 e.into(),
780 ))))
781 }
782 }
783
784 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
786
787 std::task::Poll::Ready(Some(match header.ordinal {
788 0x7a918bb5f1ca3581 => {
789 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
790 let mut req = fidl::new_empty!(
791 ProviderWatcherOnPairingCompleteRequest,
792 fidl::encoding::DefaultFuchsiaResourceDialect
793 );
794 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderWatcherOnPairingCompleteRequest>(&header, _body_bytes, handles, &mut req)?;
795 let control_handle =
796 ProviderWatcherControlHandle { inner: this.inner.clone() };
797 Ok(ProviderWatcherRequest::OnPairingComplete {
798 id: req.id,
799
800 responder: ProviderWatcherOnPairingCompleteResponder {
801 control_handle: std::mem::ManuallyDrop::new(control_handle),
802 tx_id: header.tx_id,
803 },
804 })
805 }
806 _ => Err(fidl::Error::UnknownOrdinal {
807 ordinal: header.ordinal,
808 protocol_name:
809 <ProviderWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
810 }),
811 }))
812 },
813 )
814 }
815}
816
817#[derive(Debug)]
825pub enum ProviderWatcherRequest {
826 OnPairingComplete {
831 id: fidl_fuchsia_bluetooth::PeerId,
832 responder: ProviderWatcherOnPairingCompleteResponder,
833 },
834}
835
836impl ProviderWatcherRequest {
837 #[allow(irrefutable_let_patterns)]
838 pub fn into_on_pairing_complete(
839 self,
840 ) -> Option<(fidl_fuchsia_bluetooth::PeerId, ProviderWatcherOnPairingCompleteResponder)> {
841 if let ProviderWatcherRequest::OnPairingComplete { id, responder } = self {
842 Some((id, responder))
843 } else {
844 None
845 }
846 }
847
848 pub fn method_name(&self) -> &'static str {
850 match *self {
851 ProviderWatcherRequest::OnPairingComplete { .. } => "on_pairing_complete",
852 }
853 }
854}
855
856#[derive(Debug, Clone)]
857pub struct ProviderWatcherControlHandle {
858 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
859}
860
861impl fidl::endpoints::ControlHandle for ProviderWatcherControlHandle {
862 fn shutdown(&self) {
863 self.inner.shutdown()
864 }
865 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
866 self.inner.shutdown_with_epitaph(status)
867 }
868
869 fn is_closed(&self) -> bool {
870 self.inner.channel().is_closed()
871 }
872 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
873 self.inner.channel().on_closed()
874 }
875
876 #[cfg(target_os = "fuchsia")]
877 fn signal_peer(
878 &self,
879 clear_mask: zx::Signals,
880 set_mask: zx::Signals,
881 ) -> Result<(), zx_status::Status> {
882 use fidl::Peered;
883 self.inner.channel().signal_peer(clear_mask, set_mask)
884 }
885}
886
887impl ProviderWatcherControlHandle {}
888
889#[must_use = "FIDL methods require a response to be sent"]
890#[derive(Debug)]
891pub struct ProviderWatcherOnPairingCompleteResponder {
892 control_handle: std::mem::ManuallyDrop<ProviderWatcherControlHandle>,
893 tx_id: u32,
894}
895
896impl std::ops::Drop for ProviderWatcherOnPairingCompleteResponder {
900 fn drop(&mut self) {
901 self.control_handle.shutdown();
902 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
904 }
905}
906
907impl fidl::endpoints::Responder for ProviderWatcherOnPairingCompleteResponder {
908 type ControlHandle = ProviderWatcherControlHandle;
909
910 fn control_handle(&self) -> &ProviderWatcherControlHandle {
911 &self.control_handle
912 }
913
914 fn drop_without_shutdown(mut self) {
915 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
917 std::mem::forget(self);
919 }
920}
921
922impl ProviderWatcherOnPairingCompleteResponder {
923 pub fn send(self) -> Result<(), fidl::Error> {
927 let _result = self.send_raw();
928 if _result.is_err() {
929 self.control_handle.shutdown();
930 }
931 self.drop_without_shutdown();
932 _result
933 }
934
935 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
937 let _result = self.send_raw();
938 self.drop_without_shutdown();
939 _result
940 }
941
942 fn send_raw(&self) -> Result<(), fidl::Error> {
943 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
944 (),
945 self.tx_id,
946 0x7a918bb5f1ca3581,
947 fidl::encoding::DynamicFlags::empty(),
948 )
949 }
950}
951
952mod internal {
953 use super::*;
954
955 impl fidl::encoding::ResourceTypeMarker for ProviderEnableRequest {
956 type Borrowed<'a> = &'a mut Self;
957 fn take_or_borrow<'a>(
958 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
959 ) -> Self::Borrowed<'a> {
960 value
961 }
962 }
963
964 unsafe impl fidl::encoding::TypeMarker for ProviderEnableRequest {
965 type Owned = Self;
966
967 #[inline(always)]
968 fn inline_align(_context: fidl::encoding::Context) -> usize {
969 4
970 }
971
972 #[inline(always)]
973 fn inline_size(_context: fidl::encoding::Context) -> usize {
974 4
975 }
976 }
977
978 unsafe impl
979 fidl::encoding::Encode<ProviderEnableRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
980 for &mut ProviderEnableRequest
981 {
982 #[inline]
983 unsafe fn encode(
984 self,
985 encoder: &mut fidl::encoding::Encoder<
986 '_,
987 fidl::encoding::DefaultFuchsiaResourceDialect,
988 >,
989 offset: usize,
990 _depth: fidl::encoding::Depth,
991 ) -> fidl::Result<()> {
992 encoder.debug_check_bounds::<ProviderEnableRequest>(offset);
993 fidl::encoding::Encode::<ProviderEnableRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
995 (
996 <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
997 ),
998 encoder, offset, _depth
999 )
1000 }
1001 }
1002 unsafe impl<
1003 T0: fidl::encoding::Encode<
1004 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderWatcherMarker>>,
1005 fidl::encoding::DefaultFuchsiaResourceDialect,
1006 >,
1007 >
1008 fidl::encoding::Encode<ProviderEnableRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1009 for (T0,)
1010 {
1011 #[inline]
1012 unsafe fn encode(
1013 self,
1014 encoder: &mut fidl::encoding::Encoder<
1015 '_,
1016 fidl::encoding::DefaultFuchsiaResourceDialect,
1017 >,
1018 offset: usize,
1019 depth: fidl::encoding::Depth,
1020 ) -> fidl::Result<()> {
1021 encoder.debug_check_bounds::<ProviderEnableRequest>(offset);
1022 self.0.encode(encoder, offset + 0, depth)?;
1026 Ok(())
1027 }
1028 }
1029
1030 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1031 for ProviderEnableRequest
1032 {
1033 #[inline(always)]
1034 fn new_empty() -> Self {
1035 Self {
1036 watcher: fidl::new_empty!(
1037 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderWatcherMarker>>,
1038 fidl::encoding::DefaultFuchsiaResourceDialect
1039 ),
1040 }
1041 }
1042
1043 #[inline]
1044 unsafe fn decode(
1045 &mut self,
1046 decoder: &mut fidl::encoding::Decoder<
1047 '_,
1048 fidl::encoding::DefaultFuchsiaResourceDialect,
1049 >,
1050 offset: usize,
1051 _depth: fidl::encoding::Depth,
1052 ) -> fidl::Result<()> {
1053 decoder.debug_check_bounds::<Self>(offset);
1054 fidl::decode!(
1056 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderWatcherMarker>>,
1057 fidl::encoding::DefaultFuchsiaResourceDialect,
1058 &mut self.watcher,
1059 decoder,
1060 offset + 0,
1061 _depth
1062 )?;
1063 Ok(())
1064 }
1065 }
1066}