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 { Some((responder)) } else { None }
479 }
480
481 pub fn method_name(&self) -> &'static str {
483 match *self {
484 RtcRequest::PersistentDisable { .. } => "persistent_disable",
485 RtcRequest::PersistentEnable { .. } => "persistent_enable",
486 }
487 }
488}
489
490#[derive(Debug, Clone)]
491pub struct RtcControlHandle {
492 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
493}
494
495impl fidl::endpoints::ControlHandle for RtcControlHandle {
496 fn shutdown(&self) {
497 self.inner.shutdown()
498 }
499 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
500 self.inner.shutdown_with_epitaph(status)
501 }
502
503 fn is_closed(&self) -> bool {
504 self.inner.channel().is_closed()
505 }
506 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
507 self.inner.channel().on_closed()
508 }
509
510 #[cfg(target_os = "fuchsia")]
511 fn signal_peer(
512 &self,
513 clear_mask: zx::Signals,
514 set_mask: zx::Signals,
515 ) -> Result<(), zx_status::Status> {
516 use fidl::Peered;
517 self.inner.channel().signal_peer(clear_mask, set_mask)
518 }
519}
520
521impl RtcControlHandle {}
522
523#[must_use = "FIDL methods require a response to be sent"]
524#[derive(Debug)]
525pub struct RtcPersistentDisableResponder {
526 control_handle: std::mem::ManuallyDrop<RtcControlHandle>,
527 tx_id: u32,
528}
529
530impl std::ops::Drop for RtcPersistentDisableResponder {
534 fn drop(&mut self) {
535 self.control_handle.shutdown();
536 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
538 }
539}
540
541impl fidl::endpoints::Responder for RtcPersistentDisableResponder {
542 type ControlHandle = RtcControlHandle;
543
544 fn control_handle(&self) -> &RtcControlHandle {
545 &self.control_handle
546 }
547
548 fn drop_without_shutdown(mut self) {
549 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
551 std::mem::forget(self);
553 }
554}
555
556impl RtcPersistentDisableResponder {
557 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
561 let _result = self.send_raw(result);
562 if _result.is_err() {
563 self.control_handle.shutdown();
564 }
565 self.drop_without_shutdown();
566 _result
567 }
568
569 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
571 let _result = self.send_raw(result);
572 self.drop_without_shutdown();
573 _result
574 }
575
576 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
577 self.control_handle
578 .inner
579 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
580 result,
581 self.tx_id,
582 0x5773843d951f61c4,
583 fidl::encoding::DynamicFlags::empty(),
584 )
585 }
586}
587
588#[must_use = "FIDL methods require a response to be sent"]
589#[derive(Debug)]
590pub struct RtcPersistentEnableResponder {
591 control_handle: std::mem::ManuallyDrop<RtcControlHandle>,
592 tx_id: u32,
593}
594
595impl std::ops::Drop for RtcPersistentEnableResponder {
599 fn drop(&mut self) {
600 self.control_handle.shutdown();
601 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
603 }
604}
605
606impl fidl::endpoints::Responder for RtcPersistentEnableResponder {
607 type ControlHandle = RtcControlHandle;
608
609 fn control_handle(&self) -> &RtcControlHandle {
610 &self.control_handle
611 }
612
613 fn drop_without_shutdown(mut self) {
614 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
616 std::mem::forget(self);
618 }
619}
620
621impl RtcPersistentEnableResponder {
622 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
626 let _result = self.send_raw(result);
627 if _result.is_err() {
628 self.control_handle.shutdown();
629 }
630 self.drop_without_shutdown();
631 _result
632 }
633
634 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
636 let _result = self.send_raw(result);
637 self.drop_without_shutdown();
638 _result
639 }
640
641 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
642 self.control_handle
643 .inner
644 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
645 result,
646 self.tx_id,
647 0x6fca18e78537c228,
648 fidl::encoding::DynamicFlags::empty(),
649 )
650 }
651}
652
653mod internal {
654 use super::*;
655}