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_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct MaintenanceGetWritableUtcClockResponse {
16 pub utc_clock: fidl::Clock,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20 for MaintenanceGetWritableUtcClockResponse
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct MaintenanceMarker;
26
27impl fidl::endpoints::ProtocolMarker for MaintenanceMarker {
28 type Proxy = MaintenanceProxy;
29 type RequestStream = MaintenanceRequestStream;
30 #[cfg(target_os = "fuchsia")]
31 type SynchronousProxy = MaintenanceSynchronousProxy;
32
33 const DEBUG_NAME: &'static str = "fuchsia.time.Maintenance";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for MaintenanceMarker {}
36
37pub trait MaintenanceProxyInterface: Send + Sync {
38 type GetWritableUtcClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
39 + Send;
40 fn r#get_writable_utc_clock(&self) -> Self::GetWritableUtcClockResponseFut;
41}
42#[derive(Debug)]
43#[cfg(target_os = "fuchsia")]
44pub struct MaintenanceSynchronousProxy {
45 client: fidl::client::sync::Client,
46}
47
48#[cfg(target_os = "fuchsia")]
49impl fidl::endpoints::SynchronousProxy for MaintenanceSynchronousProxy {
50 type Proxy = MaintenanceProxy;
51 type Protocol = MaintenanceMarker;
52
53 fn from_channel(inner: fidl::Channel) -> Self {
54 Self::new(inner)
55 }
56
57 fn into_channel(self) -> fidl::Channel {
58 self.client.into_channel()
59 }
60
61 fn as_channel(&self) -> &fidl::Channel {
62 self.client.as_channel()
63 }
64}
65
66#[cfg(target_os = "fuchsia")]
67impl MaintenanceSynchronousProxy {
68 pub fn new(channel: fidl::Channel) -> Self {
69 let protocol_name = <MaintenanceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
70 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
71 }
72
73 pub fn into_channel(self) -> fidl::Channel {
74 self.client.into_channel()
75 }
76
77 pub fn wait_for_event(
80 &self,
81 deadline: zx::MonotonicInstant,
82 ) -> Result<MaintenanceEvent, fidl::Error> {
83 MaintenanceEvent::decode(self.client.wait_for_event(deadline)?)
84 }
85
86 pub fn r#get_writable_utc_clock(
88 &self,
89 ___deadline: zx::MonotonicInstant,
90 ) -> Result<fidl::Clock, fidl::Error> {
91 let _response = self
92 .client
93 .send_query::<fidl::encoding::EmptyPayload, MaintenanceGetWritableUtcClockResponse>(
94 (),
95 0x7e4ff4ceb95bb136,
96 fidl::encoding::DynamicFlags::empty(),
97 ___deadline,
98 )?;
99 Ok(_response.utc_clock)
100 }
101}
102
103#[derive(Debug, Clone)]
104pub struct MaintenanceProxy {
105 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
106}
107
108impl fidl::endpoints::Proxy for MaintenanceProxy {
109 type Protocol = MaintenanceMarker;
110
111 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
112 Self::new(inner)
113 }
114
115 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
116 self.client.into_channel().map_err(|client| Self { client })
117 }
118
119 fn as_channel(&self) -> &::fidl::AsyncChannel {
120 self.client.as_channel()
121 }
122}
123
124impl MaintenanceProxy {
125 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
127 let protocol_name = <MaintenanceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
128 Self { client: fidl::client::Client::new(channel, protocol_name) }
129 }
130
131 pub fn take_event_stream(&self) -> MaintenanceEventStream {
137 MaintenanceEventStream { event_receiver: self.client.take_event_receiver() }
138 }
139
140 pub fn r#get_writable_utc_clock(
142 &self,
143 ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
144 {
145 MaintenanceProxyInterface::r#get_writable_utc_clock(self)
146 }
147}
148
149impl MaintenanceProxyInterface for MaintenanceProxy {
150 type GetWritableUtcClockResponseFut =
151 fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
152 fn r#get_writable_utc_clock(&self) -> Self::GetWritableUtcClockResponseFut {
153 fn _decode(
154 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
155 ) -> Result<fidl::Clock, fidl::Error> {
156 let _response = fidl::client::decode_transaction_body::<
157 MaintenanceGetWritableUtcClockResponse,
158 fidl::encoding::DefaultFuchsiaResourceDialect,
159 0x7e4ff4ceb95bb136,
160 >(_buf?)?;
161 Ok(_response.utc_clock)
162 }
163 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
164 (),
165 0x7e4ff4ceb95bb136,
166 fidl::encoding::DynamicFlags::empty(),
167 _decode,
168 )
169 }
170}
171
172pub struct MaintenanceEventStream {
173 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
174}
175
176impl std::marker::Unpin for MaintenanceEventStream {}
177
178impl futures::stream::FusedStream for MaintenanceEventStream {
179 fn is_terminated(&self) -> bool {
180 self.event_receiver.is_terminated()
181 }
182}
183
184impl futures::Stream for MaintenanceEventStream {
185 type Item = Result<MaintenanceEvent, fidl::Error>;
186
187 fn poll_next(
188 mut self: std::pin::Pin<&mut Self>,
189 cx: &mut std::task::Context<'_>,
190 ) -> std::task::Poll<Option<Self::Item>> {
191 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
192 &mut self.event_receiver,
193 cx
194 )?) {
195 Some(buf) => std::task::Poll::Ready(Some(MaintenanceEvent::decode(buf))),
196 None => std::task::Poll::Ready(None),
197 }
198 }
199}
200
201#[derive(Debug)]
202pub enum MaintenanceEvent {}
203
204impl MaintenanceEvent {
205 fn decode(
207 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
208 ) -> Result<MaintenanceEvent, fidl::Error> {
209 let (bytes, _handles) = buf.split_mut();
210 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
211 debug_assert_eq!(tx_header.tx_id, 0);
212 match tx_header.ordinal {
213 _ => Err(fidl::Error::UnknownOrdinal {
214 ordinal: tx_header.ordinal,
215 protocol_name: <MaintenanceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
216 }),
217 }
218 }
219}
220
221pub struct MaintenanceRequestStream {
223 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
224 is_terminated: bool,
225}
226
227impl std::marker::Unpin for MaintenanceRequestStream {}
228
229impl futures::stream::FusedStream for MaintenanceRequestStream {
230 fn is_terminated(&self) -> bool {
231 self.is_terminated
232 }
233}
234
235impl fidl::endpoints::RequestStream for MaintenanceRequestStream {
236 type Protocol = MaintenanceMarker;
237 type ControlHandle = MaintenanceControlHandle;
238
239 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
240 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
241 }
242
243 fn control_handle(&self) -> Self::ControlHandle {
244 MaintenanceControlHandle { inner: self.inner.clone() }
245 }
246
247 fn into_inner(
248 self,
249 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
250 {
251 (self.inner, self.is_terminated)
252 }
253
254 fn from_inner(
255 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
256 is_terminated: bool,
257 ) -> Self {
258 Self { inner, is_terminated }
259 }
260}
261
262impl futures::Stream for MaintenanceRequestStream {
263 type Item = Result<MaintenanceRequest, fidl::Error>;
264
265 fn poll_next(
266 mut self: std::pin::Pin<&mut Self>,
267 cx: &mut std::task::Context<'_>,
268 ) -> std::task::Poll<Option<Self::Item>> {
269 let this = &mut *self;
270 if this.inner.check_shutdown(cx) {
271 this.is_terminated = true;
272 return std::task::Poll::Ready(None);
273 }
274 if this.is_terminated {
275 panic!("polled MaintenanceRequestStream after completion");
276 }
277 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
278 |bytes, handles| {
279 match this.inner.channel().read_etc(cx, bytes, handles) {
280 std::task::Poll::Ready(Ok(())) => {}
281 std::task::Poll::Pending => return std::task::Poll::Pending,
282 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
283 this.is_terminated = true;
284 return std::task::Poll::Ready(None);
285 }
286 std::task::Poll::Ready(Err(e)) => {
287 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
288 e.into(),
289 ))))
290 }
291 }
292
293 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
295
296 std::task::Poll::Ready(Some(match header.ordinal {
297 0x7e4ff4ceb95bb136 => {
298 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
299 let mut req = fidl::new_empty!(
300 fidl::encoding::EmptyPayload,
301 fidl::encoding::DefaultFuchsiaResourceDialect
302 );
303 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
304 let control_handle = MaintenanceControlHandle { inner: this.inner.clone() };
305 Ok(MaintenanceRequest::GetWritableUtcClock {
306 responder: MaintenanceGetWritableUtcClockResponder {
307 control_handle: std::mem::ManuallyDrop::new(control_handle),
308 tx_id: header.tx_id,
309 },
310 })
311 }
312 _ => Err(fidl::Error::UnknownOrdinal {
313 ordinal: header.ordinal,
314 protocol_name:
315 <MaintenanceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
316 }),
317 }))
318 },
319 )
320 }
321}
322
323#[derive(Debug)]
329pub enum MaintenanceRequest {
330 GetWritableUtcClock { responder: MaintenanceGetWritableUtcClockResponder },
332}
333
334impl MaintenanceRequest {
335 #[allow(irrefutable_let_patterns)]
336 pub fn into_get_writable_utc_clock(self) -> Option<(MaintenanceGetWritableUtcClockResponder)> {
337 if let MaintenanceRequest::GetWritableUtcClock { responder } = self {
338 Some((responder))
339 } else {
340 None
341 }
342 }
343
344 pub fn method_name(&self) -> &'static str {
346 match *self {
347 MaintenanceRequest::GetWritableUtcClock { .. } => "get_writable_utc_clock",
348 }
349 }
350}
351
352#[derive(Debug, Clone)]
353pub struct MaintenanceControlHandle {
354 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
355}
356
357impl fidl::endpoints::ControlHandle for MaintenanceControlHandle {
358 fn shutdown(&self) {
359 self.inner.shutdown()
360 }
361 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
362 self.inner.shutdown_with_epitaph(status)
363 }
364
365 fn is_closed(&self) -> bool {
366 self.inner.channel().is_closed()
367 }
368 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
369 self.inner.channel().on_closed()
370 }
371
372 #[cfg(target_os = "fuchsia")]
373 fn signal_peer(
374 &self,
375 clear_mask: zx::Signals,
376 set_mask: zx::Signals,
377 ) -> Result<(), zx_status::Status> {
378 use fidl::Peered;
379 self.inner.channel().signal_peer(clear_mask, set_mask)
380 }
381}
382
383impl MaintenanceControlHandle {}
384
385#[must_use = "FIDL methods require a response to be sent"]
386#[derive(Debug)]
387pub struct MaintenanceGetWritableUtcClockResponder {
388 control_handle: std::mem::ManuallyDrop<MaintenanceControlHandle>,
389 tx_id: u32,
390}
391
392impl std::ops::Drop for MaintenanceGetWritableUtcClockResponder {
396 fn drop(&mut self) {
397 self.control_handle.shutdown();
398 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
400 }
401}
402
403impl fidl::endpoints::Responder for MaintenanceGetWritableUtcClockResponder {
404 type ControlHandle = MaintenanceControlHandle;
405
406 fn control_handle(&self) -> &MaintenanceControlHandle {
407 &self.control_handle
408 }
409
410 fn drop_without_shutdown(mut self) {
411 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
413 std::mem::forget(self);
415 }
416}
417
418impl MaintenanceGetWritableUtcClockResponder {
419 pub fn send(self, mut utc_clock: fidl::Clock) -> Result<(), fidl::Error> {
423 let _result = self.send_raw(utc_clock);
424 if _result.is_err() {
425 self.control_handle.shutdown();
426 }
427 self.drop_without_shutdown();
428 _result
429 }
430
431 pub fn send_no_shutdown_on_err(self, mut utc_clock: fidl::Clock) -> Result<(), fidl::Error> {
433 let _result = self.send_raw(utc_clock);
434 self.drop_without_shutdown();
435 _result
436 }
437
438 fn send_raw(&self, mut utc_clock: fidl::Clock) -> Result<(), fidl::Error> {
439 self.control_handle.inner.send::<MaintenanceGetWritableUtcClockResponse>(
440 (utc_clock,),
441 self.tx_id,
442 0x7e4ff4ceb95bb136,
443 fidl::encoding::DynamicFlags::empty(),
444 )
445 }
446}
447
448mod internal {
449 use super::*;
450
451 impl fidl::encoding::ResourceTypeMarker for MaintenanceGetWritableUtcClockResponse {
452 type Borrowed<'a> = &'a mut Self;
453 fn take_or_borrow<'a>(
454 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
455 ) -> Self::Borrowed<'a> {
456 value
457 }
458 }
459
460 unsafe impl fidl::encoding::TypeMarker for MaintenanceGetWritableUtcClockResponse {
461 type Owned = Self;
462
463 #[inline(always)]
464 fn inline_align(_context: fidl::encoding::Context) -> usize {
465 4
466 }
467
468 #[inline(always)]
469 fn inline_size(_context: fidl::encoding::Context) -> usize {
470 4
471 }
472 }
473
474 unsafe impl
475 fidl::encoding::Encode<
476 MaintenanceGetWritableUtcClockResponse,
477 fidl::encoding::DefaultFuchsiaResourceDialect,
478 > for &mut MaintenanceGetWritableUtcClockResponse
479 {
480 #[inline]
481 unsafe fn encode(
482 self,
483 encoder: &mut fidl::encoding::Encoder<
484 '_,
485 fidl::encoding::DefaultFuchsiaResourceDialect,
486 >,
487 offset: usize,
488 _depth: fidl::encoding::Depth,
489 ) -> fidl::Result<()> {
490 encoder.debug_check_bounds::<MaintenanceGetWritableUtcClockResponse>(offset);
491 fidl::encoding::Encode::<
493 MaintenanceGetWritableUtcClockResponse,
494 fidl::encoding::DefaultFuchsiaResourceDialect,
495 >::encode(
496 (<fidl::encoding::HandleType<
497 fidl::Clock,
498 { fidl::ObjectType::CLOCK.into_raw() },
499 2147483648,
500 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
501 &mut self.utc_clock
502 ),),
503 encoder,
504 offset,
505 _depth,
506 )
507 }
508 }
509 unsafe impl<
510 T0: fidl::encoding::Encode<
511 fidl::encoding::HandleType<
512 fidl::Clock,
513 { fidl::ObjectType::CLOCK.into_raw() },
514 2147483648,
515 >,
516 fidl::encoding::DefaultFuchsiaResourceDialect,
517 >,
518 >
519 fidl::encoding::Encode<
520 MaintenanceGetWritableUtcClockResponse,
521 fidl::encoding::DefaultFuchsiaResourceDialect,
522 > for (T0,)
523 {
524 #[inline]
525 unsafe fn encode(
526 self,
527 encoder: &mut fidl::encoding::Encoder<
528 '_,
529 fidl::encoding::DefaultFuchsiaResourceDialect,
530 >,
531 offset: usize,
532 depth: fidl::encoding::Depth,
533 ) -> fidl::Result<()> {
534 encoder.debug_check_bounds::<MaintenanceGetWritableUtcClockResponse>(offset);
535 self.0.encode(encoder, offset + 0, depth)?;
539 Ok(())
540 }
541 }
542
543 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
544 for MaintenanceGetWritableUtcClockResponse
545 {
546 #[inline(always)]
547 fn new_empty() -> Self {
548 Self {
549 utc_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
550 }
551 }
552
553 #[inline]
554 unsafe fn decode(
555 &mut self,
556 decoder: &mut fidl::encoding::Decoder<
557 '_,
558 fidl::encoding::DefaultFuchsiaResourceDialect,
559 >,
560 offset: usize,
561 _depth: fidl::encoding::Depth,
562 ) -> fidl::Result<()> {
563 decoder.debug_check_bounds::<Self>(offset);
564 fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.utc_clock, decoder, offset + 0, _depth)?;
566 Ok(())
567 }
568 }
569}