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