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