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_time_test__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct RtcMarker;
16
17impl fidl::endpoints::ProtocolMarker for RtcMarker {
18 type Proxy = RtcProxy;
19 type RequestStream = RtcRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = RtcSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.time.test.Rtc";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for RtcMarker {}
26pub type RtcPersistentDisableResult = Result<(), Error>;
27pub type RtcPersistentEnableResult = Result<(), Error>;
28
29pub trait RtcProxyInterface: Send + Sync {
30 type PersistentDisableResponseFut: std::future::Future<Output = Result<RtcPersistentDisableResult, fidl::Error>>
31 + Send;
32 fn r#persistent_disable(&self) -> Self::PersistentDisableResponseFut;
33 type PersistentEnableResponseFut: std::future::Future<Output = Result<RtcPersistentEnableResult, fidl::Error>>
34 + Send;
35 fn r#persistent_enable(&self) -> Self::PersistentEnableResponseFut;
36}
37#[derive(Debug)]
38#[cfg(target_os = "fuchsia")]
39pub struct RtcSynchronousProxy {
40 client: fidl::client::sync::Client,
41}
42
43#[cfg(target_os = "fuchsia")]
44impl fidl::endpoints::SynchronousProxy for RtcSynchronousProxy {
45 type Proxy = RtcProxy;
46 type Protocol = RtcMarker;
47
48 fn from_channel(inner: fidl::Channel) -> Self {
49 Self::new(inner)
50 }
51
52 fn into_channel(self) -> fidl::Channel {
53 self.client.into_channel()
54 }
55
56 fn as_channel(&self) -> &fidl::Channel {
57 self.client.as_channel()
58 }
59}
60
61#[cfg(target_os = "fuchsia")]
62impl RtcSynchronousProxy {
63 pub fn new(channel: fidl::Channel) -> Self {
64 let protocol_name = <RtcMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
65 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
66 }
67
68 pub fn into_channel(self) -> fidl::Channel {
69 self.client.into_channel()
70 }
71
72 pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<RtcEvent, fidl::Error> {
75 RtcEvent::decode(self.client.wait_for_event(deadline)?)
76 }
77
78 pub fn r#persistent_disable(
92 &self,
93 ___deadline: zx::MonotonicInstant,
94 ) -> Result<RtcPersistentDisableResult, fidl::Error> {
95 let _response = self.client.send_query::<
96 fidl::encoding::EmptyPayload,
97 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
98 >(
99 (),
100 0x5773843d951f61c4,
101 fidl::encoding::DynamicFlags::empty(),
102 ___deadline,
103 )?;
104 Ok(_response.map(|x| x))
105 }
106
107 pub fn r#persistent_enable(
112 &self,
113 ___deadline: zx::MonotonicInstant,
114 ) -> Result<RtcPersistentEnableResult, fidl::Error> {
115 let _response = self.client.send_query::<
116 fidl::encoding::EmptyPayload,
117 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
118 >(
119 (),
120 0x6fca18e78537c228,
121 fidl::encoding::DynamicFlags::empty(),
122 ___deadline,
123 )?;
124 Ok(_response.map(|x| x))
125 }
126}
127
128#[cfg(target_os = "fuchsia")]
129impl From<RtcSynchronousProxy> for zx::Handle {
130 fn from(value: RtcSynchronousProxy) -> Self {
131 value.into_channel().into()
132 }
133}
134
135#[cfg(target_os = "fuchsia")]
136impl From<fidl::Channel> for RtcSynchronousProxy {
137 fn from(value: fidl::Channel) -> Self {
138 Self::new(value)
139 }
140}
141
142#[cfg(target_os = "fuchsia")]
143impl fidl::endpoints::FromClient for RtcSynchronousProxy {
144 type Protocol = RtcMarker;
145
146 fn from_client(value: fidl::endpoints::ClientEnd<RtcMarker>) -> Self {
147 Self::new(value.into_channel())
148 }
149}
150
151#[derive(Debug, Clone)]
152pub struct RtcProxy {
153 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
154}
155
156impl fidl::endpoints::Proxy for RtcProxy {
157 type Protocol = RtcMarker;
158
159 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
160 Self::new(inner)
161 }
162
163 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
164 self.client.into_channel().map_err(|client| Self { client })
165 }
166
167 fn as_channel(&self) -> &::fidl::AsyncChannel {
168 self.client.as_channel()
169 }
170}
171
172impl RtcProxy {
173 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
175 let protocol_name = <RtcMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
176 Self { client: fidl::client::Client::new(channel, protocol_name) }
177 }
178
179 pub fn take_event_stream(&self) -> RtcEventStream {
185 RtcEventStream { event_receiver: self.client.take_event_receiver() }
186 }
187
188 pub fn r#persistent_disable(
202 &self,
203 ) -> fidl::client::QueryResponseFut<
204 RtcPersistentDisableResult,
205 fidl::encoding::DefaultFuchsiaResourceDialect,
206 > {
207 RtcProxyInterface::r#persistent_disable(self)
208 }
209
210 pub fn r#persistent_enable(
215 &self,
216 ) -> fidl::client::QueryResponseFut<
217 RtcPersistentEnableResult,
218 fidl::encoding::DefaultFuchsiaResourceDialect,
219 > {
220 RtcProxyInterface::r#persistent_enable(self)
221 }
222}
223
224impl RtcProxyInterface for RtcProxy {
225 type PersistentDisableResponseFut = fidl::client::QueryResponseFut<
226 RtcPersistentDisableResult,
227 fidl::encoding::DefaultFuchsiaResourceDialect,
228 >;
229 fn r#persistent_disable(&self) -> Self::PersistentDisableResponseFut {
230 fn _decode(
231 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
232 ) -> Result<RtcPersistentDisableResult, fidl::Error> {
233 let _response = fidl::client::decode_transaction_body::<
234 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
235 fidl::encoding::DefaultFuchsiaResourceDialect,
236 0x5773843d951f61c4,
237 >(_buf?)?;
238 Ok(_response.map(|x| x))
239 }
240 self.client
241 .send_query_and_decode::<fidl::encoding::EmptyPayload, RtcPersistentDisableResult>(
242 (),
243 0x5773843d951f61c4,
244 fidl::encoding::DynamicFlags::empty(),
245 _decode,
246 )
247 }
248
249 type PersistentEnableResponseFut = fidl::client::QueryResponseFut<
250 RtcPersistentEnableResult,
251 fidl::encoding::DefaultFuchsiaResourceDialect,
252 >;
253 fn r#persistent_enable(&self) -> Self::PersistentEnableResponseFut {
254 fn _decode(
255 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
256 ) -> Result<RtcPersistentEnableResult, fidl::Error> {
257 let _response = fidl::client::decode_transaction_body::<
258 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
259 fidl::encoding::DefaultFuchsiaResourceDialect,
260 0x6fca18e78537c228,
261 >(_buf?)?;
262 Ok(_response.map(|x| x))
263 }
264 self.client
265 .send_query_and_decode::<fidl::encoding::EmptyPayload, RtcPersistentEnableResult>(
266 (),
267 0x6fca18e78537c228,
268 fidl::encoding::DynamicFlags::empty(),
269 _decode,
270 )
271 }
272}
273
274pub struct RtcEventStream {
275 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
276}
277
278impl std::marker::Unpin for RtcEventStream {}
279
280impl futures::stream::FusedStream for RtcEventStream {
281 fn is_terminated(&self) -> bool {
282 self.event_receiver.is_terminated()
283 }
284}
285
286impl futures::Stream for RtcEventStream {
287 type Item = Result<RtcEvent, fidl::Error>;
288
289 fn poll_next(
290 mut self: std::pin::Pin<&mut Self>,
291 cx: &mut std::task::Context<'_>,
292 ) -> std::task::Poll<Option<Self::Item>> {
293 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
294 &mut self.event_receiver,
295 cx
296 )?) {
297 Some(buf) => std::task::Poll::Ready(Some(RtcEvent::decode(buf))),
298 None => std::task::Poll::Ready(None),
299 }
300 }
301}
302
303#[derive(Debug)]
304pub enum RtcEvent {}
305
306impl RtcEvent {
307 fn decode(
309 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
310 ) -> Result<RtcEvent, fidl::Error> {
311 let (bytes, _handles) = buf.split_mut();
312 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
313 debug_assert_eq!(tx_header.tx_id, 0);
314 match tx_header.ordinal {
315 _ => Err(fidl::Error::UnknownOrdinal {
316 ordinal: tx_header.ordinal,
317 protocol_name: <RtcMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
318 }),
319 }
320 }
321}
322
323pub struct RtcRequestStream {
325 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
326 is_terminated: bool,
327}
328
329impl std::marker::Unpin for RtcRequestStream {}
330
331impl futures::stream::FusedStream for RtcRequestStream {
332 fn is_terminated(&self) -> bool {
333 self.is_terminated
334 }
335}
336
337impl fidl::endpoints::RequestStream for RtcRequestStream {
338 type Protocol = RtcMarker;
339 type ControlHandle = RtcControlHandle;
340
341 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
342 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
343 }
344
345 fn control_handle(&self) -> Self::ControlHandle {
346 RtcControlHandle { inner: self.inner.clone() }
347 }
348
349 fn into_inner(
350 self,
351 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
352 {
353 (self.inner, self.is_terminated)
354 }
355
356 fn from_inner(
357 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
358 is_terminated: bool,
359 ) -> Self {
360 Self { inner, is_terminated }
361 }
362}
363
364impl futures::Stream for RtcRequestStream {
365 type Item = Result<RtcRequest, fidl::Error>;
366
367 fn poll_next(
368 mut self: std::pin::Pin<&mut Self>,
369 cx: &mut std::task::Context<'_>,
370 ) -> std::task::Poll<Option<Self::Item>> {
371 let this = &mut *self;
372 if this.inner.check_shutdown(cx) {
373 this.is_terminated = true;
374 return std::task::Poll::Ready(None);
375 }
376 if this.is_terminated {
377 panic!("polled RtcRequestStream after completion");
378 }
379 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
380 |bytes, handles| {
381 match this.inner.channel().read_etc(cx, bytes, handles) {
382 std::task::Poll::Ready(Ok(())) => {}
383 std::task::Poll::Pending => return std::task::Poll::Pending,
384 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
385 this.is_terminated = true;
386 return std::task::Poll::Ready(None);
387 }
388 std::task::Poll::Ready(Err(e)) => {
389 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
390 e.into(),
391 ))))
392 }
393 }
394
395 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
397
398 std::task::Poll::Ready(Some(match header.ordinal {
399 0x5773843d951f61c4 => {
400 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
401 let mut req = fidl::new_empty!(
402 fidl::encoding::EmptyPayload,
403 fidl::encoding::DefaultFuchsiaResourceDialect
404 );
405 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
406 let control_handle = RtcControlHandle { inner: this.inner.clone() };
407 Ok(RtcRequest::PersistentDisable {
408 responder: RtcPersistentDisableResponder {
409 control_handle: std::mem::ManuallyDrop::new(control_handle),
410 tx_id: header.tx_id,
411 },
412 })
413 }
414 0x6fca18e78537c228 => {
415 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
416 let mut req = fidl::new_empty!(
417 fidl::encoding::EmptyPayload,
418 fidl::encoding::DefaultFuchsiaResourceDialect
419 );
420 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
421 let control_handle = RtcControlHandle { inner: this.inner.clone() };
422 Ok(RtcRequest::PersistentEnable {
423 responder: RtcPersistentEnableResponder {
424 control_handle: std::mem::ManuallyDrop::new(control_handle),
425 tx_id: header.tx_id,
426 },
427 })
428 }
429 _ => Err(fidl::Error::UnknownOrdinal {
430 ordinal: header.ordinal,
431 protocol_name: <RtcMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
432 }),
433 }))
434 },
435 )
436 }
437}
438
439#[derive(Debug)]
444pub enum RtcRequest {
445 PersistentDisable { responder: RtcPersistentDisableResponder },
459 PersistentEnable { responder: RtcPersistentEnableResponder },
464}
465
466impl RtcRequest {
467 #[allow(irrefutable_let_patterns)]
468 pub fn into_persistent_disable(self) -> Option<(RtcPersistentDisableResponder)> {
469 if let RtcRequest::PersistentDisable { responder } = self {
470 Some((responder))
471 } else {
472 None
473 }
474 }
475
476 #[allow(irrefutable_let_patterns)]
477 pub fn into_persistent_enable(self) -> Option<(RtcPersistentEnableResponder)> {
478 if let RtcRequest::PersistentEnable { responder } = self {
479 Some((responder))
480 } else {
481 None
482 }
483 }
484
485 pub fn method_name(&self) -> &'static str {
487 match *self {
488 RtcRequest::PersistentDisable { .. } => "persistent_disable",
489 RtcRequest::PersistentEnable { .. } => "persistent_enable",
490 }
491 }
492}
493
494#[derive(Debug, Clone)]
495pub struct RtcControlHandle {
496 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
497}
498
499impl fidl::endpoints::ControlHandle for RtcControlHandle {
500 fn shutdown(&self) {
501 self.inner.shutdown()
502 }
503 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
504 self.inner.shutdown_with_epitaph(status)
505 }
506
507 fn is_closed(&self) -> bool {
508 self.inner.channel().is_closed()
509 }
510 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
511 self.inner.channel().on_closed()
512 }
513
514 #[cfg(target_os = "fuchsia")]
515 fn signal_peer(
516 &self,
517 clear_mask: zx::Signals,
518 set_mask: zx::Signals,
519 ) -> Result<(), zx_status::Status> {
520 use fidl::Peered;
521 self.inner.channel().signal_peer(clear_mask, set_mask)
522 }
523}
524
525impl RtcControlHandle {}
526
527#[must_use = "FIDL methods require a response to be sent"]
528#[derive(Debug)]
529pub struct RtcPersistentDisableResponder {
530 control_handle: std::mem::ManuallyDrop<RtcControlHandle>,
531 tx_id: u32,
532}
533
534impl std::ops::Drop for RtcPersistentDisableResponder {
538 fn drop(&mut self) {
539 self.control_handle.shutdown();
540 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
542 }
543}
544
545impl fidl::endpoints::Responder for RtcPersistentDisableResponder {
546 type ControlHandle = RtcControlHandle;
547
548 fn control_handle(&self) -> &RtcControlHandle {
549 &self.control_handle
550 }
551
552 fn drop_without_shutdown(mut self) {
553 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
555 std::mem::forget(self);
557 }
558}
559
560impl RtcPersistentDisableResponder {
561 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
565 let _result = self.send_raw(result);
566 if _result.is_err() {
567 self.control_handle.shutdown();
568 }
569 self.drop_without_shutdown();
570 _result
571 }
572
573 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
575 let _result = self.send_raw(result);
576 self.drop_without_shutdown();
577 _result
578 }
579
580 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
581 self.control_handle
582 .inner
583 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
584 result,
585 self.tx_id,
586 0x5773843d951f61c4,
587 fidl::encoding::DynamicFlags::empty(),
588 )
589 }
590}
591
592#[must_use = "FIDL methods require a response to be sent"]
593#[derive(Debug)]
594pub struct RtcPersistentEnableResponder {
595 control_handle: std::mem::ManuallyDrop<RtcControlHandle>,
596 tx_id: u32,
597}
598
599impl std::ops::Drop for RtcPersistentEnableResponder {
603 fn drop(&mut self) {
604 self.control_handle.shutdown();
605 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
607 }
608}
609
610impl fidl::endpoints::Responder for RtcPersistentEnableResponder {
611 type ControlHandle = RtcControlHandle;
612
613 fn control_handle(&self) -> &RtcControlHandle {
614 &self.control_handle
615 }
616
617 fn drop_without_shutdown(mut self) {
618 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
620 std::mem::forget(self);
622 }
623}
624
625impl RtcPersistentEnableResponder {
626 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
630 let _result = self.send_raw(result);
631 if _result.is_err() {
632 self.control_handle.shutdown();
633 }
634 self.drop_without_shutdown();
635 _result
636 }
637
638 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
640 let _result = self.send_raw(result);
641 self.drop_without_shutdown();
642 _result
643 }
644
645 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
646 self.control_handle
647 .inner
648 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
649 result,
650 self.tx_id,
651 0x6fca18e78537c228,
652 fidl::encoding::DynamicFlags::empty(),
653 )
654 }
655}
656
657mod internal {
658 use super::*;
659}