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