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 let protocol_name = <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
79 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
80 }
81
82 pub fn into_channel(self) -> fidl::Channel {
83 self.client.into_channel()
84 }
85
86 pub fn wait_for_event(
89 &self,
90 deadline: zx::MonotonicInstant,
91 ) -> Result<CounterEvent, fidl::Error> {
92 CounterEvent::decode(self.client.wait_for_event(deadline)?)
93 }
94
95 pub fn r#get(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
96 let _response =
97 self.client.send_query::<fidl::encoding::EmptyPayload, CounterGetResponse>(
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::Handle {
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 {
357 Some((responder))
358 } else {
359 None
360 }
361 }
362
363 pub fn method_name(&self) -> &'static str {
365 match *self {
366 CounterRequest::Get { .. } => "get",
367 }
368 }
369}
370
371#[derive(Debug, Clone)]
372pub struct CounterControlHandle {
373 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
374}
375
376impl fidl::endpoints::ControlHandle for CounterControlHandle {
377 fn shutdown(&self) {
378 self.inner.shutdown()
379 }
380 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
381 self.inner.shutdown_with_epitaph(status)
382 }
383
384 fn is_closed(&self) -> bool {
385 self.inner.channel().is_closed()
386 }
387 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
388 self.inner.channel().on_closed()
389 }
390
391 #[cfg(target_os = "fuchsia")]
392 fn signal_peer(
393 &self,
394 clear_mask: zx::Signals,
395 set_mask: zx::Signals,
396 ) -> Result<(), zx_status::Status> {
397 use fidl::Peered;
398 self.inner.channel().signal_peer(clear_mask, set_mask)
399 }
400}
401
402impl CounterControlHandle {}
403
404#[must_use = "FIDL methods require a response to be sent"]
405#[derive(Debug)]
406pub struct CounterGetResponder {
407 control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
408 tx_id: u32,
409}
410
411impl std::ops::Drop for CounterGetResponder {
415 fn drop(&mut self) {
416 self.control_handle.shutdown();
417 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
419 }
420}
421
422impl fidl::endpoints::Responder for CounterGetResponder {
423 type ControlHandle = CounterControlHandle;
424
425 fn control_handle(&self) -> &CounterControlHandle {
426 &self.control_handle
427 }
428
429 fn drop_without_shutdown(mut self) {
430 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
432 std::mem::forget(self);
434 }
435}
436
437impl CounterGetResponder {
438 pub fn send(self, mut count: u64) -> Result<(), fidl::Error> {
442 let _result = self.send_raw(count);
443 if _result.is_err() {
444 self.control_handle.shutdown();
445 }
446 self.drop_without_shutdown();
447 _result
448 }
449
450 pub fn send_no_shutdown_on_err(self, mut count: u64) -> Result<(), fidl::Error> {
452 let _result = self.send_raw(count);
453 self.drop_without_shutdown();
454 _result
455 }
456
457 fn send_raw(&self, mut count: u64) -> Result<(), fidl::Error> {
458 self.control_handle.inner.send::<CounterGetResponse>(
459 (count,),
460 self.tx_id,
461 0x3944f6d91c5b8ad8,
462 fidl::encoding::DynamicFlags::empty(),
463 )
464 }
465}
466
467#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
468pub struct FrameControlMarker;
469
470impl fidl::endpoints::ProtocolMarker for FrameControlMarker {
471 type Proxy = FrameControlProxy;
472 type RequestStream = FrameControlRequestStream;
473 #[cfg(target_os = "fuchsia")]
474 type SynchronousProxy = FrameControlSynchronousProxy;
475
476 const DEBUG_NAME: &'static str = "fuchsia.example.power.FrameControl";
477}
478impl fidl::endpoints::DiscoverableProtocolMarker for FrameControlMarker {}
479
480pub trait FrameControlProxyInterface: Send + Sync {
481 type StartFrameResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
482 fn r#start_frame(
483 &self,
484 duration_ms: u16,
485 rate_change_offset_ms: u16,
486 ) -> Self::StartFrameResponseFut;
487}
488#[derive(Debug)]
489#[cfg(target_os = "fuchsia")]
490pub struct FrameControlSynchronousProxy {
491 client: fidl::client::sync::Client,
492}
493
494#[cfg(target_os = "fuchsia")]
495impl fidl::endpoints::SynchronousProxy for FrameControlSynchronousProxy {
496 type Proxy = FrameControlProxy;
497 type Protocol = FrameControlMarker;
498
499 fn from_channel(inner: fidl::Channel) -> Self {
500 Self::new(inner)
501 }
502
503 fn into_channel(self) -> fidl::Channel {
504 self.client.into_channel()
505 }
506
507 fn as_channel(&self) -> &fidl::Channel {
508 self.client.as_channel()
509 }
510}
511
512#[cfg(target_os = "fuchsia")]
513impl FrameControlSynchronousProxy {
514 pub fn new(channel: fidl::Channel) -> Self {
515 let protocol_name = <FrameControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
516 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
517 }
518
519 pub fn into_channel(self) -> fidl::Channel {
520 self.client.into_channel()
521 }
522
523 pub fn wait_for_event(
526 &self,
527 deadline: zx::MonotonicInstant,
528 ) -> Result<FrameControlEvent, fidl::Error> {
529 FrameControlEvent::decode(self.client.wait_for_event(deadline)?)
530 }
531
532 pub fn r#start_frame(
533 &self,
534 mut duration_ms: u16,
535 mut rate_change_offset_ms: u16,
536 ___deadline: zx::MonotonicInstant,
537 ) -> Result<(), fidl::Error> {
538 let _response =
539 self.client.send_query::<FrameControlStartFrameRequest, fidl::encoding::EmptyPayload>(
540 (duration_ms, rate_change_offset_ms),
541 0x187c1cc46de29b5e,
542 fidl::encoding::DynamicFlags::empty(),
543 ___deadline,
544 )?;
545 Ok(_response)
546 }
547}
548
549#[cfg(target_os = "fuchsia")]
550impl From<FrameControlSynchronousProxy> for zx::Handle {
551 fn from(value: FrameControlSynchronousProxy) -> Self {
552 value.into_channel().into()
553 }
554}
555
556#[cfg(target_os = "fuchsia")]
557impl From<fidl::Channel> for FrameControlSynchronousProxy {
558 fn from(value: fidl::Channel) -> Self {
559 Self::new(value)
560 }
561}
562
563#[cfg(target_os = "fuchsia")]
564impl fidl::endpoints::FromClient for FrameControlSynchronousProxy {
565 type Protocol = FrameControlMarker;
566
567 fn from_client(value: fidl::endpoints::ClientEnd<FrameControlMarker>) -> Self {
568 Self::new(value.into_channel())
569 }
570}
571
572#[derive(Debug, Clone)]
573pub struct FrameControlProxy {
574 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
575}
576
577impl fidl::endpoints::Proxy for FrameControlProxy {
578 type Protocol = FrameControlMarker;
579
580 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
581 Self::new(inner)
582 }
583
584 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
585 self.client.into_channel().map_err(|client| Self { client })
586 }
587
588 fn as_channel(&self) -> &::fidl::AsyncChannel {
589 self.client.as_channel()
590 }
591}
592
593impl FrameControlProxy {
594 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
596 let protocol_name = <FrameControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
597 Self { client: fidl::client::Client::new(channel, protocol_name) }
598 }
599
600 pub fn take_event_stream(&self) -> FrameControlEventStream {
606 FrameControlEventStream { event_receiver: self.client.take_event_receiver() }
607 }
608
609 pub fn r#start_frame(
610 &self,
611 mut duration_ms: u16,
612 mut rate_change_offset_ms: u16,
613 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
614 FrameControlProxyInterface::r#start_frame(self, duration_ms, rate_change_offset_ms)
615 }
616}
617
618impl FrameControlProxyInterface for FrameControlProxy {
619 type StartFrameResponseFut =
620 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
621 fn r#start_frame(
622 &self,
623 mut duration_ms: u16,
624 mut rate_change_offset_ms: u16,
625 ) -> Self::StartFrameResponseFut {
626 fn _decode(
627 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
628 ) -> Result<(), fidl::Error> {
629 let _response = fidl::client::decode_transaction_body::<
630 fidl::encoding::EmptyPayload,
631 fidl::encoding::DefaultFuchsiaResourceDialect,
632 0x187c1cc46de29b5e,
633 >(_buf?)?;
634 Ok(_response)
635 }
636 self.client.send_query_and_decode::<FrameControlStartFrameRequest, ()>(
637 (duration_ms, rate_change_offset_ms),
638 0x187c1cc46de29b5e,
639 fidl::encoding::DynamicFlags::empty(),
640 _decode,
641 )
642 }
643}
644
645pub struct FrameControlEventStream {
646 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
647}
648
649impl std::marker::Unpin for FrameControlEventStream {}
650
651impl futures::stream::FusedStream for FrameControlEventStream {
652 fn is_terminated(&self) -> bool {
653 self.event_receiver.is_terminated()
654 }
655}
656
657impl futures::Stream for FrameControlEventStream {
658 type Item = Result<FrameControlEvent, fidl::Error>;
659
660 fn poll_next(
661 mut self: std::pin::Pin<&mut Self>,
662 cx: &mut std::task::Context<'_>,
663 ) -> std::task::Poll<Option<Self::Item>> {
664 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
665 &mut self.event_receiver,
666 cx
667 )?) {
668 Some(buf) => std::task::Poll::Ready(Some(FrameControlEvent::decode(buf))),
669 None => std::task::Poll::Ready(None),
670 }
671 }
672}
673
674#[derive(Debug)]
675pub enum FrameControlEvent {}
676
677impl FrameControlEvent {
678 fn decode(
680 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
681 ) -> Result<FrameControlEvent, fidl::Error> {
682 let (bytes, _handles) = buf.split_mut();
683 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
684 debug_assert_eq!(tx_header.tx_id, 0);
685 match tx_header.ordinal {
686 _ => Err(fidl::Error::UnknownOrdinal {
687 ordinal: tx_header.ordinal,
688 protocol_name: <FrameControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
689 }),
690 }
691 }
692}
693
694pub struct FrameControlRequestStream {
696 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
697 is_terminated: bool,
698}
699
700impl std::marker::Unpin for FrameControlRequestStream {}
701
702impl futures::stream::FusedStream for FrameControlRequestStream {
703 fn is_terminated(&self) -> bool {
704 self.is_terminated
705 }
706}
707
708impl fidl::endpoints::RequestStream for FrameControlRequestStream {
709 type Protocol = FrameControlMarker;
710 type ControlHandle = FrameControlControlHandle;
711
712 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
713 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
714 }
715
716 fn control_handle(&self) -> Self::ControlHandle {
717 FrameControlControlHandle { inner: self.inner.clone() }
718 }
719
720 fn into_inner(
721 self,
722 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
723 {
724 (self.inner, self.is_terminated)
725 }
726
727 fn from_inner(
728 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
729 is_terminated: bool,
730 ) -> Self {
731 Self { inner, is_terminated }
732 }
733}
734
735impl futures::Stream for FrameControlRequestStream {
736 type Item = Result<FrameControlRequest, fidl::Error>;
737
738 fn poll_next(
739 mut self: std::pin::Pin<&mut Self>,
740 cx: &mut std::task::Context<'_>,
741 ) -> std::task::Poll<Option<Self::Item>> {
742 let this = &mut *self;
743 if this.inner.check_shutdown(cx) {
744 this.is_terminated = true;
745 return std::task::Poll::Ready(None);
746 }
747 if this.is_terminated {
748 panic!("polled FrameControlRequestStream after completion");
749 }
750 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
751 |bytes, handles| {
752 match this.inner.channel().read_etc(cx, bytes, handles) {
753 std::task::Poll::Ready(Ok(())) => {}
754 std::task::Poll::Pending => return std::task::Poll::Pending,
755 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
756 this.is_terminated = true;
757 return std::task::Poll::Ready(None);
758 }
759 std::task::Poll::Ready(Err(e)) => {
760 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
761 e.into(),
762 ))))
763 }
764 }
765
766 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
768
769 std::task::Poll::Ready(Some(match header.ordinal {
770 0x187c1cc46de29b5e => {
771 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
772 let mut req = fidl::new_empty!(
773 FrameControlStartFrameRequest,
774 fidl::encoding::DefaultFuchsiaResourceDialect
775 );
776 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FrameControlStartFrameRequest>(&header, _body_bytes, handles, &mut req)?;
777 let control_handle =
778 FrameControlControlHandle { inner: this.inner.clone() };
779 Ok(FrameControlRequest::StartFrame {
780 duration_ms: req.duration_ms,
781 rate_change_offset_ms: req.rate_change_offset_ms,
782
783 responder: FrameControlStartFrameResponder {
784 control_handle: std::mem::ManuallyDrop::new(control_handle),
785 tx_id: header.tx_id,
786 },
787 })
788 }
789 _ => Err(fidl::Error::UnknownOrdinal {
790 ordinal: header.ordinal,
791 protocol_name:
792 <FrameControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
793 }),
794 }))
795 },
796 )
797 }
798}
799
800#[derive(Debug)]
801pub enum FrameControlRequest {
802 StartFrame {
803 duration_ms: u16,
804 rate_change_offset_ms: u16,
805 responder: FrameControlStartFrameResponder,
806 },
807}
808
809impl FrameControlRequest {
810 #[allow(irrefutable_let_patterns)]
811 pub fn into_start_frame(self) -> Option<(u16, u16, FrameControlStartFrameResponder)> {
812 if let FrameControlRequest::StartFrame { duration_ms, rate_change_offset_ms, responder } =
813 self
814 {
815 Some((duration_ms, rate_change_offset_ms, responder))
816 } else {
817 None
818 }
819 }
820
821 pub fn method_name(&self) -> &'static str {
823 match *self {
824 FrameControlRequest::StartFrame { .. } => "start_frame",
825 }
826 }
827}
828
829#[derive(Debug, Clone)]
830pub struct FrameControlControlHandle {
831 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
832}
833
834impl fidl::endpoints::ControlHandle for FrameControlControlHandle {
835 fn shutdown(&self) {
836 self.inner.shutdown()
837 }
838 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
839 self.inner.shutdown_with_epitaph(status)
840 }
841
842 fn is_closed(&self) -> bool {
843 self.inner.channel().is_closed()
844 }
845 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
846 self.inner.channel().on_closed()
847 }
848
849 #[cfg(target_os = "fuchsia")]
850 fn signal_peer(
851 &self,
852 clear_mask: zx::Signals,
853 set_mask: zx::Signals,
854 ) -> Result<(), zx_status::Status> {
855 use fidl::Peered;
856 self.inner.channel().signal_peer(clear_mask, set_mask)
857 }
858}
859
860impl FrameControlControlHandle {}
861
862#[must_use = "FIDL methods require a response to be sent"]
863#[derive(Debug)]
864pub struct FrameControlStartFrameResponder {
865 control_handle: std::mem::ManuallyDrop<FrameControlControlHandle>,
866 tx_id: u32,
867}
868
869impl std::ops::Drop for FrameControlStartFrameResponder {
873 fn drop(&mut self) {
874 self.control_handle.shutdown();
875 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
877 }
878}
879
880impl fidl::endpoints::Responder for FrameControlStartFrameResponder {
881 type ControlHandle = FrameControlControlHandle;
882
883 fn control_handle(&self) -> &FrameControlControlHandle {
884 &self.control_handle
885 }
886
887 fn drop_without_shutdown(mut self) {
888 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
890 std::mem::forget(self);
892 }
893}
894
895impl FrameControlStartFrameResponder {
896 pub fn send(self) -> Result<(), fidl::Error> {
900 let _result = self.send_raw();
901 if _result.is_err() {
902 self.control_handle.shutdown();
903 }
904 self.drop_without_shutdown();
905 _result
906 }
907
908 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
910 let _result = self.send_raw();
911 self.drop_without_shutdown();
912 _result
913 }
914
915 fn send_raw(&self) -> Result<(), fidl::Error> {
916 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
917 (),
918 self.tx_id,
919 0x187c1cc46de29b5e,
920 fidl::encoding::DynamicFlags::empty(),
921 )
922 }
923}
924
925#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
926pub struct MessageSourceMarker;
927
928impl fidl::endpoints::ProtocolMarker for MessageSourceMarker {
929 type Proxy = MessageSourceProxy;
930 type RequestStream = MessageSourceRequestStream;
931 #[cfg(target_os = "fuchsia")]
932 type SynchronousProxy = MessageSourceSynchronousProxy;
933
934 const DEBUG_NAME: &'static str = "fuchsia.example.power.MessageSource";
935}
936impl fidl::endpoints::DiscoverableProtocolMarker for MessageSourceMarker {}
937
938pub trait MessageSourceProxyInterface: Send + Sync {
939 type ReceiveMessagesResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
940 fn r#receive_messages(&self, socket: fidl::Socket) -> Self::ReceiveMessagesResponseFut;
941 type ReceiveBatonResponseFut: std::future::Future<Output = Result<LeaseBaton, fidl::Error>>
942 + Send;
943 fn r#receive_baton(&self) -> Self::ReceiveBatonResponseFut;
944}
945#[derive(Debug)]
946#[cfg(target_os = "fuchsia")]
947pub struct MessageSourceSynchronousProxy {
948 client: fidl::client::sync::Client,
949}
950
951#[cfg(target_os = "fuchsia")]
952impl fidl::endpoints::SynchronousProxy for MessageSourceSynchronousProxy {
953 type Proxy = MessageSourceProxy;
954 type Protocol = MessageSourceMarker;
955
956 fn from_channel(inner: fidl::Channel) -> Self {
957 Self::new(inner)
958 }
959
960 fn into_channel(self) -> fidl::Channel {
961 self.client.into_channel()
962 }
963
964 fn as_channel(&self) -> &fidl::Channel {
965 self.client.as_channel()
966 }
967}
968
969#[cfg(target_os = "fuchsia")]
970impl MessageSourceSynchronousProxy {
971 pub fn new(channel: fidl::Channel) -> Self {
972 let protocol_name = <MessageSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
973 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
974 }
975
976 pub fn into_channel(self) -> fidl::Channel {
977 self.client.into_channel()
978 }
979
980 pub fn wait_for_event(
983 &self,
984 deadline: zx::MonotonicInstant,
985 ) -> Result<MessageSourceEvent, fidl::Error> {
986 MessageSourceEvent::decode(self.client.wait_for_event(deadline)?)
987 }
988
989 pub fn r#receive_messages(
990 &self,
991 mut socket: fidl::Socket,
992 ___deadline: zx::MonotonicInstant,
993 ) -> Result<(), fidl::Error> {
994 let _response = self
995 .client
996 .send_query::<MessageSourceReceiveMessagesRequest, fidl::encoding::EmptyPayload>(
997 (socket,),
998 0x23351bdac594c749,
999 fidl::encoding::DynamicFlags::empty(),
1000 ___deadline,
1001 )?;
1002 Ok(_response)
1003 }
1004
1005 pub fn r#receive_baton(
1006 &self,
1007 ___deadline: zx::MonotonicInstant,
1008 ) -> Result<LeaseBaton, fidl::Error> {
1009 let _response = self.client.send_query::<fidl::encoding::EmptyPayload, LeaseBaton>(
1010 (),
1011 0x18ed150a92dd23ee,
1012 fidl::encoding::DynamicFlags::empty(),
1013 ___deadline,
1014 )?;
1015 Ok(_response)
1016 }
1017}
1018
1019#[cfg(target_os = "fuchsia")]
1020impl From<MessageSourceSynchronousProxy> for zx::Handle {
1021 fn from(value: MessageSourceSynchronousProxy) -> Self {
1022 value.into_channel().into()
1023 }
1024}
1025
1026#[cfg(target_os = "fuchsia")]
1027impl From<fidl::Channel> for MessageSourceSynchronousProxy {
1028 fn from(value: fidl::Channel) -> Self {
1029 Self::new(value)
1030 }
1031}
1032
1033#[cfg(target_os = "fuchsia")]
1034impl fidl::endpoints::FromClient for MessageSourceSynchronousProxy {
1035 type Protocol = MessageSourceMarker;
1036
1037 fn from_client(value: fidl::endpoints::ClientEnd<MessageSourceMarker>) -> Self {
1038 Self::new(value.into_channel())
1039 }
1040}
1041
1042#[derive(Debug, Clone)]
1043pub struct MessageSourceProxy {
1044 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1045}
1046
1047impl fidl::endpoints::Proxy for MessageSourceProxy {
1048 type Protocol = MessageSourceMarker;
1049
1050 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1051 Self::new(inner)
1052 }
1053
1054 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1055 self.client.into_channel().map_err(|client| Self { client })
1056 }
1057
1058 fn as_channel(&self) -> &::fidl::AsyncChannel {
1059 self.client.as_channel()
1060 }
1061}
1062
1063impl MessageSourceProxy {
1064 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1066 let protocol_name = <MessageSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1067 Self { client: fidl::client::Client::new(channel, protocol_name) }
1068 }
1069
1070 pub fn take_event_stream(&self) -> MessageSourceEventStream {
1076 MessageSourceEventStream { event_receiver: self.client.take_event_receiver() }
1077 }
1078
1079 pub fn r#receive_messages(
1080 &self,
1081 mut socket: fidl::Socket,
1082 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1083 MessageSourceProxyInterface::r#receive_messages(self, socket)
1084 }
1085
1086 pub fn r#receive_baton(
1087 &self,
1088 ) -> fidl::client::QueryResponseFut<LeaseBaton, fidl::encoding::DefaultFuchsiaResourceDialect>
1089 {
1090 MessageSourceProxyInterface::r#receive_baton(self)
1091 }
1092}
1093
1094impl MessageSourceProxyInterface for MessageSourceProxy {
1095 type ReceiveMessagesResponseFut =
1096 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1097 fn r#receive_messages(&self, mut socket: fidl::Socket) -> Self::ReceiveMessagesResponseFut {
1098 fn _decode(
1099 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1100 ) -> Result<(), fidl::Error> {
1101 let _response = fidl::client::decode_transaction_body::<
1102 fidl::encoding::EmptyPayload,
1103 fidl::encoding::DefaultFuchsiaResourceDialect,
1104 0x23351bdac594c749,
1105 >(_buf?)?;
1106 Ok(_response)
1107 }
1108 self.client.send_query_and_decode::<MessageSourceReceiveMessagesRequest, ()>(
1109 (socket,),
1110 0x23351bdac594c749,
1111 fidl::encoding::DynamicFlags::empty(),
1112 _decode,
1113 )
1114 }
1115
1116 type ReceiveBatonResponseFut =
1117 fidl::client::QueryResponseFut<LeaseBaton, fidl::encoding::DefaultFuchsiaResourceDialect>;
1118 fn r#receive_baton(&self) -> Self::ReceiveBatonResponseFut {
1119 fn _decode(
1120 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1121 ) -> Result<LeaseBaton, fidl::Error> {
1122 let _response = fidl::client::decode_transaction_body::<
1123 LeaseBaton,
1124 fidl::encoding::DefaultFuchsiaResourceDialect,
1125 0x18ed150a92dd23ee,
1126 >(_buf?)?;
1127 Ok(_response)
1128 }
1129 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, LeaseBaton>(
1130 (),
1131 0x18ed150a92dd23ee,
1132 fidl::encoding::DynamicFlags::empty(),
1133 _decode,
1134 )
1135 }
1136}
1137
1138pub struct MessageSourceEventStream {
1139 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1140}
1141
1142impl std::marker::Unpin for MessageSourceEventStream {}
1143
1144impl futures::stream::FusedStream for MessageSourceEventStream {
1145 fn is_terminated(&self) -> bool {
1146 self.event_receiver.is_terminated()
1147 }
1148}
1149
1150impl futures::Stream for MessageSourceEventStream {
1151 type Item = Result<MessageSourceEvent, fidl::Error>;
1152
1153 fn poll_next(
1154 mut self: std::pin::Pin<&mut Self>,
1155 cx: &mut std::task::Context<'_>,
1156 ) -> std::task::Poll<Option<Self::Item>> {
1157 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1158 &mut self.event_receiver,
1159 cx
1160 )?) {
1161 Some(buf) => std::task::Poll::Ready(Some(MessageSourceEvent::decode(buf))),
1162 None => std::task::Poll::Ready(None),
1163 }
1164 }
1165}
1166
1167#[derive(Debug)]
1168pub enum MessageSourceEvent {}
1169
1170impl MessageSourceEvent {
1171 fn decode(
1173 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1174 ) -> Result<MessageSourceEvent, fidl::Error> {
1175 let (bytes, _handles) = buf.split_mut();
1176 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1177 debug_assert_eq!(tx_header.tx_id, 0);
1178 match tx_header.ordinal {
1179 _ => Err(fidl::Error::UnknownOrdinal {
1180 ordinal: tx_header.ordinal,
1181 protocol_name: <MessageSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1182 }),
1183 }
1184 }
1185}
1186
1187pub struct MessageSourceRequestStream {
1189 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1190 is_terminated: bool,
1191}
1192
1193impl std::marker::Unpin for MessageSourceRequestStream {}
1194
1195impl futures::stream::FusedStream for MessageSourceRequestStream {
1196 fn is_terminated(&self) -> bool {
1197 self.is_terminated
1198 }
1199}
1200
1201impl fidl::endpoints::RequestStream for MessageSourceRequestStream {
1202 type Protocol = MessageSourceMarker;
1203 type ControlHandle = MessageSourceControlHandle;
1204
1205 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1206 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1207 }
1208
1209 fn control_handle(&self) -> Self::ControlHandle {
1210 MessageSourceControlHandle { inner: self.inner.clone() }
1211 }
1212
1213 fn into_inner(
1214 self,
1215 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1216 {
1217 (self.inner, self.is_terminated)
1218 }
1219
1220 fn from_inner(
1221 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1222 is_terminated: bool,
1223 ) -> Self {
1224 Self { inner, is_terminated }
1225 }
1226}
1227
1228impl futures::Stream for MessageSourceRequestStream {
1229 type Item = Result<MessageSourceRequest, fidl::Error>;
1230
1231 fn poll_next(
1232 mut self: std::pin::Pin<&mut Self>,
1233 cx: &mut std::task::Context<'_>,
1234 ) -> std::task::Poll<Option<Self::Item>> {
1235 let this = &mut *self;
1236 if this.inner.check_shutdown(cx) {
1237 this.is_terminated = true;
1238 return std::task::Poll::Ready(None);
1239 }
1240 if this.is_terminated {
1241 panic!("polled MessageSourceRequestStream after completion");
1242 }
1243 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1244 |bytes, handles| {
1245 match this.inner.channel().read_etc(cx, bytes, handles) {
1246 std::task::Poll::Ready(Ok(())) => {}
1247 std::task::Poll::Pending => return std::task::Poll::Pending,
1248 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1249 this.is_terminated = true;
1250 return std::task::Poll::Ready(None);
1251 }
1252 std::task::Poll::Ready(Err(e)) => {
1253 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1254 e.into(),
1255 ))))
1256 }
1257 }
1258
1259 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1261
1262 std::task::Poll::Ready(Some(match header.ordinal {
1263 0x23351bdac594c749 => {
1264 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1265 let mut req = fidl::new_empty!(
1266 MessageSourceReceiveMessagesRequest,
1267 fidl::encoding::DefaultFuchsiaResourceDialect
1268 );
1269 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MessageSourceReceiveMessagesRequest>(&header, _body_bytes, handles, &mut req)?;
1270 let control_handle =
1271 MessageSourceControlHandle { inner: this.inner.clone() };
1272 Ok(MessageSourceRequest::ReceiveMessages {
1273 socket: req.socket,
1274
1275 responder: MessageSourceReceiveMessagesResponder {
1276 control_handle: std::mem::ManuallyDrop::new(control_handle),
1277 tx_id: header.tx_id,
1278 },
1279 })
1280 }
1281 0x18ed150a92dd23ee => {
1282 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1283 let mut req = fidl::new_empty!(
1284 fidl::encoding::EmptyPayload,
1285 fidl::encoding::DefaultFuchsiaResourceDialect
1286 );
1287 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1288 let control_handle =
1289 MessageSourceControlHandle { inner: this.inner.clone() };
1290 Ok(MessageSourceRequest::ReceiveBaton {
1291 responder: MessageSourceReceiveBatonResponder {
1292 control_handle: std::mem::ManuallyDrop::new(control_handle),
1293 tx_id: header.tx_id,
1294 },
1295 })
1296 }
1297 _ => Err(fidl::Error::UnknownOrdinal {
1298 ordinal: header.ordinal,
1299 protocol_name:
1300 <MessageSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1301 }),
1302 }))
1303 },
1304 )
1305 }
1306}
1307
1308#[derive(Debug)]
1309pub enum MessageSourceRequest {
1310 ReceiveMessages { socket: fidl::Socket, responder: MessageSourceReceiveMessagesResponder },
1311 ReceiveBaton { responder: MessageSourceReceiveBatonResponder },
1312}
1313
1314impl MessageSourceRequest {
1315 #[allow(irrefutable_let_patterns)]
1316 pub fn into_receive_messages(
1317 self,
1318 ) -> Option<(fidl::Socket, MessageSourceReceiveMessagesResponder)> {
1319 if let MessageSourceRequest::ReceiveMessages { socket, responder } = self {
1320 Some((socket, responder))
1321 } else {
1322 None
1323 }
1324 }
1325
1326 #[allow(irrefutable_let_patterns)]
1327 pub fn into_receive_baton(self) -> Option<(MessageSourceReceiveBatonResponder)> {
1328 if let MessageSourceRequest::ReceiveBaton { responder } = self {
1329 Some((responder))
1330 } else {
1331 None
1332 }
1333 }
1334
1335 pub fn method_name(&self) -> &'static str {
1337 match *self {
1338 MessageSourceRequest::ReceiveMessages { .. } => "receive_messages",
1339 MessageSourceRequest::ReceiveBaton { .. } => "receive_baton",
1340 }
1341 }
1342}
1343
1344#[derive(Debug, Clone)]
1345pub struct MessageSourceControlHandle {
1346 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1347}
1348
1349impl fidl::endpoints::ControlHandle for MessageSourceControlHandle {
1350 fn shutdown(&self) {
1351 self.inner.shutdown()
1352 }
1353 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1354 self.inner.shutdown_with_epitaph(status)
1355 }
1356
1357 fn is_closed(&self) -> bool {
1358 self.inner.channel().is_closed()
1359 }
1360 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1361 self.inner.channel().on_closed()
1362 }
1363
1364 #[cfg(target_os = "fuchsia")]
1365 fn signal_peer(
1366 &self,
1367 clear_mask: zx::Signals,
1368 set_mask: zx::Signals,
1369 ) -> Result<(), zx_status::Status> {
1370 use fidl::Peered;
1371 self.inner.channel().signal_peer(clear_mask, set_mask)
1372 }
1373}
1374
1375impl MessageSourceControlHandle {}
1376
1377#[must_use = "FIDL methods require a response to be sent"]
1378#[derive(Debug)]
1379pub struct MessageSourceReceiveMessagesResponder {
1380 control_handle: std::mem::ManuallyDrop<MessageSourceControlHandle>,
1381 tx_id: u32,
1382}
1383
1384impl std::ops::Drop for MessageSourceReceiveMessagesResponder {
1388 fn drop(&mut self) {
1389 self.control_handle.shutdown();
1390 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1392 }
1393}
1394
1395impl fidl::endpoints::Responder for MessageSourceReceiveMessagesResponder {
1396 type ControlHandle = MessageSourceControlHandle;
1397
1398 fn control_handle(&self) -> &MessageSourceControlHandle {
1399 &self.control_handle
1400 }
1401
1402 fn drop_without_shutdown(mut self) {
1403 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1405 std::mem::forget(self);
1407 }
1408}
1409
1410impl MessageSourceReceiveMessagesResponder {
1411 pub fn send(self) -> Result<(), fidl::Error> {
1415 let _result = self.send_raw();
1416 if _result.is_err() {
1417 self.control_handle.shutdown();
1418 }
1419 self.drop_without_shutdown();
1420 _result
1421 }
1422
1423 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1425 let _result = self.send_raw();
1426 self.drop_without_shutdown();
1427 _result
1428 }
1429
1430 fn send_raw(&self) -> Result<(), fidl::Error> {
1431 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1432 (),
1433 self.tx_id,
1434 0x23351bdac594c749,
1435 fidl::encoding::DynamicFlags::empty(),
1436 )
1437 }
1438}
1439
1440#[must_use = "FIDL methods require a response to be sent"]
1441#[derive(Debug)]
1442pub struct MessageSourceReceiveBatonResponder {
1443 control_handle: std::mem::ManuallyDrop<MessageSourceControlHandle>,
1444 tx_id: u32,
1445}
1446
1447impl std::ops::Drop for MessageSourceReceiveBatonResponder {
1451 fn drop(&mut self) {
1452 self.control_handle.shutdown();
1453 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1455 }
1456}
1457
1458impl fidl::endpoints::Responder for MessageSourceReceiveBatonResponder {
1459 type ControlHandle = MessageSourceControlHandle;
1460
1461 fn control_handle(&self) -> &MessageSourceControlHandle {
1462 &self.control_handle
1463 }
1464
1465 fn drop_without_shutdown(mut self) {
1466 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1468 std::mem::forget(self);
1470 }
1471}
1472
1473impl MessageSourceReceiveBatonResponder {
1474 pub fn send(self, mut payload: LeaseBaton) -> Result<(), fidl::Error> {
1478 let _result = self.send_raw(payload);
1479 if _result.is_err() {
1480 self.control_handle.shutdown();
1481 }
1482 self.drop_without_shutdown();
1483 _result
1484 }
1485
1486 pub fn send_no_shutdown_on_err(self, mut payload: LeaseBaton) -> Result<(), fidl::Error> {
1488 let _result = self.send_raw(payload);
1489 self.drop_without_shutdown();
1490 _result
1491 }
1492
1493 fn send_raw(&self, mut payload: LeaseBaton) -> Result<(), fidl::Error> {
1494 self.control_handle.inner.send::<LeaseBaton>(
1495 &mut payload,
1496 self.tx_id,
1497 0x18ed150a92dd23ee,
1498 fidl::encoding::DynamicFlags::empty(),
1499 )
1500 }
1501}
1502
1503mod internal {
1504 use super::*;
1505
1506 impl fidl::encoding::ResourceTypeMarker for MessageSourceReceiveMessagesRequest {
1507 type Borrowed<'a> = &'a mut Self;
1508 fn take_or_borrow<'a>(
1509 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1510 ) -> Self::Borrowed<'a> {
1511 value
1512 }
1513 }
1514
1515 unsafe impl fidl::encoding::TypeMarker for MessageSourceReceiveMessagesRequest {
1516 type Owned = Self;
1517
1518 #[inline(always)]
1519 fn inline_align(_context: fidl::encoding::Context) -> usize {
1520 4
1521 }
1522
1523 #[inline(always)]
1524 fn inline_size(_context: fidl::encoding::Context) -> usize {
1525 4
1526 }
1527 }
1528
1529 unsafe impl
1530 fidl::encoding::Encode<
1531 MessageSourceReceiveMessagesRequest,
1532 fidl::encoding::DefaultFuchsiaResourceDialect,
1533 > for &mut MessageSourceReceiveMessagesRequest
1534 {
1535 #[inline]
1536 unsafe fn encode(
1537 self,
1538 encoder: &mut fidl::encoding::Encoder<
1539 '_,
1540 fidl::encoding::DefaultFuchsiaResourceDialect,
1541 >,
1542 offset: usize,
1543 _depth: fidl::encoding::Depth,
1544 ) -> fidl::Result<()> {
1545 encoder.debug_check_bounds::<MessageSourceReceiveMessagesRequest>(offset);
1546 fidl::encoding::Encode::<
1548 MessageSourceReceiveMessagesRequest,
1549 fidl::encoding::DefaultFuchsiaResourceDialect,
1550 >::encode(
1551 (<fidl::encoding::HandleType<
1552 fidl::Socket,
1553 { fidl::ObjectType::SOCKET.into_raw() },
1554 2147483648,
1555 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1556 &mut self.socket
1557 ),),
1558 encoder,
1559 offset,
1560 _depth,
1561 )
1562 }
1563 }
1564 unsafe impl<
1565 T0: fidl::encoding::Encode<
1566 fidl::encoding::HandleType<
1567 fidl::Socket,
1568 { fidl::ObjectType::SOCKET.into_raw() },
1569 2147483648,
1570 >,
1571 fidl::encoding::DefaultFuchsiaResourceDialect,
1572 >,
1573 >
1574 fidl::encoding::Encode<
1575 MessageSourceReceiveMessagesRequest,
1576 fidl::encoding::DefaultFuchsiaResourceDialect,
1577 > for (T0,)
1578 {
1579 #[inline]
1580 unsafe fn encode(
1581 self,
1582 encoder: &mut fidl::encoding::Encoder<
1583 '_,
1584 fidl::encoding::DefaultFuchsiaResourceDialect,
1585 >,
1586 offset: usize,
1587 depth: fidl::encoding::Depth,
1588 ) -> fidl::Result<()> {
1589 encoder.debug_check_bounds::<MessageSourceReceiveMessagesRequest>(offset);
1590 self.0.encode(encoder, offset + 0, depth)?;
1594 Ok(())
1595 }
1596 }
1597
1598 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1599 for MessageSourceReceiveMessagesRequest
1600 {
1601 #[inline(always)]
1602 fn new_empty() -> Self {
1603 Self {
1604 socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1605 }
1606 }
1607
1608 #[inline]
1609 unsafe fn decode(
1610 &mut self,
1611 decoder: &mut fidl::encoding::Decoder<
1612 '_,
1613 fidl::encoding::DefaultFuchsiaResourceDialect,
1614 >,
1615 offset: usize,
1616 _depth: fidl::encoding::Depth,
1617 ) -> fidl::Result<()> {
1618 decoder.debug_check_bounds::<Self>(offset);
1619 fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
1621 Ok(())
1622 }
1623 }
1624
1625 impl LeaseBaton {
1626 #[inline(always)]
1627 fn max_ordinal_present(&self) -> u64 {
1628 if let Some(_) = self.msg_index {
1629 return 2;
1630 }
1631 if let Some(_) = self.lease {
1632 return 1;
1633 }
1634 0
1635 }
1636 }
1637
1638 impl fidl::encoding::ResourceTypeMarker for LeaseBaton {
1639 type Borrowed<'a> = &'a mut Self;
1640 fn take_or_borrow<'a>(
1641 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1642 ) -> Self::Borrowed<'a> {
1643 value
1644 }
1645 }
1646
1647 unsafe impl fidl::encoding::TypeMarker for LeaseBaton {
1648 type Owned = Self;
1649
1650 #[inline(always)]
1651 fn inline_align(_context: fidl::encoding::Context) -> usize {
1652 8
1653 }
1654
1655 #[inline(always)]
1656 fn inline_size(_context: fidl::encoding::Context) -> usize {
1657 16
1658 }
1659 }
1660
1661 unsafe impl fidl::encoding::Encode<LeaseBaton, fidl::encoding::DefaultFuchsiaResourceDialect>
1662 for &mut LeaseBaton
1663 {
1664 unsafe fn encode(
1665 self,
1666 encoder: &mut fidl::encoding::Encoder<
1667 '_,
1668 fidl::encoding::DefaultFuchsiaResourceDialect,
1669 >,
1670 offset: usize,
1671 mut depth: fidl::encoding::Depth,
1672 ) -> fidl::Result<()> {
1673 encoder.debug_check_bounds::<LeaseBaton>(offset);
1674 let max_ordinal: u64 = self.max_ordinal_present();
1676 encoder.write_num(max_ordinal, offset);
1677 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1678 if max_ordinal == 0 {
1680 return Ok(());
1681 }
1682 depth.increment()?;
1683 let envelope_size = 8;
1684 let bytes_len = max_ordinal as usize * envelope_size;
1685 #[allow(unused_variables)]
1686 let offset = encoder.out_of_line_offset(bytes_len);
1687 let mut _prev_end_offset: usize = 0;
1688 if 1 > max_ordinal {
1689 return Ok(());
1690 }
1691
1692 let cur_offset: usize = (1 - 1) * envelope_size;
1695
1696 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1698
1699 fidl::encoding::encode_in_envelope_optional::<
1704 fidl::encoding::HandleType<
1705 fidl::EventPair,
1706 { fidl::ObjectType::EVENTPAIR.into_raw() },
1707 2147483648,
1708 >,
1709 fidl::encoding::DefaultFuchsiaResourceDialect,
1710 >(
1711 self.lease.as_mut().map(
1712 <fidl::encoding::HandleType<
1713 fidl::EventPair,
1714 { fidl::ObjectType::EVENTPAIR.into_raw() },
1715 2147483648,
1716 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1717 ),
1718 encoder,
1719 offset + cur_offset,
1720 depth,
1721 )?;
1722
1723 _prev_end_offset = cur_offset + envelope_size;
1724 if 2 > max_ordinal {
1725 return Ok(());
1726 }
1727
1728 let cur_offset: usize = (2 - 1) * envelope_size;
1731
1732 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1734
1735 fidl::encoding::encode_in_envelope_optional::<
1740 u64,
1741 fidl::encoding::DefaultFuchsiaResourceDialect,
1742 >(
1743 self.msg_index.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1744 encoder,
1745 offset + cur_offset,
1746 depth,
1747 )?;
1748
1749 _prev_end_offset = cur_offset + envelope_size;
1750
1751 Ok(())
1752 }
1753 }
1754
1755 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for LeaseBaton {
1756 #[inline(always)]
1757 fn new_empty() -> Self {
1758 Self::default()
1759 }
1760
1761 unsafe fn decode(
1762 &mut self,
1763 decoder: &mut fidl::encoding::Decoder<
1764 '_,
1765 fidl::encoding::DefaultFuchsiaResourceDialect,
1766 >,
1767 offset: usize,
1768 mut depth: fidl::encoding::Depth,
1769 ) -> fidl::Result<()> {
1770 decoder.debug_check_bounds::<Self>(offset);
1771 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1772 None => return Err(fidl::Error::NotNullable),
1773 Some(len) => len,
1774 };
1775 if len == 0 {
1777 return Ok(());
1778 };
1779 depth.increment()?;
1780 let envelope_size = 8;
1781 let bytes_len = len * envelope_size;
1782 let offset = decoder.out_of_line_offset(bytes_len)?;
1783 let mut _next_ordinal_to_read = 0;
1785 let mut next_offset = offset;
1786 let end_offset = offset + bytes_len;
1787 _next_ordinal_to_read += 1;
1788 if next_offset >= end_offset {
1789 return Ok(());
1790 }
1791
1792 while _next_ordinal_to_read < 1 {
1794 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1795 _next_ordinal_to_read += 1;
1796 next_offset += envelope_size;
1797 }
1798
1799 let next_out_of_line = decoder.next_out_of_line();
1800 let handles_before = decoder.remaining_handles();
1801 if let Some((inlined, num_bytes, num_handles)) =
1802 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1803 {
1804 let member_inline_size = <fidl::encoding::HandleType<
1805 fidl::EventPair,
1806 { fidl::ObjectType::EVENTPAIR.into_raw() },
1807 2147483648,
1808 > as fidl::encoding::TypeMarker>::inline_size(
1809 decoder.context
1810 );
1811 if inlined != (member_inline_size <= 4) {
1812 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1813 }
1814 let inner_offset;
1815 let mut inner_depth = depth.clone();
1816 if inlined {
1817 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1818 inner_offset = next_offset;
1819 } else {
1820 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1821 inner_depth.increment()?;
1822 }
1823 let val_ref =
1824 self.lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
1825 fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1826 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1827 {
1828 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1829 }
1830 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1831 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1832 }
1833 }
1834
1835 next_offset += envelope_size;
1836 _next_ordinal_to_read += 1;
1837 if next_offset >= end_offset {
1838 return Ok(());
1839 }
1840
1841 while _next_ordinal_to_read < 2 {
1843 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1844 _next_ordinal_to_read += 1;
1845 next_offset += envelope_size;
1846 }
1847
1848 let next_out_of_line = decoder.next_out_of_line();
1849 let handles_before = decoder.remaining_handles();
1850 if let Some((inlined, num_bytes, num_handles)) =
1851 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1852 {
1853 let member_inline_size =
1854 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1855 if inlined != (member_inline_size <= 4) {
1856 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1857 }
1858 let inner_offset;
1859 let mut inner_depth = depth.clone();
1860 if inlined {
1861 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1862 inner_offset = next_offset;
1863 } else {
1864 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1865 inner_depth.increment()?;
1866 }
1867 let val_ref = self.msg_index.get_or_insert_with(|| {
1868 fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
1869 });
1870 fidl::decode!(
1871 u64,
1872 fidl::encoding::DefaultFuchsiaResourceDialect,
1873 val_ref,
1874 decoder,
1875 inner_offset,
1876 inner_depth
1877 )?;
1878 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1879 {
1880 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1881 }
1882 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1883 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1884 }
1885 }
1886
1887 next_offset += envelope_size;
1888
1889 while next_offset < end_offset {
1891 _next_ordinal_to_read += 1;
1892 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1893 next_offset += envelope_size;
1894 }
1895
1896 Ok(())
1897 }
1898 }
1899}