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_example_power_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct MessageSourceReceiveMessagesRequest {
16 pub socket: fidl::Socket,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20 for MessageSourceReceiveMessagesRequest
21{
22}
23
24#[derive(Debug, Default, PartialEq)]
25pub struct LeaseBaton {
26 pub lease: Option<fidl::EventPair>,
27 pub msg_index: Option<u64>,
28 #[doc(hidden)]
29 pub __source_breaking: fidl::marker::SourceBreaking,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LeaseBaton {}
33
34#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
35pub struct CounterMarker;
36
37impl fidl::endpoints::ProtocolMarker for CounterMarker {
38 type Proxy = CounterProxy;
39 type RequestStream = CounterRequestStream;
40 #[cfg(target_os = "fuchsia")]
41 type SynchronousProxy = CounterSynchronousProxy;
42
43 const DEBUG_NAME: &'static str = "fuchsia.example.power.Counter";
44}
45impl fidl::endpoints::DiscoverableProtocolMarker for CounterMarker {}
46
47pub trait CounterProxyInterface: Send + Sync {
48 type GetResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
49 fn r#get(&self) -> Self::GetResponseFut;
50}
51#[derive(Debug)]
52#[cfg(target_os = "fuchsia")]
53pub struct CounterSynchronousProxy {
54 client: fidl::client::sync::Client,
55}
56
57#[cfg(target_os = "fuchsia")]
58impl fidl::endpoints::SynchronousProxy for CounterSynchronousProxy {
59 type Proxy = CounterProxy;
60 type Protocol = CounterMarker;
61
62 fn from_channel(inner: fidl::Channel) -> Self {
63 Self::new(inner)
64 }
65
66 fn into_channel(self) -> fidl::Channel {
67 self.client.into_channel()
68 }
69
70 fn as_channel(&self) -> &fidl::Channel {
71 self.client.as_channel()
72 }
73}
74
75#[cfg(target_os = "fuchsia")]
76impl CounterSynchronousProxy {
77 pub fn new(channel: fidl::Channel) -> Self {
78 Self { client: fidl::client::sync::Client::new(channel) }
79 }
80
81 pub fn into_channel(self) -> fidl::Channel {
82 self.client.into_channel()
83 }
84
85 pub fn wait_for_event(
88 &self,
89 deadline: zx::MonotonicInstant,
90 ) -> Result<CounterEvent, fidl::Error> {
91 CounterEvent::decode(self.client.wait_for_event::<CounterMarker>(deadline)?)
92 }
93
94 pub fn r#get(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
95 let _response = self
96 .client
97 .send_query::<fidl::encoding::EmptyPayload, CounterGetResponse, CounterMarker>(
98 (),
99 0x3944f6d91c5b8ad8,
100 fidl::encoding::DynamicFlags::empty(),
101 ___deadline,
102 )?;
103 Ok(_response.count)
104 }
105}
106
107#[cfg(target_os = "fuchsia")]
108impl From<CounterSynchronousProxy> for zx::NullableHandle {
109 fn from(value: CounterSynchronousProxy) -> Self {
110 value.into_channel().into()
111 }
112}
113
114#[cfg(target_os = "fuchsia")]
115impl From<fidl::Channel> for CounterSynchronousProxy {
116 fn from(value: fidl::Channel) -> Self {
117 Self::new(value)
118 }
119}
120
121#[cfg(target_os = "fuchsia")]
122impl fidl::endpoints::FromClient for CounterSynchronousProxy {
123 type Protocol = CounterMarker;
124
125 fn from_client(value: fidl::endpoints::ClientEnd<CounterMarker>) -> Self {
126 Self::new(value.into_channel())
127 }
128}
129
130#[derive(Debug, Clone)]
131pub struct CounterProxy {
132 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
133}
134
135impl fidl::endpoints::Proxy for CounterProxy {
136 type Protocol = CounterMarker;
137
138 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
139 Self::new(inner)
140 }
141
142 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
143 self.client.into_channel().map_err(|client| Self { client })
144 }
145
146 fn as_channel(&self) -> &::fidl::AsyncChannel {
147 self.client.as_channel()
148 }
149}
150
151impl CounterProxy {
152 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
154 let protocol_name = <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
155 Self { client: fidl::client::Client::new(channel, protocol_name) }
156 }
157
158 pub fn take_event_stream(&self) -> CounterEventStream {
164 CounterEventStream { event_receiver: self.client.take_event_receiver() }
165 }
166
167 pub fn r#get(
168 &self,
169 ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
170 CounterProxyInterface::r#get(self)
171 }
172}
173
174impl CounterProxyInterface for CounterProxy {
175 type GetResponseFut =
176 fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
177 fn r#get(&self) -> Self::GetResponseFut {
178 fn _decode(
179 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
180 ) -> Result<u64, fidl::Error> {
181 let _response = fidl::client::decode_transaction_body::<
182 CounterGetResponse,
183 fidl::encoding::DefaultFuchsiaResourceDialect,
184 0x3944f6d91c5b8ad8,
185 >(_buf?)?;
186 Ok(_response.count)
187 }
188 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
189 (),
190 0x3944f6d91c5b8ad8,
191 fidl::encoding::DynamicFlags::empty(),
192 _decode,
193 )
194 }
195}
196
197pub struct CounterEventStream {
198 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
199}
200
201impl std::marker::Unpin for CounterEventStream {}
202
203impl futures::stream::FusedStream for CounterEventStream {
204 fn is_terminated(&self) -> bool {
205 self.event_receiver.is_terminated()
206 }
207}
208
209impl futures::Stream for CounterEventStream {
210 type Item = Result<CounterEvent, fidl::Error>;
211
212 fn poll_next(
213 mut self: std::pin::Pin<&mut Self>,
214 cx: &mut std::task::Context<'_>,
215 ) -> std::task::Poll<Option<Self::Item>> {
216 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
217 &mut self.event_receiver,
218 cx
219 )?) {
220 Some(buf) => std::task::Poll::Ready(Some(CounterEvent::decode(buf))),
221 None => std::task::Poll::Ready(None),
222 }
223 }
224}
225
226#[derive(Debug)]
227pub enum CounterEvent {}
228
229impl CounterEvent {
230 fn decode(
232 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
233 ) -> Result<CounterEvent, fidl::Error> {
234 let (bytes, _handles) = buf.split_mut();
235 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
236 debug_assert_eq!(tx_header.tx_id, 0);
237 match tx_header.ordinal {
238 _ => Err(fidl::Error::UnknownOrdinal {
239 ordinal: tx_header.ordinal,
240 protocol_name: <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
241 }),
242 }
243 }
244}
245
246pub struct CounterRequestStream {
248 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
249 is_terminated: bool,
250}
251
252impl std::marker::Unpin for CounterRequestStream {}
253
254impl futures::stream::FusedStream for CounterRequestStream {
255 fn is_terminated(&self) -> bool {
256 self.is_terminated
257 }
258}
259
260impl fidl::endpoints::RequestStream for CounterRequestStream {
261 type Protocol = CounterMarker;
262 type ControlHandle = CounterControlHandle;
263
264 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
265 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
266 }
267
268 fn control_handle(&self) -> Self::ControlHandle {
269 CounterControlHandle { inner: self.inner.clone() }
270 }
271
272 fn into_inner(
273 self,
274 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
275 {
276 (self.inner, self.is_terminated)
277 }
278
279 fn from_inner(
280 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
281 is_terminated: bool,
282 ) -> Self {
283 Self { inner, is_terminated }
284 }
285}
286
287impl futures::Stream for CounterRequestStream {
288 type Item = Result<CounterRequest, fidl::Error>;
289
290 fn poll_next(
291 mut self: std::pin::Pin<&mut Self>,
292 cx: &mut std::task::Context<'_>,
293 ) -> std::task::Poll<Option<Self::Item>> {
294 let this = &mut *self;
295 if this.inner.check_shutdown(cx) {
296 this.is_terminated = true;
297 return std::task::Poll::Ready(None);
298 }
299 if this.is_terminated {
300 panic!("polled CounterRequestStream after completion");
301 }
302 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
303 |bytes, handles| {
304 match this.inner.channel().read_etc(cx, bytes, handles) {
305 std::task::Poll::Ready(Ok(())) => {}
306 std::task::Poll::Pending => return std::task::Poll::Pending,
307 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
308 this.is_terminated = true;
309 return std::task::Poll::Ready(None);
310 }
311 std::task::Poll::Ready(Err(e)) => {
312 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
313 e.into(),
314 ))));
315 }
316 }
317
318 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
320
321 std::task::Poll::Ready(Some(match header.ordinal {
322 0x3944f6d91c5b8ad8 => {
323 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
324 let mut req = fidl::new_empty!(
325 fidl::encoding::EmptyPayload,
326 fidl::encoding::DefaultFuchsiaResourceDialect
327 );
328 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
329 let control_handle = CounterControlHandle { inner: this.inner.clone() };
330 Ok(CounterRequest::Get {
331 responder: CounterGetResponder {
332 control_handle: std::mem::ManuallyDrop::new(control_handle),
333 tx_id: header.tx_id,
334 },
335 })
336 }
337 _ => Err(fidl::Error::UnknownOrdinal {
338 ordinal: header.ordinal,
339 protocol_name:
340 <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
341 }),
342 }))
343 },
344 )
345 }
346}
347
348#[derive(Debug)]
349pub enum CounterRequest {
350 Get { responder: CounterGetResponder },
351}
352
353impl CounterRequest {
354 #[allow(irrefutable_let_patterns)]
355 pub fn into_get(self) -> Option<(CounterGetResponder)> {
356 if let CounterRequest::Get { responder } = self { Some((responder)) } else { None }
357 }
358
359 pub fn method_name(&self) -> &'static str {
361 match *self {
362 CounterRequest::Get { .. } => "get",
363 }
364 }
365}
366
367#[derive(Debug, Clone)]
368pub struct CounterControlHandle {
369 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
370}
371
372impl CounterControlHandle {
373 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
374 self.inner.shutdown_with_epitaph(status.into())
375 }
376}
377
378impl fidl::endpoints::ControlHandle for CounterControlHandle {
379 fn shutdown(&self) {
380 self.inner.shutdown()
381 }
382
383 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
384 self.inner.shutdown_with_epitaph(status)
385 }
386
387 fn is_closed(&self) -> bool {
388 self.inner.channel().is_closed()
389 }
390 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
391 self.inner.channel().on_closed()
392 }
393
394 #[cfg(target_os = "fuchsia")]
395 fn signal_peer(
396 &self,
397 clear_mask: zx::Signals,
398 set_mask: zx::Signals,
399 ) -> Result<(), zx_status::Status> {
400 use fidl::Peered;
401 self.inner.channel().signal_peer(clear_mask, set_mask)
402 }
403}
404
405impl CounterControlHandle {}
406
407#[must_use = "FIDL methods require a response to be sent"]
408#[derive(Debug)]
409pub struct CounterGetResponder {
410 control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
411 tx_id: u32,
412}
413
414impl std::ops::Drop for CounterGetResponder {
418 fn drop(&mut self) {
419 self.control_handle.shutdown();
420 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
422 }
423}
424
425impl fidl::endpoints::Responder for CounterGetResponder {
426 type ControlHandle = CounterControlHandle;
427
428 fn control_handle(&self) -> &CounterControlHandle {
429 &self.control_handle
430 }
431
432 fn drop_without_shutdown(mut self) {
433 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
435 std::mem::forget(self);
437 }
438}
439
440impl CounterGetResponder {
441 pub fn send(self, mut count: u64) -> Result<(), fidl::Error> {
445 let _result = self.send_raw(count);
446 if _result.is_err() {
447 self.control_handle.shutdown();
448 }
449 self.drop_without_shutdown();
450 _result
451 }
452
453 pub fn send_no_shutdown_on_err(self, mut count: u64) -> Result<(), fidl::Error> {
455 let _result = self.send_raw(count);
456 self.drop_without_shutdown();
457 _result
458 }
459
460 fn send_raw(&self, mut count: u64) -> Result<(), fidl::Error> {
461 self.control_handle.inner.send::<CounterGetResponse>(
462 (count,),
463 self.tx_id,
464 0x3944f6d91c5b8ad8,
465 fidl::encoding::DynamicFlags::empty(),
466 )
467 }
468}
469
470#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
471pub struct FrameControlMarker;
472
473impl fidl::endpoints::ProtocolMarker for FrameControlMarker {
474 type Proxy = FrameControlProxy;
475 type RequestStream = FrameControlRequestStream;
476 #[cfg(target_os = "fuchsia")]
477 type SynchronousProxy = FrameControlSynchronousProxy;
478
479 const DEBUG_NAME: &'static str = "fuchsia.example.power.FrameControl";
480}
481impl fidl::endpoints::DiscoverableProtocolMarker for FrameControlMarker {}
482
483pub trait FrameControlProxyInterface: Send + Sync {
484 type StartFrameResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
485 fn r#start_frame(
486 &self,
487 duration_ms: u16,
488 rate_change_offset_ms: u16,
489 ) -> Self::StartFrameResponseFut;
490}
491#[derive(Debug)]
492#[cfg(target_os = "fuchsia")]
493pub struct FrameControlSynchronousProxy {
494 client: fidl::client::sync::Client,
495}
496
497#[cfg(target_os = "fuchsia")]
498impl fidl::endpoints::SynchronousProxy for FrameControlSynchronousProxy {
499 type Proxy = FrameControlProxy;
500 type Protocol = FrameControlMarker;
501
502 fn from_channel(inner: fidl::Channel) -> Self {
503 Self::new(inner)
504 }
505
506 fn into_channel(self) -> fidl::Channel {
507 self.client.into_channel()
508 }
509
510 fn as_channel(&self) -> &fidl::Channel {
511 self.client.as_channel()
512 }
513}
514
515#[cfg(target_os = "fuchsia")]
516impl FrameControlSynchronousProxy {
517 pub fn new(channel: fidl::Channel) -> Self {
518 Self { client: fidl::client::sync::Client::new(channel) }
519 }
520
521 pub fn into_channel(self) -> fidl::Channel {
522 self.client.into_channel()
523 }
524
525 pub fn wait_for_event(
528 &self,
529 deadline: zx::MonotonicInstant,
530 ) -> Result<FrameControlEvent, fidl::Error> {
531 FrameControlEvent::decode(self.client.wait_for_event::<FrameControlMarker>(deadline)?)
532 }
533
534 pub fn r#start_frame(
535 &self,
536 mut duration_ms: u16,
537 mut rate_change_offset_ms: u16,
538 ___deadline: zx::MonotonicInstant,
539 ) -> Result<(), fidl::Error> {
540 let _response = self.client.send_query::<
541 FrameControlStartFrameRequest,
542 fidl::encoding::EmptyPayload,
543 FrameControlMarker,
544 >(
545 (duration_ms, rate_change_offset_ms,),
546 0x187c1cc46de29b5e,
547 fidl::encoding::DynamicFlags::empty(),
548 ___deadline,
549 )?;
550 Ok(_response)
551 }
552}
553
554#[cfg(target_os = "fuchsia")]
555impl From<FrameControlSynchronousProxy> for zx::NullableHandle {
556 fn from(value: FrameControlSynchronousProxy) -> Self {
557 value.into_channel().into()
558 }
559}
560
561#[cfg(target_os = "fuchsia")]
562impl From<fidl::Channel> for FrameControlSynchronousProxy {
563 fn from(value: fidl::Channel) -> Self {
564 Self::new(value)
565 }
566}
567
568#[cfg(target_os = "fuchsia")]
569impl fidl::endpoints::FromClient for FrameControlSynchronousProxy {
570 type Protocol = FrameControlMarker;
571
572 fn from_client(value: fidl::endpoints::ClientEnd<FrameControlMarker>) -> Self {
573 Self::new(value.into_channel())
574 }
575}
576
577#[derive(Debug, Clone)]
578pub struct FrameControlProxy {
579 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
580}
581
582impl fidl::endpoints::Proxy for FrameControlProxy {
583 type Protocol = FrameControlMarker;
584
585 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
586 Self::new(inner)
587 }
588
589 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
590 self.client.into_channel().map_err(|client| Self { client })
591 }
592
593 fn as_channel(&self) -> &::fidl::AsyncChannel {
594 self.client.as_channel()
595 }
596}
597
598impl FrameControlProxy {
599 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
601 let protocol_name = <FrameControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
602 Self { client: fidl::client::Client::new(channel, protocol_name) }
603 }
604
605 pub fn take_event_stream(&self) -> FrameControlEventStream {
611 FrameControlEventStream { event_receiver: self.client.take_event_receiver() }
612 }
613
614 pub fn r#start_frame(
615 &self,
616 mut duration_ms: u16,
617 mut rate_change_offset_ms: u16,
618 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
619 FrameControlProxyInterface::r#start_frame(self, duration_ms, rate_change_offset_ms)
620 }
621}
622
623impl FrameControlProxyInterface for FrameControlProxy {
624 type StartFrameResponseFut =
625 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
626 fn r#start_frame(
627 &self,
628 mut duration_ms: u16,
629 mut rate_change_offset_ms: u16,
630 ) -> Self::StartFrameResponseFut {
631 fn _decode(
632 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
633 ) -> Result<(), fidl::Error> {
634 let _response = fidl::client::decode_transaction_body::<
635 fidl::encoding::EmptyPayload,
636 fidl::encoding::DefaultFuchsiaResourceDialect,
637 0x187c1cc46de29b5e,
638 >(_buf?)?;
639 Ok(_response)
640 }
641 self.client.send_query_and_decode::<FrameControlStartFrameRequest, ()>(
642 (duration_ms, rate_change_offset_ms),
643 0x187c1cc46de29b5e,
644 fidl::encoding::DynamicFlags::empty(),
645 _decode,
646 )
647 }
648}
649
650pub struct FrameControlEventStream {
651 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
652}
653
654impl std::marker::Unpin for FrameControlEventStream {}
655
656impl futures::stream::FusedStream for FrameControlEventStream {
657 fn is_terminated(&self) -> bool {
658 self.event_receiver.is_terminated()
659 }
660}
661
662impl futures::Stream for FrameControlEventStream {
663 type Item = Result<FrameControlEvent, fidl::Error>;
664
665 fn poll_next(
666 mut self: std::pin::Pin<&mut Self>,
667 cx: &mut std::task::Context<'_>,
668 ) -> std::task::Poll<Option<Self::Item>> {
669 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
670 &mut self.event_receiver,
671 cx
672 )?) {
673 Some(buf) => std::task::Poll::Ready(Some(FrameControlEvent::decode(buf))),
674 None => std::task::Poll::Ready(None),
675 }
676 }
677}
678
679#[derive(Debug)]
680pub enum FrameControlEvent {}
681
682impl FrameControlEvent {
683 fn decode(
685 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
686 ) -> Result<FrameControlEvent, fidl::Error> {
687 let (bytes, _handles) = buf.split_mut();
688 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
689 debug_assert_eq!(tx_header.tx_id, 0);
690 match tx_header.ordinal {
691 _ => Err(fidl::Error::UnknownOrdinal {
692 ordinal: tx_header.ordinal,
693 protocol_name: <FrameControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
694 }),
695 }
696 }
697}
698
699pub struct FrameControlRequestStream {
701 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
702 is_terminated: bool,
703}
704
705impl std::marker::Unpin for FrameControlRequestStream {}
706
707impl futures::stream::FusedStream for FrameControlRequestStream {
708 fn is_terminated(&self) -> bool {
709 self.is_terminated
710 }
711}
712
713impl fidl::endpoints::RequestStream for FrameControlRequestStream {
714 type Protocol = FrameControlMarker;
715 type ControlHandle = FrameControlControlHandle;
716
717 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
718 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
719 }
720
721 fn control_handle(&self) -> Self::ControlHandle {
722 FrameControlControlHandle { inner: self.inner.clone() }
723 }
724
725 fn into_inner(
726 self,
727 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
728 {
729 (self.inner, self.is_terminated)
730 }
731
732 fn from_inner(
733 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
734 is_terminated: bool,
735 ) -> Self {
736 Self { inner, is_terminated }
737 }
738}
739
740impl futures::Stream for FrameControlRequestStream {
741 type Item = Result<FrameControlRequest, fidl::Error>;
742
743 fn poll_next(
744 mut self: std::pin::Pin<&mut Self>,
745 cx: &mut std::task::Context<'_>,
746 ) -> std::task::Poll<Option<Self::Item>> {
747 let this = &mut *self;
748 if this.inner.check_shutdown(cx) {
749 this.is_terminated = true;
750 return std::task::Poll::Ready(None);
751 }
752 if this.is_terminated {
753 panic!("polled FrameControlRequestStream after completion");
754 }
755 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
756 |bytes, handles| {
757 match this.inner.channel().read_etc(cx, bytes, handles) {
758 std::task::Poll::Ready(Ok(())) => {}
759 std::task::Poll::Pending => return std::task::Poll::Pending,
760 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
761 this.is_terminated = true;
762 return std::task::Poll::Ready(None);
763 }
764 std::task::Poll::Ready(Err(e)) => {
765 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
766 e.into(),
767 ))));
768 }
769 }
770
771 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
773
774 std::task::Poll::Ready(Some(match header.ordinal {
775 0x187c1cc46de29b5e => {
776 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
777 let mut req = fidl::new_empty!(
778 FrameControlStartFrameRequest,
779 fidl::encoding::DefaultFuchsiaResourceDialect
780 );
781 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FrameControlStartFrameRequest>(&header, _body_bytes, handles, &mut req)?;
782 let control_handle =
783 FrameControlControlHandle { inner: this.inner.clone() };
784 Ok(FrameControlRequest::StartFrame {
785 duration_ms: req.duration_ms,
786 rate_change_offset_ms: req.rate_change_offset_ms,
787
788 responder: FrameControlStartFrameResponder {
789 control_handle: std::mem::ManuallyDrop::new(control_handle),
790 tx_id: header.tx_id,
791 },
792 })
793 }
794 _ => Err(fidl::Error::UnknownOrdinal {
795 ordinal: header.ordinal,
796 protocol_name:
797 <FrameControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
798 }),
799 }))
800 },
801 )
802 }
803}
804
805#[derive(Debug)]
806pub enum FrameControlRequest {
807 StartFrame {
808 duration_ms: u16,
809 rate_change_offset_ms: u16,
810 responder: FrameControlStartFrameResponder,
811 },
812}
813
814impl FrameControlRequest {
815 #[allow(irrefutable_let_patterns)]
816 pub fn into_start_frame(self) -> Option<(u16, u16, FrameControlStartFrameResponder)> {
817 if let FrameControlRequest::StartFrame { duration_ms, rate_change_offset_ms, responder } =
818 self
819 {
820 Some((duration_ms, rate_change_offset_ms, responder))
821 } else {
822 None
823 }
824 }
825
826 pub fn method_name(&self) -> &'static str {
828 match *self {
829 FrameControlRequest::StartFrame { .. } => "start_frame",
830 }
831 }
832}
833
834#[derive(Debug, Clone)]
835pub struct FrameControlControlHandle {
836 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
837}
838
839impl FrameControlControlHandle {
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 FrameControlControlHandle {
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 FrameControlControlHandle {}
873
874#[must_use = "FIDL methods require a response to be sent"]
875#[derive(Debug)]
876pub struct FrameControlStartFrameResponder {
877 control_handle: std::mem::ManuallyDrop<FrameControlControlHandle>,
878 tx_id: u32,
879}
880
881impl std::ops::Drop for FrameControlStartFrameResponder {
885 fn drop(&mut self) {
886 self.control_handle.shutdown();
887 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
889 }
890}
891
892impl fidl::endpoints::Responder for FrameControlStartFrameResponder {
893 type ControlHandle = FrameControlControlHandle;
894
895 fn control_handle(&self) -> &FrameControlControlHandle {
896 &self.control_handle
897 }
898
899 fn drop_without_shutdown(mut self) {
900 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
902 std::mem::forget(self);
904 }
905}
906
907impl FrameControlStartFrameResponder {
908 pub fn send(self) -> Result<(), fidl::Error> {
912 let _result = self.send_raw();
913 if _result.is_err() {
914 self.control_handle.shutdown();
915 }
916 self.drop_without_shutdown();
917 _result
918 }
919
920 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
922 let _result = self.send_raw();
923 self.drop_without_shutdown();
924 _result
925 }
926
927 fn send_raw(&self) -> Result<(), fidl::Error> {
928 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
929 (),
930 self.tx_id,
931 0x187c1cc46de29b5e,
932 fidl::encoding::DynamicFlags::empty(),
933 )
934 }
935}
936
937#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
938pub struct MessageSourceMarker;
939
940impl fidl::endpoints::ProtocolMarker for MessageSourceMarker {
941 type Proxy = MessageSourceProxy;
942 type RequestStream = MessageSourceRequestStream;
943 #[cfg(target_os = "fuchsia")]
944 type SynchronousProxy = MessageSourceSynchronousProxy;
945
946 const DEBUG_NAME: &'static str = "fuchsia.example.power.MessageSource";
947}
948impl fidl::endpoints::DiscoverableProtocolMarker for MessageSourceMarker {}
949
950pub trait MessageSourceProxyInterface: Send + Sync {
951 type ReceiveMessagesResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
952 fn r#receive_messages(&self, socket: fidl::Socket) -> Self::ReceiveMessagesResponseFut;
953 type ReceiveBatonResponseFut: std::future::Future<Output = Result<LeaseBaton, fidl::Error>>
954 + Send;
955 fn r#receive_baton(&self) -> Self::ReceiveBatonResponseFut;
956}
957#[derive(Debug)]
958#[cfg(target_os = "fuchsia")]
959pub struct MessageSourceSynchronousProxy {
960 client: fidl::client::sync::Client,
961}
962
963#[cfg(target_os = "fuchsia")]
964impl fidl::endpoints::SynchronousProxy for MessageSourceSynchronousProxy {
965 type Proxy = MessageSourceProxy;
966 type Protocol = MessageSourceMarker;
967
968 fn from_channel(inner: fidl::Channel) -> Self {
969 Self::new(inner)
970 }
971
972 fn into_channel(self) -> fidl::Channel {
973 self.client.into_channel()
974 }
975
976 fn as_channel(&self) -> &fidl::Channel {
977 self.client.as_channel()
978 }
979}
980
981#[cfg(target_os = "fuchsia")]
982impl MessageSourceSynchronousProxy {
983 pub fn new(channel: fidl::Channel) -> Self {
984 Self { client: fidl::client::sync::Client::new(channel) }
985 }
986
987 pub fn into_channel(self) -> fidl::Channel {
988 self.client.into_channel()
989 }
990
991 pub fn wait_for_event(
994 &self,
995 deadline: zx::MonotonicInstant,
996 ) -> Result<MessageSourceEvent, fidl::Error> {
997 MessageSourceEvent::decode(self.client.wait_for_event::<MessageSourceMarker>(deadline)?)
998 }
999
1000 pub fn r#receive_messages(
1001 &self,
1002 mut socket: fidl::Socket,
1003 ___deadline: zx::MonotonicInstant,
1004 ) -> Result<(), fidl::Error> {
1005 let _response = self.client.send_query::<
1006 MessageSourceReceiveMessagesRequest,
1007 fidl::encoding::EmptyPayload,
1008 MessageSourceMarker,
1009 >(
1010 (socket,),
1011 0x23351bdac594c749,
1012 fidl::encoding::DynamicFlags::empty(),
1013 ___deadline,
1014 )?;
1015 Ok(_response)
1016 }
1017
1018 pub fn r#receive_baton(
1019 &self,
1020 ___deadline: zx::MonotonicInstant,
1021 ) -> Result<LeaseBaton, fidl::Error> {
1022 let _response = self
1023 .client
1024 .send_query::<fidl::encoding::EmptyPayload, LeaseBaton, MessageSourceMarker>(
1025 (),
1026 0x18ed150a92dd23ee,
1027 fidl::encoding::DynamicFlags::empty(),
1028 ___deadline,
1029 )?;
1030 Ok(_response)
1031 }
1032}
1033
1034#[cfg(target_os = "fuchsia")]
1035impl From<MessageSourceSynchronousProxy> for zx::NullableHandle {
1036 fn from(value: MessageSourceSynchronousProxy) -> Self {
1037 value.into_channel().into()
1038 }
1039}
1040
1041#[cfg(target_os = "fuchsia")]
1042impl From<fidl::Channel> for MessageSourceSynchronousProxy {
1043 fn from(value: fidl::Channel) -> Self {
1044 Self::new(value)
1045 }
1046}
1047
1048#[cfg(target_os = "fuchsia")]
1049impl fidl::endpoints::FromClient for MessageSourceSynchronousProxy {
1050 type Protocol = MessageSourceMarker;
1051
1052 fn from_client(value: fidl::endpoints::ClientEnd<MessageSourceMarker>) -> Self {
1053 Self::new(value.into_channel())
1054 }
1055}
1056
1057#[derive(Debug, Clone)]
1058pub struct MessageSourceProxy {
1059 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1060}
1061
1062impl fidl::endpoints::Proxy for MessageSourceProxy {
1063 type Protocol = MessageSourceMarker;
1064
1065 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1066 Self::new(inner)
1067 }
1068
1069 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1070 self.client.into_channel().map_err(|client| Self { client })
1071 }
1072
1073 fn as_channel(&self) -> &::fidl::AsyncChannel {
1074 self.client.as_channel()
1075 }
1076}
1077
1078impl MessageSourceProxy {
1079 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1081 let protocol_name = <MessageSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1082 Self { client: fidl::client::Client::new(channel, protocol_name) }
1083 }
1084
1085 pub fn take_event_stream(&self) -> MessageSourceEventStream {
1091 MessageSourceEventStream { event_receiver: self.client.take_event_receiver() }
1092 }
1093
1094 pub fn r#receive_messages(
1095 &self,
1096 mut socket: fidl::Socket,
1097 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1098 MessageSourceProxyInterface::r#receive_messages(self, socket)
1099 }
1100
1101 pub fn r#receive_baton(
1102 &self,
1103 ) -> fidl::client::QueryResponseFut<LeaseBaton, fidl::encoding::DefaultFuchsiaResourceDialect>
1104 {
1105 MessageSourceProxyInterface::r#receive_baton(self)
1106 }
1107}
1108
1109impl MessageSourceProxyInterface for MessageSourceProxy {
1110 type ReceiveMessagesResponseFut =
1111 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1112 fn r#receive_messages(&self, mut socket: fidl::Socket) -> Self::ReceiveMessagesResponseFut {
1113 fn _decode(
1114 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1115 ) -> Result<(), fidl::Error> {
1116 let _response = fidl::client::decode_transaction_body::<
1117 fidl::encoding::EmptyPayload,
1118 fidl::encoding::DefaultFuchsiaResourceDialect,
1119 0x23351bdac594c749,
1120 >(_buf?)?;
1121 Ok(_response)
1122 }
1123 self.client.send_query_and_decode::<MessageSourceReceiveMessagesRequest, ()>(
1124 (socket,),
1125 0x23351bdac594c749,
1126 fidl::encoding::DynamicFlags::empty(),
1127 _decode,
1128 )
1129 }
1130
1131 type ReceiveBatonResponseFut =
1132 fidl::client::QueryResponseFut<LeaseBaton, fidl::encoding::DefaultFuchsiaResourceDialect>;
1133 fn r#receive_baton(&self) -> Self::ReceiveBatonResponseFut {
1134 fn _decode(
1135 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1136 ) -> Result<LeaseBaton, fidl::Error> {
1137 let _response = fidl::client::decode_transaction_body::<
1138 LeaseBaton,
1139 fidl::encoding::DefaultFuchsiaResourceDialect,
1140 0x18ed150a92dd23ee,
1141 >(_buf?)?;
1142 Ok(_response)
1143 }
1144 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, LeaseBaton>(
1145 (),
1146 0x18ed150a92dd23ee,
1147 fidl::encoding::DynamicFlags::empty(),
1148 _decode,
1149 )
1150 }
1151}
1152
1153pub struct MessageSourceEventStream {
1154 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1155}
1156
1157impl std::marker::Unpin for MessageSourceEventStream {}
1158
1159impl futures::stream::FusedStream for MessageSourceEventStream {
1160 fn is_terminated(&self) -> bool {
1161 self.event_receiver.is_terminated()
1162 }
1163}
1164
1165impl futures::Stream for MessageSourceEventStream {
1166 type Item = Result<MessageSourceEvent, fidl::Error>;
1167
1168 fn poll_next(
1169 mut self: std::pin::Pin<&mut Self>,
1170 cx: &mut std::task::Context<'_>,
1171 ) -> std::task::Poll<Option<Self::Item>> {
1172 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1173 &mut self.event_receiver,
1174 cx
1175 )?) {
1176 Some(buf) => std::task::Poll::Ready(Some(MessageSourceEvent::decode(buf))),
1177 None => std::task::Poll::Ready(None),
1178 }
1179 }
1180}
1181
1182#[derive(Debug)]
1183pub enum MessageSourceEvent {}
1184
1185impl MessageSourceEvent {
1186 fn decode(
1188 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1189 ) -> Result<MessageSourceEvent, fidl::Error> {
1190 let (bytes, _handles) = buf.split_mut();
1191 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1192 debug_assert_eq!(tx_header.tx_id, 0);
1193 match tx_header.ordinal {
1194 _ => Err(fidl::Error::UnknownOrdinal {
1195 ordinal: tx_header.ordinal,
1196 protocol_name: <MessageSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1197 }),
1198 }
1199 }
1200}
1201
1202pub struct MessageSourceRequestStream {
1204 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1205 is_terminated: bool,
1206}
1207
1208impl std::marker::Unpin for MessageSourceRequestStream {}
1209
1210impl futures::stream::FusedStream for MessageSourceRequestStream {
1211 fn is_terminated(&self) -> bool {
1212 self.is_terminated
1213 }
1214}
1215
1216impl fidl::endpoints::RequestStream for MessageSourceRequestStream {
1217 type Protocol = MessageSourceMarker;
1218 type ControlHandle = MessageSourceControlHandle;
1219
1220 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1221 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1222 }
1223
1224 fn control_handle(&self) -> Self::ControlHandle {
1225 MessageSourceControlHandle { inner: self.inner.clone() }
1226 }
1227
1228 fn into_inner(
1229 self,
1230 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1231 {
1232 (self.inner, self.is_terminated)
1233 }
1234
1235 fn from_inner(
1236 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1237 is_terminated: bool,
1238 ) -> Self {
1239 Self { inner, is_terminated }
1240 }
1241}
1242
1243impl futures::Stream for MessageSourceRequestStream {
1244 type Item = Result<MessageSourceRequest, fidl::Error>;
1245
1246 fn poll_next(
1247 mut self: std::pin::Pin<&mut Self>,
1248 cx: &mut std::task::Context<'_>,
1249 ) -> std::task::Poll<Option<Self::Item>> {
1250 let this = &mut *self;
1251 if this.inner.check_shutdown(cx) {
1252 this.is_terminated = true;
1253 return std::task::Poll::Ready(None);
1254 }
1255 if this.is_terminated {
1256 panic!("polled MessageSourceRequestStream after completion");
1257 }
1258 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1259 |bytes, handles| {
1260 match this.inner.channel().read_etc(cx, bytes, handles) {
1261 std::task::Poll::Ready(Ok(())) => {}
1262 std::task::Poll::Pending => return std::task::Poll::Pending,
1263 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1264 this.is_terminated = true;
1265 return std::task::Poll::Ready(None);
1266 }
1267 std::task::Poll::Ready(Err(e)) => {
1268 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1269 e.into(),
1270 ))));
1271 }
1272 }
1273
1274 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1276
1277 std::task::Poll::Ready(Some(match header.ordinal {
1278 0x23351bdac594c749 => {
1279 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1280 let mut req = fidl::new_empty!(
1281 MessageSourceReceiveMessagesRequest,
1282 fidl::encoding::DefaultFuchsiaResourceDialect
1283 );
1284 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MessageSourceReceiveMessagesRequest>(&header, _body_bytes, handles, &mut req)?;
1285 let control_handle =
1286 MessageSourceControlHandle { inner: this.inner.clone() };
1287 Ok(MessageSourceRequest::ReceiveMessages {
1288 socket: req.socket,
1289
1290 responder: MessageSourceReceiveMessagesResponder {
1291 control_handle: std::mem::ManuallyDrop::new(control_handle),
1292 tx_id: header.tx_id,
1293 },
1294 })
1295 }
1296 0x18ed150a92dd23ee => {
1297 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1298 let mut req = fidl::new_empty!(
1299 fidl::encoding::EmptyPayload,
1300 fidl::encoding::DefaultFuchsiaResourceDialect
1301 );
1302 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1303 let control_handle =
1304 MessageSourceControlHandle { inner: this.inner.clone() };
1305 Ok(MessageSourceRequest::ReceiveBaton {
1306 responder: MessageSourceReceiveBatonResponder {
1307 control_handle: std::mem::ManuallyDrop::new(control_handle),
1308 tx_id: header.tx_id,
1309 },
1310 })
1311 }
1312 _ => Err(fidl::Error::UnknownOrdinal {
1313 ordinal: header.ordinal,
1314 protocol_name:
1315 <MessageSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1316 }),
1317 }))
1318 },
1319 )
1320 }
1321}
1322
1323#[derive(Debug)]
1324pub enum MessageSourceRequest {
1325 ReceiveMessages { socket: fidl::Socket, responder: MessageSourceReceiveMessagesResponder },
1326 ReceiveBaton { responder: MessageSourceReceiveBatonResponder },
1327}
1328
1329impl MessageSourceRequest {
1330 #[allow(irrefutable_let_patterns)]
1331 pub fn into_receive_messages(
1332 self,
1333 ) -> Option<(fidl::Socket, MessageSourceReceiveMessagesResponder)> {
1334 if let MessageSourceRequest::ReceiveMessages { socket, responder } = self {
1335 Some((socket, responder))
1336 } else {
1337 None
1338 }
1339 }
1340
1341 #[allow(irrefutable_let_patterns)]
1342 pub fn into_receive_baton(self) -> Option<(MessageSourceReceiveBatonResponder)> {
1343 if let MessageSourceRequest::ReceiveBaton { responder } = self {
1344 Some((responder))
1345 } else {
1346 None
1347 }
1348 }
1349
1350 pub fn method_name(&self) -> &'static str {
1352 match *self {
1353 MessageSourceRequest::ReceiveMessages { .. } => "receive_messages",
1354 MessageSourceRequest::ReceiveBaton { .. } => "receive_baton",
1355 }
1356 }
1357}
1358
1359#[derive(Debug, Clone)]
1360pub struct MessageSourceControlHandle {
1361 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1362}
1363
1364impl MessageSourceControlHandle {
1365 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1366 self.inner.shutdown_with_epitaph(status.into())
1367 }
1368}
1369
1370impl fidl::endpoints::ControlHandle for MessageSourceControlHandle {
1371 fn shutdown(&self) {
1372 self.inner.shutdown()
1373 }
1374
1375 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1376 self.inner.shutdown_with_epitaph(status)
1377 }
1378
1379 fn is_closed(&self) -> bool {
1380 self.inner.channel().is_closed()
1381 }
1382 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1383 self.inner.channel().on_closed()
1384 }
1385
1386 #[cfg(target_os = "fuchsia")]
1387 fn signal_peer(
1388 &self,
1389 clear_mask: zx::Signals,
1390 set_mask: zx::Signals,
1391 ) -> Result<(), zx_status::Status> {
1392 use fidl::Peered;
1393 self.inner.channel().signal_peer(clear_mask, set_mask)
1394 }
1395}
1396
1397impl MessageSourceControlHandle {}
1398
1399#[must_use = "FIDL methods require a response to be sent"]
1400#[derive(Debug)]
1401pub struct MessageSourceReceiveMessagesResponder {
1402 control_handle: std::mem::ManuallyDrop<MessageSourceControlHandle>,
1403 tx_id: u32,
1404}
1405
1406impl std::ops::Drop for MessageSourceReceiveMessagesResponder {
1410 fn drop(&mut self) {
1411 self.control_handle.shutdown();
1412 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1414 }
1415}
1416
1417impl fidl::endpoints::Responder for MessageSourceReceiveMessagesResponder {
1418 type ControlHandle = MessageSourceControlHandle;
1419
1420 fn control_handle(&self) -> &MessageSourceControlHandle {
1421 &self.control_handle
1422 }
1423
1424 fn drop_without_shutdown(mut self) {
1425 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1427 std::mem::forget(self);
1429 }
1430}
1431
1432impl MessageSourceReceiveMessagesResponder {
1433 pub fn send(self) -> Result<(), fidl::Error> {
1437 let _result = self.send_raw();
1438 if _result.is_err() {
1439 self.control_handle.shutdown();
1440 }
1441 self.drop_without_shutdown();
1442 _result
1443 }
1444
1445 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1447 let _result = self.send_raw();
1448 self.drop_without_shutdown();
1449 _result
1450 }
1451
1452 fn send_raw(&self) -> Result<(), fidl::Error> {
1453 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1454 (),
1455 self.tx_id,
1456 0x23351bdac594c749,
1457 fidl::encoding::DynamicFlags::empty(),
1458 )
1459 }
1460}
1461
1462#[must_use = "FIDL methods require a response to be sent"]
1463#[derive(Debug)]
1464pub struct MessageSourceReceiveBatonResponder {
1465 control_handle: std::mem::ManuallyDrop<MessageSourceControlHandle>,
1466 tx_id: u32,
1467}
1468
1469impl std::ops::Drop for MessageSourceReceiveBatonResponder {
1473 fn drop(&mut self) {
1474 self.control_handle.shutdown();
1475 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1477 }
1478}
1479
1480impl fidl::endpoints::Responder for MessageSourceReceiveBatonResponder {
1481 type ControlHandle = MessageSourceControlHandle;
1482
1483 fn control_handle(&self) -> &MessageSourceControlHandle {
1484 &self.control_handle
1485 }
1486
1487 fn drop_without_shutdown(mut self) {
1488 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1490 std::mem::forget(self);
1492 }
1493}
1494
1495impl MessageSourceReceiveBatonResponder {
1496 pub fn send(self, mut payload: LeaseBaton) -> Result<(), fidl::Error> {
1500 let _result = self.send_raw(payload);
1501 if _result.is_err() {
1502 self.control_handle.shutdown();
1503 }
1504 self.drop_without_shutdown();
1505 _result
1506 }
1507
1508 pub fn send_no_shutdown_on_err(self, mut payload: LeaseBaton) -> Result<(), fidl::Error> {
1510 let _result = self.send_raw(payload);
1511 self.drop_without_shutdown();
1512 _result
1513 }
1514
1515 fn send_raw(&self, mut payload: LeaseBaton) -> Result<(), fidl::Error> {
1516 self.control_handle.inner.send::<LeaseBaton>(
1517 &mut payload,
1518 self.tx_id,
1519 0x18ed150a92dd23ee,
1520 fidl::encoding::DynamicFlags::empty(),
1521 )
1522 }
1523}
1524
1525mod internal {
1526 use super::*;
1527
1528 impl fidl::encoding::ResourceTypeMarker for MessageSourceReceiveMessagesRequest {
1529 type Borrowed<'a> = &'a mut Self;
1530 fn take_or_borrow<'a>(
1531 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1532 ) -> Self::Borrowed<'a> {
1533 value
1534 }
1535 }
1536
1537 unsafe impl fidl::encoding::TypeMarker for MessageSourceReceiveMessagesRequest {
1538 type Owned = Self;
1539
1540 #[inline(always)]
1541 fn inline_align(_context: fidl::encoding::Context) -> usize {
1542 4
1543 }
1544
1545 #[inline(always)]
1546 fn inline_size(_context: fidl::encoding::Context) -> usize {
1547 4
1548 }
1549 }
1550
1551 unsafe impl
1552 fidl::encoding::Encode<
1553 MessageSourceReceiveMessagesRequest,
1554 fidl::encoding::DefaultFuchsiaResourceDialect,
1555 > for &mut MessageSourceReceiveMessagesRequest
1556 {
1557 #[inline]
1558 unsafe fn encode(
1559 self,
1560 encoder: &mut fidl::encoding::Encoder<
1561 '_,
1562 fidl::encoding::DefaultFuchsiaResourceDialect,
1563 >,
1564 offset: usize,
1565 _depth: fidl::encoding::Depth,
1566 ) -> fidl::Result<()> {
1567 encoder.debug_check_bounds::<MessageSourceReceiveMessagesRequest>(offset);
1568 fidl::encoding::Encode::<
1570 MessageSourceReceiveMessagesRequest,
1571 fidl::encoding::DefaultFuchsiaResourceDialect,
1572 >::encode(
1573 (<fidl::encoding::HandleType<
1574 fidl::Socket,
1575 { fidl::ObjectType::SOCKET.into_raw() },
1576 2147483648,
1577 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1578 &mut self.socket
1579 ),),
1580 encoder,
1581 offset,
1582 _depth,
1583 )
1584 }
1585 }
1586 unsafe impl<
1587 T0: fidl::encoding::Encode<
1588 fidl::encoding::HandleType<
1589 fidl::Socket,
1590 { fidl::ObjectType::SOCKET.into_raw() },
1591 2147483648,
1592 >,
1593 fidl::encoding::DefaultFuchsiaResourceDialect,
1594 >,
1595 >
1596 fidl::encoding::Encode<
1597 MessageSourceReceiveMessagesRequest,
1598 fidl::encoding::DefaultFuchsiaResourceDialect,
1599 > for (T0,)
1600 {
1601 #[inline]
1602 unsafe fn encode(
1603 self,
1604 encoder: &mut fidl::encoding::Encoder<
1605 '_,
1606 fidl::encoding::DefaultFuchsiaResourceDialect,
1607 >,
1608 offset: usize,
1609 depth: fidl::encoding::Depth,
1610 ) -> fidl::Result<()> {
1611 encoder.debug_check_bounds::<MessageSourceReceiveMessagesRequest>(offset);
1612 self.0.encode(encoder, offset + 0, depth)?;
1616 Ok(())
1617 }
1618 }
1619
1620 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1621 for MessageSourceReceiveMessagesRequest
1622 {
1623 #[inline(always)]
1624 fn new_empty() -> Self {
1625 Self {
1626 socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1627 }
1628 }
1629
1630 #[inline]
1631 unsafe fn decode(
1632 &mut self,
1633 decoder: &mut fidl::encoding::Decoder<
1634 '_,
1635 fidl::encoding::DefaultFuchsiaResourceDialect,
1636 >,
1637 offset: usize,
1638 _depth: fidl::encoding::Depth,
1639 ) -> fidl::Result<()> {
1640 decoder.debug_check_bounds::<Self>(offset);
1641 fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
1643 Ok(())
1644 }
1645 }
1646
1647 impl LeaseBaton {
1648 #[inline(always)]
1649 fn max_ordinal_present(&self) -> u64 {
1650 if let Some(_) = self.msg_index {
1651 return 2;
1652 }
1653 if let Some(_) = self.lease {
1654 return 1;
1655 }
1656 0
1657 }
1658 }
1659
1660 impl fidl::encoding::ResourceTypeMarker for LeaseBaton {
1661 type Borrowed<'a> = &'a mut Self;
1662 fn take_or_borrow<'a>(
1663 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1664 ) -> Self::Borrowed<'a> {
1665 value
1666 }
1667 }
1668
1669 unsafe impl fidl::encoding::TypeMarker for LeaseBaton {
1670 type Owned = Self;
1671
1672 #[inline(always)]
1673 fn inline_align(_context: fidl::encoding::Context) -> usize {
1674 8
1675 }
1676
1677 #[inline(always)]
1678 fn inline_size(_context: fidl::encoding::Context) -> usize {
1679 16
1680 }
1681 }
1682
1683 unsafe impl fidl::encoding::Encode<LeaseBaton, fidl::encoding::DefaultFuchsiaResourceDialect>
1684 for &mut LeaseBaton
1685 {
1686 unsafe fn encode(
1687 self,
1688 encoder: &mut fidl::encoding::Encoder<
1689 '_,
1690 fidl::encoding::DefaultFuchsiaResourceDialect,
1691 >,
1692 offset: usize,
1693 mut depth: fidl::encoding::Depth,
1694 ) -> fidl::Result<()> {
1695 encoder.debug_check_bounds::<LeaseBaton>(offset);
1696 let max_ordinal: u64 = self.max_ordinal_present();
1698 encoder.write_num(max_ordinal, offset);
1699 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1700 if max_ordinal == 0 {
1702 return Ok(());
1703 }
1704 depth.increment()?;
1705 let envelope_size = 8;
1706 let bytes_len = max_ordinal as usize * envelope_size;
1707 #[allow(unused_variables)]
1708 let offset = encoder.out_of_line_offset(bytes_len);
1709 let mut _prev_end_offset: usize = 0;
1710 if 1 > max_ordinal {
1711 return Ok(());
1712 }
1713
1714 let cur_offset: usize = (1 - 1) * envelope_size;
1717
1718 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1720
1721 fidl::encoding::encode_in_envelope_optional::<
1726 fidl::encoding::HandleType<
1727 fidl::EventPair,
1728 { fidl::ObjectType::EVENTPAIR.into_raw() },
1729 2147483648,
1730 >,
1731 fidl::encoding::DefaultFuchsiaResourceDialect,
1732 >(
1733 self.lease.as_mut().map(
1734 <fidl::encoding::HandleType<
1735 fidl::EventPair,
1736 { fidl::ObjectType::EVENTPAIR.into_raw() },
1737 2147483648,
1738 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1739 ),
1740 encoder,
1741 offset + cur_offset,
1742 depth,
1743 )?;
1744
1745 _prev_end_offset = cur_offset + envelope_size;
1746 if 2 > max_ordinal {
1747 return Ok(());
1748 }
1749
1750 let cur_offset: usize = (2 - 1) * envelope_size;
1753
1754 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1756
1757 fidl::encoding::encode_in_envelope_optional::<
1762 u64,
1763 fidl::encoding::DefaultFuchsiaResourceDialect,
1764 >(
1765 self.msg_index.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1766 encoder,
1767 offset + cur_offset,
1768 depth,
1769 )?;
1770
1771 _prev_end_offset = cur_offset + envelope_size;
1772
1773 Ok(())
1774 }
1775 }
1776
1777 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for LeaseBaton {
1778 #[inline(always)]
1779 fn new_empty() -> Self {
1780 Self::default()
1781 }
1782
1783 unsafe fn decode(
1784 &mut self,
1785 decoder: &mut fidl::encoding::Decoder<
1786 '_,
1787 fidl::encoding::DefaultFuchsiaResourceDialect,
1788 >,
1789 offset: usize,
1790 mut depth: fidl::encoding::Depth,
1791 ) -> fidl::Result<()> {
1792 decoder.debug_check_bounds::<Self>(offset);
1793 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1794 None => return Err(fidl::Error::NotNullable),
1795 Some(len) => len,
1796 };
1797 if len == 0 {
1799 return Ok(());
1800 };
1801 depth.increment()?;
1802 let envelope_size = 8;
1803 let bytes_len = len * envelope_size;
1804 let offset = decoder.out_of_line_offset(bytes_len)?;
1805 let mut _next_ordinal_to_read = 0;
1807 let mut next_offset = offset;
1808 let end_offset = offset + bytes_len;
1809 _next_ordinal_to_read += 1;
1810 if next_offset >= end_offset {
1811 return Ok(());
1812 }
1813
1814 while _next_ordinal_to_read < 1 {
1816 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1817 _next_ordinal_to_read += 1;
1818 next_offset += envelope_size;
1819 }
1820
1821 let next_out_of_line = decoder.next_out_of_line();
1822 let handles_before = decoder.remaining_handles();
1823 if let Some((inlined, num_bytes, num_handles)) =
1824 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1825 {
1826 let member_inline_size = <fidl::encoding::HandleType<
1827 fidl::EventPair,
1828 { fidl::ObjectType::EVENTPAIR.into_raw() },
1829 2147483648,
1830 > as fidl::encoding::TypeMarker>::inline_size(
1831 decoder.context
1832 );
1833 if inlined != (member_inline_size <= 4) {
1834 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1835 }
1836 let inner_offset;
1837 let mut inner_depth = depth.clone();
1838 if inlined {
1839 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1840 inner_offset = next_offset;
1841 } else {
1842 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1843 inner_depth.increment()?;
1844 }
1845 let val_ref =
1846 self.lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
1847 fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1848 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1849 {
1850 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1851 }
1852 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1853 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1854 }
1855 }
1856
1857 next_offset += envelope_size;
1858 _next_ordinal_to_read += 1;
1859 if next_offset >= end_offset {
1860 return Ok(());
1861 }
1862
1863 while _next_ordinal_to_read < 2 {
1865 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1866 _next_ordinal_to_read += 1;
1867 next_offset += envelope_size;
1868 }
1869
1870 let next_out_of_line = decoder.next_out_of_line();
1871 let handles_before = decoder.remaining_handles();
1872 if let Some((inlined, num_bytes, num_handles)) =
1873 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1874 {
1875 let member_inline_size =
1876 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1877 if inlined != (member_inline_size <= 4) {
1878 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1879 }
1880 let inner_offset;
1881 let mut inner_depth = depth.clone();
1882 if inlined {
1883 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1884 inner_offset = next_offset;
1885 } else {
1886 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1887 inner_depth.increment()?;
1888 }
1889 let val_ref = self.msg_index.get_or_insert_with(|| {
1890 fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
1891 });
1892 fidl::decode!(
1893 u64,
1894 fidl::encoding::DefaultFuchsiaResourceDialect,
1895 val_ref,
1896 decoder,
1897 inner_offset,
1898 inner_depth
1899 )?;
1900 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1901 {
1902 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1903 }
1904 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1905 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1906 }
1907 }
1908
1909 next_offset += envelope_size;
1910
1911 while next_offset < end_offset {
1913 _next_ordinal_to_read += 1;
1914 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1915 next_offset += envelope_size;
1916 }
1917
1918 Ok(())
1919 }
1920 }
1921}