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 Self { client: fidl::client::sync::Client::new(channel) }
70 }
71
72 pub fn into_channel(self) -> fidl::Channel {
73 self.client.into_channel()
74 }
75
76 pub fn wait_for_event(
79 &self,
80 deadline: zx::MonotonicInstant,
81 ) -> Result<MaintenanceEvent, fidl::Error> {
82 MaintenanceEvent::decode(self.client.wait_for_event::<MaintenanceMarker>(deadline)?)
83 }
84
85 pub fn r#get_writable_utc_clock(
87 &self,
88 ___deadline: zx::MonotonicInstant,
89 ) -> Result<fidl::Clock, fidl::Error> {
90 let _response = self.client.send_query::<
91 fidl::encoding::EmptyPayload,
92 MaintenanceGetWritableUtcClockResponse,
93 MaintenanceMarker,
94 >(
95 (),
96 0x7e4ff4ceb95bb136,
97 fidl::encoding::DynamicFlags::empty(),
98 ___deadline,
99 )?;
100 Ok(_response.utc_clock)
101 }
102}
103
104#[cfg(target_os = "fuchsia")]
105impl From<MaintenanceSynchronousProxy> for zx::NullableHandle {
106 fn from(value: MaintenanceSynchronousProxy) -> Self {
107 value.into_channel().into()
108 }
109}
110
111#[cfg(target_os = "fuchsia")]
112impl From<fidl::Channel> for MaintenanceSynchronousProxy {
113 fn from(value: fidl::Channel) -> Self {
114 Self::new(value)
115 }
116}
117
118#[cfg(target_os = "fuchsia")]
119impl fidl::endpoints::FromClient for MaintenanceSynchronousProxy {
120 type Protocol = MaintenanceMarker;
121
122 fn from_client(value: fidl::endpoints::ClientEnd<MaintenanceMarker>) -> Self {
123 Self::new(value.into_channel())
124 }
125}
126
127#[derive(Debug, Clone)]
128pub struct MaintenanceProxy {
129 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
130}
131
132impl fidl::endpoints::Proxy for MaintenanceProxy {
133 type Protocol = MaintenanceMarker;
134
135 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
136 Self::new(inner)
137 }
138
139 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
140 self.client.into_channel().map_err(|client| Self { client })
141 }
142
143 fn as_channel(&self) -> &::fidl::AsyncChannel {
144 self.client.as_channel()
145 }
146}
147
148impl MaintenanceProxy {
149 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
151 let protocol_name = <MaintenanceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
152 Self { client: fidl::client::Client::new(channel, protocol_name) }
153 }
154
155 pub fn take_event_stream(&self) -> MaintenanceEventStream {
161 MaintenanceEventStream { event_receiver: self.client.take_event_receiver() }
162 }
163
164 pub fn r#get_writable_utc_clock(
166 &self,
167 ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
168 {
169 MaintenanceProxyInterface::r#get_writable_utc_clock(self)
170 }
171}
172
173impl MaintenanceProxyInterface for MaintenanceProxy {
174 type GetWritableUtcClockResponseFut =
175 fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
176 fn r#get_writable_utc_clock(&self) -> Self::GetWritableUtcClockResponseFut {
177 fn _decode(
178 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
179 ) -> Result<fidl::Clock, fidl::Error> {
180 let _response = fidl::client::decode_transaction_body::<
181 MaintenanceGetWritableUtcClockResponse,
182 fidl::encoding::DefaultFuchsiaResourceDialect,
183 0x7e4ff4ceb95bb136,
184 >(_buf?)?;
185 Ok(_response.utc_clock)
186 }
187 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
188 (),
189 0x7e4ff4ceb95bb136,
190 fidl::encoding::DynamicFlags::empty(),
191 _decode,
192 )
193 }
194}
195
196pub struct MaintenanceEventStream {
197 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
198}
199
200impl std::marker::Unpin for MaintenanceEventStream {}
201
202impl futures::stream::FusedStream for MaintenanceEventStream {
203 fn is_terminated(&self) -> bool {
204 self.event_receiver.is_terminated()
205 }
206}
207
208impl futures::Stream for MaintenanceEventStream {
209 type Item = Result<MaintenanceEvent, fidl::Error>;
210
211 fn poll_next(
212 mut self: std::pin::Pin<&mut Self>,
213 cx: &mut std::task::Context<'_>,
214 ) -> std::task::Poll<Option<Self::Item>> {
215 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
216 &mut self.event_receiver,
217 cx
218 )?) {
219 Some(buf) => std::task::Poll::Ready(Some(MaintenanceEvent::decode(buf))),
220 None => std::task::Poll::Ready(None),
221 }
222 }
223}
224
225#[derive(Debug)]
226pub enum MaintenanceEvent {}
227
228impl MaintenanceEvent {
229 fn decode(
231 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
232 ) -> Result<MaintenanceEvent, fidl::Error> {
233 let (bytes, _handles) = buf.split_mut();
234 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
235 debug_assert_eq!(tx_header.tx_id, 0);
236 match tx_header.ordinal {
237 _ => Err(fidl::Error::UnknownOrdinal {
238 ordinal: tx_header.ordinal,
239 protocol_name: <MaintenanceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
240 }),
241 }
242 }
243}
244
245pub struct MaintenanceRequestStream {
247 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
248 is_terminated: bool,
249}
250
251impl std::marker::Unpin for MaintenanceRequestStream {}
252
253impl futures::stream::FusedStream for MaintenanceRequestStream {
254 fn is_terminated(&self) -> bool {
255 self.is_terminated
256 }
257}
258
259impl fidl::endpoints::RequestStream for MaintenanceRequestStream {
260 type Protocol = MaintenanceMarker;
261 type ControlHandle = MaintenanceControlHandle;
262
263 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
264 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
265 }
266
267 fn control_handle(&self) -> Self::ControlHandle {
268 MaintenanceControlHandle { inner: self.inner.clone() }
269 }
270
271 fn into_inner(
272 self,
273 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
274 {
275 (self.inner, self.is_terminated)
276 }
277
278 fn from_inner(
279 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
280 is_terminated: bool,
281 ) -> Self {
282 Self { inner, is_terminated }
283 }
284}
285
286impl futures::Stream for MaintenanceRequestStream {
287 type Item = Result<MaintenanceRequest, 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 let this = &mut *self;
294 if this.inner.check_shutdown(cx) {
295 this.is_terminated = true;
296 return std::task::Poll::Ready(None);
297 }
298 if this.is_terminated {
299 panic!("polled MaintenanceRequestStream after completion");
300 }
301 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
302 |bytes, handles| {
303 match this.inner.channel().read_etc(cx, bytes, handles) {
304 std::task::Poll::Ready(Ok(())) => {}
305 std::task::Poll::Pending => return std::task::Poll::Pending,
306 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
307 this.is_terminated = true;
308 return std::task::Poll::Ready(None);
309 }
310 std::task::Poll::Ready(Err(e)) => {
311 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
312 e.into(),
313 ))));
314 }
315 }
316
317 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
319
320 std::task::Poll::Ready(Some(match header.ordinal {
321 0x7e4ff4ceb95bb136 => {
322 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
323 let mut req = fidl::new_empty!(
324 fidl::encoding::EmptyPayload,
325 fidl::encoding::DefaultFuchsiaResourceDialect
326 );
327 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
328 let control_handle = MaintenanceControlHandle { inner: this.inner.clone() };
329 Ok(MaintenanceRequest::GetWritableUtcClock {
330 responder: MaintenanceGetWritableUtcClockResponder {
331 control_handle: std::mem::ManuallyDrop::new(control_handle),
332 tx_id: header.tx_id,
333 },
334 })
335 }
336 _ => Err(fidl::Error::UnknownOrdinal {
337 ordinal: header.ordinal,
338 protocol_name:
339 <MaintenanceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
340 }),
341 }))
342 },
343 )
344 }
345}
346
347#[derive(Debug)]
353pub enum MaintenanceRequest {
354 GetWritableUtcClock { responder: MaintenanceGetWritableUtcClockResponder },
356}
357
358impl MaintenanceRequest {
359 #[allow(irrefutable_let_patterns)]
360 pub fn into_get_writable_utc_clock(self) -> Option<(MaintenanceGetWritableUtcClockResponder)> {
361 if let MaintenanceRequest::GetWritableUtcClock { responder } = self {
362 Some((responder))
363 } else {
364 None
365 }
366 }
367
368 pub fn method_name(&self) -> &'static str {
370 match *self {
371 MaintenanceRequest::GetWritableUtcClock { .. } => "get_writable_utc_clock",
372 }
373 }
374}
375
376#[derive(Debug, Clone)]
377pub struct MaintenanceControlHandle {
378 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
379}
380
381impl fidl::endpoints::ControlHandle for MaintenanceControlHandle {
382 fn shutdown(&self) {
383 self.inner.shutdown()
384 }
385
386 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
387 self.inner.shutdown_with_epitaph(status)
388 }
389
390 fn is_closed(&self) -> bool {
391 self.inner.channel().is_closed()
392 }
393 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
394 self.inner.channel().on_closed()
395 }
396
397 #[cfg(target_os = "fuchsia")]
398 fn signal_peer(
399 &self,
400 clear_mask: zx::Signals,
401 set_mask: zx::Signals,
402 ) -> Result<(), zx_status::Status> {
403 use fidl::Peered;
404 self.inner.channel().signal_peer(clear_mask, set_mask)
405 }
406}
407
408impl MaintenanceControlHandle {}
409
410#[must_use = "FIDL methods require a response to be sent"]
411#[derive(Debug)]
412pub struct MaintenanceGetWritableUtcClockResponder {
413 control_handle: std::mem::ManuallyDrop<MaintenanceControlHandle>,
414 tx_id: u32,
415}
416
417impl std::ops::Drop for MaintenanceGetWritableUtcClockResponder {
421 fn drop(&mut self) {
422 self.control_handle.shutdown();
423 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
425 }
426}
427
428impl fidl::endpoints::Responder for MaintenanceGetWritableUtcClockResponder {
429 type ControlHandle = MaintenanceControlHandle;
430
431 fn control_handle(&self) -> &MaintenanceControlHandle {
432 &self.control_handle
433 }
434
435 fn drop_without_shutdown(mut self) {
436 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
438 std::mem::forget(self);
440 }
441}
442
443impl MaintenanceGetWritableUtcClockResponder {
444 pub fn send(self, mut utc_clock: fidl::Clock) -> Result<(), fidl::Error> {
448 let _result = self.send_raw(utc_clock);
449 if _result.is_err() {
450 self.control_handle.shutdown();
451 }
452 self.drop_without_shutdown();
453 _result
454 }
455
456 pub fn send_no_shutdown_on_err(self, mut utc_clock: fidl::Clock) -> Result<(), fidl::Error> {
458 let _result = self.send_raw(utc_clock);
459 self.drop_without_shutdown();
460 _result
461 }
462
463 fn send_raw(&self, mut utc_clock: fidl::Clock) -> Result<(), fidl::Error> {
464 self.control_handle.inner.send::<MaintenanceGetWritableUtcClockResponse>(
465 (utc_clock,),
466 self.tx_id,
467 0x7e4ff4ceb95bb136,
468 fidl::encoding::DynamicFlags::empty(),
469 )
470 }
471}
472
473mod internal {
474 use super::*;
475
476 impl fidl::encoding::ResourceTypeMarker for MaintenanceGetWritableUtcClockResponse {
477 type Borrowed<'a> = &'a mut Self;
478 fn take_or_borrow<'a>(
479 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
480 ) -> Self::Borrowed<'a> {
481 value
482 }
483 }
484
485 unsafe impl fidl::encoding::TypeMarker for MaintenanceGetWritableUtcClockResponse {
486 type Owned = Self;
487
488 #[inline(always)]
489 fn inline_align(_context: fidl::encoding::Context) -> usize {
490 4
491 }
492
493 #[inline(always)]
494 fn inline_size(_context: fidl::encoding::Context) -> usize {
495 4
496 }
497 }
498
499 unsafe impl
500 fidl::encoding::Encode<
501 MaintenanceGetWritableUtcClockResponse,
502 fidl::encoding::DefaultFuchsiaResourceDialect,
503 > for &mut MaintenanceGetWritableUtcClockResponse
504 {
505 #[inline]
506 unsafe fn encode(
507 self,
508 encoder: &mut fidl::encoding::Encoder<
509 '_,
510 fidl::encoding::DefaultFuchsiaResourceDialect,
511 >,
512 offset: usize,
513 _depth: fidl::encoding::Depth,
514 ) -> fidl::Result<()> {
515 encoder.debug_check_bounds::<MaintenanceGetWritableUtcClockResponse>(offset);
516 fidl::encoding::Encode::<
518 MaintenanceGetWritableUtcClockResponse,
519 fidl::encoding::DefaultFuchsiaResourceDialect,
520 >::encode(
521 (<fidl::encoding::HandleType<
522 fidl::Clock,
523 { fidl::ObjectType::CLOCK.into_raw() },
524 2147483648,
525 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
526 &mut self.utc_clock
527 ),),
528 encoder,
529 offset,
530 _depth,
531 )
532 }
533 }
534 unsafe impl<
535 T0: fidl::encoding::Encode<
536 fidl::encoding::HandleType<
537 fidl::Clock,
538 { fidl::ObjectType::CLOCK.into_raw() },
539 2147483648,
540 >,
541 fidl::encoding::DefaultFuchsiaResourceDialect,
542 >,
543 >
544 fidl::encoding::Encode<
545 MaintenanceGetWritableUtcClockResponse,
546 fidl::encoding::DefaultFuchsiaResourceDialect,
547 > for (T0,)
548 {
549 #[inline]
550 unsafe fn encode(
551 self,
552 encoder: &mut fidl::encoding::Encoder<
553 '_,
554 fidl::encoding::DefaultFuchsiaResourceDialect,
555 >,
556 offset: usize,
557 depth: fidl::encoding::Depth,
558 ) -> fidl::Result<()> {
559 encoder.debug_check_bounds::<MaintenanceGetWritableUtcClockResponse>(offset);
560 self.0.encode(encoder, offset + 0, depth)?;
564 Ok(())
565 }
566 }
567
568 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
569 for MaintenanceGetWritableUtcClockResponse
570 {
571 #[inline(always)]
572 fn new_empty() -> Self {
573 Self {
574 utc_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
575 }
576 }
577
578 #[inline]
579 unsafe fn decode(
580 &mut self,
581 decoder: &mut fidl::encoding::Decoder<
582 '_,
583 fidl::encoding::DefaultFuchsiaResourceDialect,
584 >,
585 offset: usize,
586 _depth: fidl::encoding::Depth,
587 ) -> fidl::Result<()> {
588 decoder.debug_check_bounds::<Self>(offset);
589 fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.utc_clock, decoder, offset + 0, _depth)?;
591 Ok(())
592 }
593 }
594}