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_internal_a2dp_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ControllerSuspendRequest {
16 pub peer_id: Option<Box<fidl_fuchsia_bluetooth::PeerId>>,
17 pub token: fidl::endpoints::ServerEnd<StreamSuspenderMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ControllerSuspendRequest {}
21
22#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
23pub struct ControllerMarker;
24
25impl fidl::endpoints::ProtocolMarker for ControllerMarker {
26 type Proxy = ControllerProxy;
27 type RequestStream = ControllerRequestStream;
28 #[cfg(target_os = "fuchsia")]
29 type SynchronousProxy = ControllerSynchronousProxy;
30
31 const DEBUG_NAME: &'static str = "fuchsia.bluetooth.internal.a2dp.Controller";
32}
33impl fidl::endpoints::DiscoverableProtocolMarker for ControllerMarker {}
34
35pub trait ControllerProxyInterface: Send + Sync {
36 type SuspendResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
37 fn r#suspend(
38 &self,
39 peer_id: Option<&fidl_fuchsia_bluetooth::PeerId>,
40 token: fidl::endpoints::ServerEnd<StreamSuspenderMarker>,
41 ) -> Self::SuspendResponseFut;
42}
43#[derive(Debug)]
44#[cfg(target_os = "fuchsia")]
45pub struct ControllerSynchronousProxy {
46 client: fidl::client::sync::Client,
47}
48
49#[cfg(target_os = "fuchsia")]
50impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
51 type Proxy = ControllerProxy;
52 type Protocol = ControllerMarker;
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 ControllerSynchronousProxy {
69 pub fn new(channel: fidl::Channel) -> Self {
70 Self { client: fidl::client::sync::Client::new(channel) }
71 }
72
73 pub fn into_channel(self) -> fidl::Channel {
74 self.client.into_channel()
75 }
76
77 pub fn wait_for_event(
80 &self,
81 deadline: zx::MonotonicInstant,
82 ) -> Result<ControllerEvent, fidl::Error> {
83 ControllerEvent::decode(self.client.wait_for_event::<ControllerMarker>(deadline)?)
84 }
85
86 pub fn r#suspend(
107 &self,
108 mut peer_id: Option<&fidl_fuchsia_bluetooth::PeerId>,
109 mut token: fidl::endpoints::ServerEnd<StreamSuspenderMarker>,
110 ___deadline: zx::MonotonicInstant,
111 ) -> Result<(), fidl::Error> {
112 let _response = self
113 .client
114 .send_query::<ControllerSuspendRequest, fidl::encoding::EmptyPayload, ControllerMarker>(
115 (peer_id, token),
116 0xe68646aaf69cb61,
117 fidl::encoding::DynamicFlags::empty(),
118 ___deadline,
119 )?;
120 Ok(_response)
121 }
122}
123
124#[cfg(target_os = "fuchsia")]
125impl From<ControllerSynchronousProxy> for zx::NullableHandle {
126 fn from(value: ControllerSynchronousProxy) -> Self {
127 value.into_channel().into()
128 }
129}
130
131#[cfg(target_os = "fuchsia")]
132impl From<fidl::Channel> for ControllerSynchronousProxy {
133 fn from(value: fidl::Channel) -> Self {
134 Self::new(value)
135 }
136}
137
138#[cfg(target_os = "fuchsia")]
139impl fidl::endpoints::FromClient for ControllerSynchronousProxy {
140 type Protocol = ControllerMarker;
141
142 fn from_client(value: fidl::endpoints::ClientEnd<ControllerMarker>) -> Self {
143 Self::new(value.into_channel())
144 }
145}
146
147#[derive(Debug, Clone)]
148pub struct ControllerProxy {
149 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
150}
151
152impl fidl::endpoints::Proxy for ControllerProxy {
153 type Protocol = ControllerMarker;
154
155 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
156 Self::new(inner)
157 }
158
159 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
160 self.client.into_channel().map_err(|client| Self { client })
161 }
162
163 fn as_channel(&self) -> &::fidl::AsyncChannel {
164 self.client.as_channel()
165 }
166}
167
168impl ControllerProxy {
169 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
171 let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
172 Self { client: fidl::client::Client::new(channel, protocol_name) }
173 }
174
175 pub fn take_event_stream(&self) -> ControllerEventStream {
181 ControllerEventStream { event_receiver: self.client.take_event_receiver() }
182 }
183
184 pub fn r#suspend(
205 &self,
206 mut peer_id: Option<&fidl_fuchsia_bluetooth::PeerId>,
207 mut token: fidl::endpoints::ServerEnd<StreamSuspenderMarker>,
208 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
209 ControllerProxyInterface::r#suspend(self, peer_id, token)
210 }
211}
212
213impl ControllerProxyInterface for ControllerProxy {
214 type SuspendResponseFut =
215 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
216 fn r#suspend(
217 &self,
218 mut peer_id: Option<&fidl_fuchsia_bluetooth::PeerId>,
219 mut token: fidl::endpoints::ServerEnd<StreamSuspenderMarker>,
220 ) -> Self::SuspendResponseFut {
221 fn _decode(
222 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
223 ) -> Result<(), fidl::Error> {
224 let _response = fidl::client::decode_transaction_body::<
225 fidl::encoding::EmptyPayload,
226 fidl::encoding::DefaultFuchsiaResourceDialect,
227 0xe68646aaf69cb61,
228 >(_buf?)?;
229 Ok(_response)
230 }
231 self.client.send_query_and_decode::<ControllerSuspendRequest, ()>(
232 (peer_id, token),
233 0xe68646aaf69cb61,
234 fidl::encoding::DynamicFlags::empty(),
235 _decode,
236 )
237 }
238}
239
240pub struct ControllerEventStream {
241 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
242}
243
244impl std::marker::Unpin for ControllerEventStream {}
245
246impl futures::stream::FusedStream for ControllerEventStream {
247 fn is_terminated(&self) -> bool {
248 self.event_receiver.is_terminated()
249 }
250}
251
252impl futures::Stream for ControllerEventStream {
253 type Item = Result<ControllerEvent, fidl::Error>;
254
255 fn poll_next(
256 mut self: std::pin::Pin<&mut Self>,
257 cx: &mut std::task::Context<'_>,
258 ) -> std::task::Poll<Option<Self::Item>> {
259 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
260 &mut self.event_receiver,
261 cx
262 )?) {
263 Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
264 None => std::task::Poll::Ready(None),
265 }
266 }
267}
268
269#[derive(Debug)]
270pub enum ControllerEvent {}
271
272impl ControllerEvent {
273 fn decode(
275 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
276 ) -> Result<ControllerEvent, fidl::Error> {
277 let (bytes, _handles) = buf.split_mut();
278 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
279 debug_assert_eq!(tx_header.tx_id, 0);
280 match tx_header.ordinal {
281 _ => Err(fidl::Error::UnknownOrdinal {
282 ordinal: tx_header.ordinal,
283 protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
284 }),
285 }
286 }
287}
288
289pub struct ControllerRequestStream {
291 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
292 is_terminated: bool,
293}
294
295impl std::marker::Unpin for ControllerRequestStream {}
296
297impl futures::stream::FusedStream for ControllerRequestStream {
298 fn is_terminated(&self) -> bool {
299 self.is_terminated
300 }
301}
302
303impl fidl::endpoints::RequestStream for ControllerRequestStream {
304 type Protocol = ControllerMarker;
305 type ControlHandle = ControllerControlHandle;
306
307 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
308 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
309 }
310
311 fn control_handle(&self) -> Self::ControlHandle {
312 ControllerControlHandle { inner: self.inner.clone() }
313 }
314
315 fn into_inner(
316 self,
317 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
318 {
319 (self.inner, self.is_terminated)
320 }
321
322 fn from_inner(
323 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
324 is_terminated: bool,
325 ) -> Self {
326 Self { inner, is_terminated }
327 }
328}
329
330impl futures::Stream for ControllerRequestStream {
331 type Item = Result<ControllerRequest, fidl::Error>;
332
333 fn poll_next(
334 mut self: std::pin::Pin<&mut Self>,
335 cx: &mut std::task::Context<'_>,
336 ) -> std::task::Poll<Option<Self::Item>> {
337 let this = &mut *self;
338 if this.inner.check_shutdown(cx) {
339 this.is_terminated = true;
340 return std::task::Poll::Ready(None);
341 }
342 if this.is_terminated {
343 panic!("polled ControllerRequestStream after completion");
344 }
345 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
346 |bytes, handles| {
347 match this.inner.channel().read_etc(cx, bytes, handles) {
348 std::task::Poll::Ready(Ok(())) => {}
349 std::task::Poll::Pending => return std::task::Poll::Pending,
350 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
351 this.is_terminated = true;
352 return std::task::Poll::Ready(None);
353 }
354 std::task::Poll::Ready(Err(e)) => {
355 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
356 e.into(),
357 ))));
358 }
359 }
360
361 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
363
364 std::task::Poll::Ready(Some(match header.ordinal {
365 0xe68646aaf69cb61 => {
366 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
367 let mut req = fidl::new_empty!(
368 ControllerSuspendRequest,
369 fidl::encoding::DefaultFuchsiaResourceDialect
370 );
371 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerSuspendRequest>(&header, _body_bytes, handles, &mut req)?;
372 let control_handle = ControllerControlHandle { inner: this.inner.clone() };
373 Ok(ControllerRequest::Suspend {
374 peer_id: req.peer_id,
375 token: req.token,
376
377 responder: ControllerSuspendResponder {
378 control_handle: std::mem::ManuallyDrop::new(control_handle),
379 tx_id: header.tx_id,
380 },
381 })
382 }
383 _ => Err(fidl::Error::UnknownOrdinal {
384 ordinal: header.ordinal,
385 protocol_name:
386 <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
387 }),
388 }))
389 },
390 )
391 }
392}
393
394#[derive(Debug)]
396pub enum ControllerRequest {
397 Suspend {
418 peer_id: Option<Box<fidl_fuchsia_bluetooth::PeerId>>,
419 token: fidl::endpoints::ServerEnd<StreamSuspenderMarker>,
420 responder: ControllerSuspendResponder,
421 },
422}
423
424impl ControllerRequest {
425 #[allow(irrefutable_let_patterns)]
426 pub fn into_suspend(
427 self,
428 ) -> Option<(
429 Option<Box<fidl_fuchsia_bluetooth::PeerId>>,
430 fidl::endpoints::ServerEnd<StreamSuspenderMarker>,
431 ControllerSuspendResponder,
432 )> {
433 if let ControllerRequest::Suspend { peer_id, token, responder } = self {
434 Some((peer_id, token, responder))
435 } else {
436 None
437 }
438 }
439
440 pub fn method_name(&self) -> &'static str {
442 match *self {
443 ControllerRequest::Suspend { .. } => "suspend",
444 }
445 }
446}
447
448#[derive(Debug, Clone)]
449pub struct ControllerControlHandle {
450 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
451}
452
453impl ControllerControlHandle {
454 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
455 self.inner.shutdown_with_epitaph(status.into())
456 }
457}
458
459impl fidl::endpoints::ControlHandle for ControllerControlHandle {
460 fn shutdown(&self) {
461 self.inner.shutdown()
462 }
463
464 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
465 self.inner.shutdown_with_epitaph(status)
466 }
467
468 fn is_closed(&self) -> bool {
469 self.inner.channel().is_closed()
470 }
471 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
472 self.inner.channel().on_closed()
473 }
474
475 #[cfg(target_os = "fuchsia")]
476 fn signal_peer(
477 &self,
478 clear_mask: zx::Signals,
479 set_mask: zx::Signals,
480 ) -> Result<(), zx_status::Status> {
481 use fidl::Peered;
482 self.inner.channel().signal_peer(clear_mask, set_mask)
483 }
484}
485
486impl ControllerControlHandle {}
487
488#[must_use = "FIDL methods require a response to be sent"]
489#[derive(Debug)]
490pub struct ControllerSuspendResponder {
491 control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
492 tx_id: u32,
493}
494
495impl std::ops::Drop for ControllerSuspendResponder {
499 fn drop(&mut self) {
500 self.control_handle.shutdown();
501 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
503 }
504}
505
506impl fidl::endpoints::Responder for ControllerSuspendResponder {
507 type ControlHandle = ControllerControlHandle;
508
509 fn control_handle(&self) -> &ControllerControlHandle {
510 &self.control_handle
511 }
512
513 fn drop_without_shutdown(mut self) {
514 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
516 std::mem::forget(self);
518 }
519}
520
521impl ControllerSuspendResponder {
522 pub fn send(self) -> Result<(), fidl::Error> {
526 let _result = self.send_raw();
527 if _result.is_err() {
528 self.control_handle.shutdown();
529 }
530 self.drop_without_shutdown();
531 _result
532 }
533
534 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
536 let _result = self.send_raw();
537 self.drop_without_shutdown();
538 _result
539 }
540
541 fn send_raw(&self) -> Result<(), fidl::Error> {
542 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
543 (),
544 self.tx_id,
545 0xe68646aaf69cb61,
546 fidl::encoding::DynamicFlags::empty(),
547 )
548 }
549}
550
551#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
552pub struct StreamSuspenderMarker;
553
554impl fidl::endpoints::ProtocolMarker for StreamSuspenderMarker {
555 type Proxy = StreamSuspenderProxy;
556 type RequestStream = StreamSuspenderRequestStream;
557 #[cfg(target_os = "fuchsia")]
558 type SynchronousProxy = StreamSuspenderSynchronousProxy;
559
560 const DEBUG_NAME: &'static str = "(anonymous) StreamSuspender";
561}
562
563pub trait StreamSuspenderProxyInterface: Send + Sync {}
564#[derive(Debug)]
565#[cfg(target_os = "fuchsia")]
566pub struct StreamSuspenderSynchronousProxy {
567 client: fidl::client::sync::Client,
568}
569
570#[cfg(target_os = "fuchsia")]
571impl fidl::endpoints::SynchronousProxy for StreamSuspenderSynchronousProxy {
572 type Proxy = StreamSuspenderProxy;
573 type Protocol = StreamSuspenderMarker;
574
575 fn from_channel(inner: fidl::Channel) -> Self {
576 Self::new(inner)
577 }
578
579 fn into_channel(self) -> fidl::Channel {
580 self.client.into_channel()
581 }
582
583 fn as_channel(&self) -> &fidl::Channel {
584 self.client.as_channel()
585 }
586}
587
588#[cfg(target_os = "fuchsia")]
589impl StreamSuspenderSynchronousProxy {
590 pub fn new(channel: fidl::Channel) -> Self {
591 Self { client: fidl::client::sync::Client::new(channel) }
592 }
593
594 pub fn into_channel(self) -> fidl::Channel {
595 self.client.into_channel()
596 }
597
598 pub fn wait_for_event(
601 &self,
602 deadline: zx::MonotonicInstant,
603 ) -> Result<StreamSuspenderEvent, fidl::Error> {
604 StreamSuspenderEvent::decode(self.client.wait_for_event::<StreamSuspenderMarker>(deadline)?)
605 }
606}
607
608#[cfg(target_os = "fuchsia")]
609impl From<StreamSuspenderSynchronousProxy> for zx::NullableHandle {
610 fn from(value: StreamSuspenderSynchronousProxy) -> Self {
611 value.into_channel().into()
612 }
613}
614
615#[cfg(target_os = "fuchsia")]
616impl From<fidl::Channel> for StreamSuspenderSynchronousProxy {
617 fn from(value: fidl::Channel) -> Self {
618 Self::new(value)
619 }
620}
621
622#[cfg(target_os = "fuchsia")]
623impl fidl::endpoints::FromClient for StreamSuspenderSynchronousProxy {
624 type Protocol = StreamSuspenderMarker;
625
626 fn from_client(value: fidl::endpoints::ClientEnd<StreamSuspenderMarker>) -> Self {
627 Self::new(value.into_channel())
628 }
629}
630
631#[derive(Debug, Clone)]
632pub struct StreamSuspenderProxy {
633 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
634}
635
636impl fidl::endpoints::Proxy for StreamSuspenderProxy {
637 type Protocol = StreamSuspenderMarker;
638
639 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
640 Self::new(inner)
641 }
642
643 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
644 self.client.into_channel().map_err(|client| Self { client })
645 }
646
647 fn as_channel(&self) -> &::fidl::AsyncChannel {
648 self.client.as_channel()
649 }
650}
651
652impl StreamSuspenderProxy {
653 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
655 let protocol_name = <StreamSuspenderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
656 Self { client: fidl::client::Client::new(channel, protocol_name) }
657 }
658
659 pub fn take_event_stream(&self) -> StreamSuspenderEventStream {
665 StreamSuspenderEventStream { event_receiver: self.client.take_event_receiver() }
666 }
667}
668
669impl StreamSuspenderProxyInterface for StreamSuspenderProxy {}
670
671pub struct StreamSuspenderEventStream {
672 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
673}
674
675impl std::marker::Unpin for StreamSuspenderEventStream {}
676
677impl futures::stream::FusedStream for StreamSuspenderEventStream {
678 fn is_terminated(&self) -> bool {
679 self.event_receiver.is_terminated()
680 }
681}
682
683impl futures::Stream for StreamSuspenderEventStream {
684 type Item = Result<StreamSuspenderEvent, fidl::Error>;
685
686 fn poll_next(
687 mut self: std::pin::Pin<&mut Self>,
688 cx: &mut std::task::Context<'_>,
689 ) -> std::task::Poll<Option<Self::Item>> {
690 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
691 &mut self.event_receiver,
692 cx
693 )?) {
694 Some(buf) => std::task::Poll::Ready(Some(StreamSuspenderEvent::decode(buf))),
695 None => std::task::Poll::Ready(None),
696 }
697 }
698}
699
700#[derive(Debug)]
701pub enum StreamSuspenderEvent {
702 OnSuspended {},
703}
704
705impl StreamSuspenderEvent {
706 #[allow(irrefutable_let_patterns)]
707 pub fn into_on_suspended(self) -> Option<()> {
708 if let StreamSuspenderEvent::OnSuspended {} = self { Some(()) } else { None }
709 }
710
711 fn decode(
713 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
714 ) -> Result<StreamSuspenderEvent, fidl::Error> {
715 let (bytes, _handles) = buf.split_mut();
716 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
717 debug_assert_eq!(tx_header.tx_id, 0);
718 match tx_header.ordinal {
719 0x3f927abc531cba34 => {
720 let mut out = fidl::new_empty!(
721 fidl::encoding::EmptyPayload,
722 fidl::encoding::DefaultFuchsiaResourceDialect
723 );
724 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
725 Ok((StreamSuspenderEvent::OnSuspended {}))
726 }
727 _ => Err(fidl::Error::UnknownOrdinal {
728 ordinal: tx_header.ordinal,
729 protocol_name:
730 <StreamSuspenderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
731 }),
732 }
733 }
734}
735
736pub struct StreamSuspenderRequestStream {
738 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
739 is_terminated: bool,
740}
741
742impl std::marker::Unpin for StreamSuspenderRequestStream {}
743
744impl futures::stream::FusedStream for StreamSuspenderRequestStream {
745 fn is_terminated(&self) -> bool {
746 self.is_terminated
747 }
748}
749
750impl fidl::endpoints::RequestStream for StreamSuspenderRequestStream {
751 type Protocol = StreamSuspenderMarker;
752 type ControlHandle = StreamSuspenderControlHandle;
753
754 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
755 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
756 }
757
758 fn control_handle(&self) -> Self::ControlHandle {
759 StreamSuspenderControlHandle { inner: self.inner.clone() }
760 }
761
762 fn into_inner(
763 self,
764 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
765 {
766 (self.inner, self.is_terminated)
767 }
768
769 fn from_inner(
770 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
771 is_terminated: bool,
772 ) -> Self {
773 Self { inner, is_terminated }
774 }
775}
776
777impl futures::Stream for StreamSuspenderRequestStream {
778 type Item = Result<StreamSuspenderRequest, fidl::Error>;
779
780 fn poll_next(
781 mut self: std::pin::Pin<&mut Self>,
782 cx: &mut std::task::Context<'_>,
783 ) -> std::task::Poll<Option<Self::Item>> {
784 let this = &mut *self;
785 if this.inner.check_shutdown(cx) {
786 this.is_terminated = true;
787 return std::task::Poll::Ready(None);
788 }
789 if this.is_terminated {
790 panic!("polled StreamSuspenderRequestStream after completion");
791 }
792 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
793 |bytes, handles| {
794 match this.inner.channel().read_etc(cx, bytes, handles) {
795 std::task::Poll::Ready(Ok(())) => {}
796 std::task::Poll::Pending => return std::task::Poll::Pending,
797 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
798 this.is_terminated = true;
799 return std::task::Poll::Ready(None);
800 }
801 std::task::Poll::Ready(Err(e)) => {
802 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
803 e.into(),
804 ))));
805 }
806 }
807
808 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
810
811 std::task::Poll::Ready(Some(match header.ordinal {
812 _ => Err(fidl::Error::UnknownOrdinal {
813 ordinal: header.ordinal,
814 protocol_name:
815 <StreamSuspenderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
816 }),
817 }))
818 },
819 )
820 }
821}
822
823#[derive(Debug)]
825pub enum StreamSuspenderRequest {}
826
827impl StreamSuspenderRequest {
828 pub fn method_name(&self) -> &'static str {
830 match *self {}
831 }
832}
833
834#[derive(Debug, Clone)]
835pub struct StreamSuspenderControlHandle {
836 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
837}
838
839impl StreamSuspenderControlHandle {
840 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
841 self.inner.shutdown_with_epitaph(status.into())
842 }
843}
844
845impl fidl::endpoints::ControlHandle for StreamSuspenderControlHandle {
846 fn shutdown(&self) {
847 self.inner.shutdown()
848 }
849
850 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
851 self.inner.shutdown_with_epitaph(status)
852 }
853
854 fn is_closed(&self) -> bool {
855 self.inner.channel().is_closed()
856 }
857 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
858 self.inner.channel().on_closed()
859 }
860
861 #[cfg(target_os = "fuchsia")]
862 fn signal_peer(
863 &self,
864 clear_mask: zx::Signals,
865 set_mask: zx::Signals,
866 ) -> Result<(), zx_status::Status> {
867 use fidl::Peered;
868 self.inner.channel().signal_peer(clear_mask, set_mask)
869 }
870}
871
872impl StreamSuspenderControlHandle {
873 pub fn send_on_suspended(&self) -> Result<(), fidl::Error> {
874 self.inner.send::<fidl::encoding::EmptyPayload>(
875 (),
876 0,
877 0x3f927abc531cba34,
878 fidl::encoding::DynamicFlags::empty(),
879 )
880 }
881}
882
883mod internal {
884 use super::*;
885
886 impl fidl::encoding::ResourceTypeMarker for ControllerSuspendRequest {
887 type Borrowed<'a> = &'a mut Self;
888 fn take_or_borrow<'a>(
889 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
890 ) -> Self::Borrowed<'a> {
891 value
892 }
893 }
894
895 unsafe impl fidl::encoding::TypeMarker for ControllerSuspendRequest {
896 type Owned = Self;
897
898 #[inline(always)]
899 fn inline_align(_context: fidl::encoding::Context) -> usize {
900 8
901 }
902
903 #[inline(always)]
904 fn inline_size(_context: fidl::encoding::Context) -> usize {
905 16
906 }
907 }
908
909 unsafe impl
910 fidl::encoding::Encode<
911 ControllerSuspendRequest,
912 fidl::encoding::DefaultFuchsiaResourceDialect,
913 > for &mut ControllerSuspendRequest
914 {
915 #[inline]
916 unsafe fn encode(
917 self,
918 encoder: &mut fidl::encoding::Encoder<
919 '_,
920 fidl::encoding::DefaultFuchsiaResourceDialect,
921 >,
922 offset: usize,
923 _depth: fidl::encoding::Depth,
924 ) -> fidl::Result<()> {
925 encoder.debug_check_bounds::<ControllerSuspendRequest>(offset);
926 fidl::encoding::Encode::<ControllerSuspendRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
928 (
929 <fidl::encoding::Boxed<fidl_fuchsia_bluetooth::PeerId> as fidl::encoding::ValueTypeMarker>::borrow(&self.peer_id),
930 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSuspenderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
931 ),
932 encoder, offset, _depth
933 )
934 }
935 }
936 unsafe impl<
937 T0: fidl::encoding::Encode<
938 fidl::encoding::Boxed<fidl_fuchsia_bluetooth::PeerId>,
939 fidl::encoding::DefaultFuchsiaResourceDialect,
940 >,
941 T1: fidl::encoding::Encode<
942 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSuspenderMarker>>,
943 fidl::encoding::DefaultFuchsiaResourceDialect,
944 >,
945 >
946 fidl::encoding::Encode<
947 ControllerSuspendRequest,
948 fidl::encoding::DefaultFuchsiaResourceDialect,
949 > for (T0, T1)
950 {
951 #[inline]
952 unsafe fn encode(
953 self,
954 encoder: &mut fidl::encoding::Encoder<
955 '_,
956 fidl::encoding::DefaultFuchsiaResourceDialect,
957 >,
958 offset: usize,
959 depth: fidl::encoding::Depth,
960 ) -> fidl::Result<()> {
961 encoder.debug_check_bounds::<ControllerSuspendRequest>(offset);
962 unsafe {
965 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
966 (ptr as *mut u64).write_unaligned(0);
967 }
968 self.0.encode(encoder, offset + 0, depth)?;
970 self.1.encode(encoder, offset + 8, depth)?;
971 Ok(())
972 }
973 }
974
975 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
976 for ControllerSuspendRequest
977 {
978 #[inline(always)]
979 fn new_empty() -> Self {
980 Self {
981 peer_id: fidl::new_empty!(
982 fidl::encoding::Boxed<fidl_fuchsia_bluetooth::PeerId>,
983 fidl::encoding::DefaultFuchsiaResourceDialect
984 ),
985 token: fidl::new_empty!(
986 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSuspenderMarker>>,
987 fidl::encoding::DefaultFuchsiaResourceDialect
988 ),
989 }
990 }
991
992 #[inline]
993 unsafe fn decode(
994 &mut self,
995 decoder: &mut fidl::encoding::Decoder<
996 '_,
997 fidl::encoding::DefaultFuchsiaResourceDialect,
998 >,
999 offset: usize,
1000 _depth: fidl::encoding::Depth,
1001 ) -> fidl::Result<()> {
1002 decoder.debug_check_bounds::<Self>(offset);
1003 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
1005 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1006 let mask = 0xffffffff00000000u64;
1007 let maskedval = padval & mask;
1008 if maskedval != 0 {
1009 return Err(fidl::Error::NonZeroPadding {
1010 padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
1011 });
1012 }
1013 fidl::decode!(
1014 fidl::encoding::Boxed<fidl_fuchsia_bluetooth::PeerId>,
1015 fidl::encoding::DefaultFuchsiaResourceDialect,
1016 &mut self.peer_id,
1017 decoder,
1018 offset + 0,
1019 _depth
1020 )?;
1021 fidl::decode!(
1022 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSuspenderMarker>>,
1023 fidl::encoding::DefaultFuchsiaResourceDialect,
1024 &mut self.token,
1025 decoder,
1026 offset + 8,
1027 _depth
1028 )?;
1029 Ok(())
1030 }
1031 }
1032}