Skip to main content

fidl_fuchsia_time_external/
fidl_fuchsia_time_external.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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_external_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct PullSourceShutdownResponse {
16    pub escrow_token: fidl_fuchsia_inspect::EscrowToken,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for PullSourceShutdownResponse
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct AdjustMarker;
26
27impl fidl::endpoints::ProtocolMarker for AdjustMarker {
28    type Proxy = AdjustProxy;
29    type RequestStream = AdjustRequestStream;
30    #[cfg(target_os = "fuchsia")]
31    type SynchronousProxy = AdjustSynchronousProxy;
32
33    const DEBUG_NAME: &'static str = "fuchsia.time.external.Adjust";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for AdjustMarker {}
36pub type AdjustReportBootToUtcMappingResult = Result<(), Error>;
37
38pub trait AdjustProxyInterface: Send + Sync {
39    type ReportBootToUtcMappingResponseFut: std::future::Future<Output = Result<AdjustReportBootToUtcMappingResult, fidl::Error>>
40        + Send;
41    fn r#report_boot_to_utc_mapping(
42        &self,
43        boot_reference: fidl::BootInstant,
44        utc_reference: i64,
45    ) -> Self::ReportBootToUtcMappingResponseFut;
46}
47#[derive(Debug)]
48#[cfg(target_os = "fuchsia")]
49pub struct AdjustSynchronousProxy {
50    client: fidl::client::sync::Client,
51}
52
53#[cfg(target_os = "fuchsia")]
54impl fidl::endpoints::SynchronousProxy for AdjustSynchronousProxy {
55    type Proxy = AdjustProxy;
56    type Protocol = AdjustMarker;
57
58    fn from_channel(inner: fidl::Channel) -> Self {
59        Self::new(inner)
60    }
61
62    fn into_channel(self) -> fidl::Channel {
63        self.client.into_channel()
64    }
65
66    fn as_channel(&self) -> &fidl::Channel {
67        self.client.as_channel()
68    }
69}
70
71#[cfg(target_os = "fuchsia")]
72impl AdjustSynchronousProxy {
73    pub fn new(channel: fidl::Channel) -> Self {
74        Self { client: fidl::client::sync::Client::new(channel) }
75    }
76
77    pub fn into_channel(self) -> fidl::Channel {
78        self.client.into_channel()
79    }
80
81    /// Waits until an event arrives and returns it. It is safe for other
82    /// threads to make concurrent requests while waiting for an event.
83    pub fn wait_for_event(
84        &self,
85        deadline: zx::MonotonicInstant,
86    ) -> Result<AdjustEvent, fidl::Error> {
87        AdjustEvent::decode(self.client.wait_for_event::<AdjustMarker>(deadline)?)
88    }
89
90    /// Requests that the callee changes its UTC time estimate.
91    ///
92    /// Reports the caller's desired correspondence between the boot timeline,
93    /// and the UTC timeline.
94    ///
95    /// The caller is required to provide both reference points so that any
96    /// FIDL round-trip delays do not affect the callee's interpretation of
97    /// the caller's intentions.  For example, were the callee to use its own
98    /// `boot_reference` value instead of a caller-provided one, long wall time
99    /// delays between the caller's and the callee's sampling of `boot_reference`
100    /// would introduce a skew.  While this is unlikely to happen on a device to
101    /// a meaningful extent, we established that this is the correct way to
102    /// transmit such information.
103    ///
104    /// To wit, we have observed delays in test environments. This is likely
105    /// because test environments run on emulators in shared-resource
106    /// settings, where unusually long delays are relatively common.
107    pub fn r#report_boot_to_utc_mapping(
108        &self,
109        mut boot_reference: fidl::BootInstant,
110        mut utc_reference: i64,
111        ___deadline: zx::MonotonicInstant,
112    ) -> Result<AdjustReportBootToUtcMappingResult, fidl::Error> {
113        let _response = self.client.send_query::<
114            AdjustReportBootToUtcMappingRequest,
115            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
116            AdjustMarker,
117        >(
118            (boot_reference, utc_reference,),
119            0x1186fc4a8c7f7fbe,
120            fidl::encoding::DynamicFlags::empty(),
121            ___deadline,
122        )?;
123        Ok(_response.map(|x| x))
124    }
125}
126
127#[cfg(target_os = "fuchsia")]
128impl From<AdjustSynchronousProxy> for zx::NullableHandle {
129    fn from(value: AdjustSynchronousProxy) -> Self {
130        value.into_channel().into()
131    }
132}
133
134#[cfg(target_os = "fuchsia")]
135impl From<fidl::Channel> for AdjustSynchronousProxy {
136    fn from(value: fidl::Channel) -> Self {
137        Self::new(value)
138    }
139}
140
141#[cfg(target_os = "fuchsia")]
142impl fidl::endpoints::FromClient for AdjustSynchronousProxy {
143    type Protocol = AdjustMarker;
144
145    fn from_client(value: fidl::endpoints::ClientEnd<AdjustMarker>) -> Self {
146        Self::new(value.into_channel())
147    }
148}
149
150#[derive(Debug, Clone)]
151pub struct AdjustProxy {
152    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
153}
154
155impl fidl::endpoints::Proxy for AdjustProxy {
156    type Protocol = AdjustMarker;
157
158    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
159        Self::new(inner)
160    }
161
162    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
163        self.client.into_channel().map_err(|client| Self { client })
164    }
165
166    fn as_channel(&self) -> &::fidl::AsyncChannel {
167        self.client.as_channel()
168    }
169}
170
171impl AdjustProxy {
172    /// Create a new Proxy for fuchsia.time.external/Adjust.
173    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
174        let protocol_name = <AdjustMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
175        Self { client: fidl::client::Client::new(channel, protocol_name) }
176    }
177
178    /// Get a Stream of events from the remote end of the protocol.
179    ///
180    /// # Panics
181    ///
182    /// Panics if the event stream was already taken.
183    pub fn take_event_stream(&self) -> AdjustEventStream {
184        AdjustEventStream { event_receiver: self.client.take_event_receiver() }
185    }
186
187    /// Requests that the callee changes its UTC time estimate.
188    ///
189    /// Reports the caller's desired correspondence between the boot timeline,
190    /// and the UTC timeline.
191    ///
192    /// The caller is required to provide both reference points so that any
193    /// FIDL round-trip delays do not affect the callee's interpretation of
194    /// the caller's intentions.  For example, were the callee to use its own
195    /// `boot_reference` value instead of a caller-provided one, long wall time
196    /// delays between the caller's and the callee's sampling of `boot_reference`
197    /// would introduce a skew.  While this is unlikely to happen on a device to
198    /// a meaningful extent, we established that this is the correct way to
199    /// transmit such information.
200    ///
201    /// To wit, we have observed delays in test environments. This is likely
202    /// because test environments run on emulators in shared-resource
203    /// settings, where unusually long delays are relatively common.
204    pub fn r#report_boot_to_utc_mapping(
205        &self,
206        mut boot_reference: fidl::BootInstant,
207        mut utc_reference: i64,
208    ) -> fidl::client::QueryResponseFut<
209        AdjustReportBootToUtcMappingResult,
210        fidl::encoding::DefaultFuchsiaResourceDialect,
211    > {
212        AdjustProxyInterface::r#report_boot_to_utc_mapping(self, boot_reference, utc_reference)
213    }
214}
215
216impl AdjustProxyInterface for AdjustProxy {
217    type ReportBootToUtcMappingResponseFut = fidl::client::QueryResponseFut<
218        AdjustReportBootToUtcMappingResult,
219        fidl::encoding::DefaultFuchsiaResourceDialect,
220    >;
221    fn r#report_boot_to_utc_mapping(
222        &self,
223        mut boot_reference: fidl::BootInstant,
224        mut utc_reference: i64,
225    ) -> Self::ReportBootToUtcMappingResponseFut {
226        fn _decode(
227            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
228        ) -> Result<AdjustReportBootToUtcMappingResult, fidl::Error> {
229            let _response = fidl::client::decode_transaction_body::<
230                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
231                fidl::encoding::DefaultFuchsiaResourceDialect,
232                0x1186fc4a8c7f7fbe,
233            >(_buf?)?;
234            Ok(_response.map(|x| x))
235        }
236        self.client.send_query_and_decode::<
237            AdjustReportBootToUtcMappingRequest,
238            AdjustReportBootToUtcMappingResult,
239        >(
240            (boot_reference, utc_reference,),
241            0x1186fc4a8c7f7fbe,
242            fidl::encoding::DynamicFlags::empty(),
243            _decode,
244        )
245    }
246}
247
248pub struct AdjustEventStream {
249    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
250}
251
252impl std::marker::Unpin for AdjustEventStream {}
253
254impl futures::stream::FusedStream for AdjustEventStream {
255    fn is_terminated(&self) -> bool {
256        self.event_receiver.is_terminated()
257    }
258}
259
260impl futures::Stream for AdjustEventStream {
261    type Item = Result<AdjustEvent, fidl::Error>;
262
263    fn poll_next(
264        mut self: std::pin::Pin<&mut Self>,
265        cx: &mut std::task::Context<'_>,
266    ) -> std::task::Poll<Option<Self::Item>> {
267        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
268            &mut self.event_receiver,
269            cx
270        )?) {
271            Some(buf) => std::task::Poll::Ready(Some(AdjustEvent::decode(buf))),
272            None => std::task::Poll::Ready(None),
273        }
274    }
275}
276
277#[derive(Debug)]
278pub enum AdjustEvent {}
279
280impl AdjustEvent {
281    /// Decodes a message buffer as a [`AdjustEvent`].
282    fn decode(
283        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
284    ) -> Result<AdjustEvent, fidl::Error> {
285        let (bytes, _handles) = buf.split_mut();
286        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
287        debug_assert_eq!(tx_header.tx_id, 0);
288        match tx_header.ordinal {
289            _ => Err(fidl::Error::UnknownOrdinal {
290                ordinal: tx_header.ordinal,
291                protocol_name: <AdjustMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
292            }),
293        }
294    }
295}
296
297/// A Stream of incoming requests for fuchsia.time.external/Adjust.
298pub struct AdjustRequestStream {
299    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
300    is_terminated: bool,
301}
302
303impl std::marker::Unpin for AdjustRequestStream {}
304
305impl futures::stream::FusedStream for AdjustRequestStream {
306    fn is_terminated(&self) -> bool {
307        self.is_terminated
308    }
309}
310
311impl fidl::endpoints::RequestStream for AdjustRequestStream {
312    type Protocol = AdjustMarker;
313    type ControlHandle = AdjustControlHandle;
314
315    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
316        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
317    }
318
319    fn control_handle(&self) -> Self::ControlHandle {
320        AdjustControlHandle { inner: self.inner.clone() }
321    }
322
323    fn into_inner(
324        self,
325    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
326    {
327        (self.inner, self.is_terminated)
328    }
329
330    fn from_inner(
331        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
332        is_terminated: bool,
333    ) -> Self {
334        Self { inner, is_terminated }
335    }
336}
337
338impl futures::Stream for AdjustRequestStream {
339    type Item = Result<AdjustRequest, fidl::Error>;
340
341    fn poll_next(
342        mut self: std::pin::Pin<&mut Self>,
343        cx: &mut std::task::Context<'_>,
344    ) -> std::task::Poll<Option<Self::Item>> {
345        let this = &mut *self;
346        if this.inner.check_shutdown(cx) {
347            this.is_terminated = true;
348            return std::task::Poll::Ready(None);
349        }
350        if this.is_terminated {
351            panic!("polled AdjustRequestStream after completion");
352        }
353        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
354            |bytes, handles| {
355                match this.inner.channel().read_etc(cx, bytes, handles) {
356                    std::task::Poll::Ready(Ok(())) => {}
357                    std::task::Poll::Pending => return std::task::Poll::Pending,
358                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
359                        this.is_terminated = true;
360                        return std::task::Poll::Ready(None);
361                    }
362                    std::task::Poll::Ready(Err(e)) => {
363                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
364                            e.into(),
365                        ))));
366                    }
367                }
368
369                // A message has been received from the channel
370                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
371
372                std::task::Poll::Ready(Some(match header.ordinal {
373                    0x1186fc4a8c7f7fbe => {
374                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
375                        let mut req = fidl::new_empty!(
376                            AdjustReportBootToUtcMappingRequest,
377                            fidl::encoding::DefaultFuchsiaResourceDialect
378                        );
379                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AdjustReportBootToUtcMappingRequest>(&header, _body_bytes, handles, &mut req)?;
380                        let control_handle = AdjustControlHandle { inner: this.inner.clone() };
381                        Ok(AdjustRequest::ReportBootToUtcMapping {
382                            boot_reference: req.boot_reference,
383                            utc_reference: req.utc_reference,
384
385                            responder: AdjustReportBootToUtcMappingResponder {
386                                control_handle: std::mem::ManuallyDrop::new(control_handle),
387                                tx_id: header.tx_id,
388                            },
389                        })
390                    }
391                    _ => Err(fidl::Error::UnknownOrdinal {
392                        ordinal: header.ordinal,
393                        protocol_name:
394                            <AdjustMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
395                    }),
396                }))
397            },
398        )
399    }
400}
401
402/// Report UTC reference adjustment.
403///
404/// Allows components to request corrections to the reported UTC time.  Very few
405/// components should be expected to have access to this capability.
406#[derive(Debug)]
407pub enum AdjustRequest {
408    /// Requests that the callee changes its UTC time estimate.
409    ///
410    /// Reports the caller's desired correspondence between the boot timeline,
411    /// and the UTC timeline.
412    ///
413    /// The caller is required to provide both reference points so that any
414    /// FIDL round-trip delays do not affect the callee's interpretation of
415    /// the caller's intentions.  For example, were the callee to use its own
416    /// `boot_reference` value instead of a caller-provided one, long wall time
417    /// delays between the caller's and the callee's sampling of `boot_reference`
418    /// would introduce a skew.  While this is unlikely to happen on a device to
419    /// a meaningful extent, we established that this is the correct way to
420    /// transmit such information.
421    ///
422    /// To wit, we have observed delays in test environments. This is likely
423    /// because test environments run on emulators in shared-resource
424    /// settings, where unusually long delays are relatively common.
425    ReportBootToUtcMapping {
426        boot_reference: fidl::BootInstant,
427        utc_reference: i64,
428        responder: AdjustReportBootToUtcMappingResponder,
429    },
430}
431
432impl AdjustRequest {
433    #[allow(irrefutable_let_patterns)]
434    pub fn into_report_boot_to_utc_mapping(
435        self,
436    ) -> Option<(fidl::BootInstant, i64, AdjustReportBootToUtcMappingResponder)> {
437        if let AdjustRequest::ReportBootToUtcMapping { boot_reference, utc_reference, responder } =
438            self
439        {
440            Some((boot_reference, utc_reference, responder))
441        } else {
442            None
443        }
444    }
445
446    /// Name of the method defined in FIDL
447    pub fn method_name(&self) -> &'static str {
448        match *self {
449            AdjustRequest::ReportBootToUtcMapping { .. } => "report_boot_to_utc_mapping",
450        }
451    }
452}
453
454#[derive(Debug, Clone)]
455pub struct AdjustControlHandle {
456    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
457}
458
459impl AdjustControlHandle {
460    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
461        self.inner.shutdown_with_epitaph(status.into())
462    }
463}
464
465impl fidl::endpoints::ControlHandle for AdjustControlHandle {
466    fn shutdown(&self) {
467        self.inner.shutdown()
468    }
469
470    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
471        self.inner.shutdown_with_epitaph(status)
472    }
473
474    fn is_closed(&self) -> bool {
475        self.inner.channel().is_closed()
476    }
477    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
478        self.inner.channel().on_closed()
479    }
480
481    #[cfg(target_os = "fuchsia")]
482    fn signal_peer(
483        &self,
484        clear_mask: zx::Signals,
485        set_mask: zx::Signals,
486    ) -> Result<(), zx_status::Status> {
487        use fidl::Peered;
488        self.inner.channel().signal_peer(clear_mask, set_mask)
489    }
490}
491
492impl AdjustControlHandle {}
493
494#[must_use = "FIDL methods require a response to be sent"]
495#[derive(Debug)]
496pub struct AdjustReportBootToUtcMappingResponder {
497    control_handle: std::mem::ManuallyDrop<AdjustControlHandle>,
498    tx_id: u32,
499}
500
501/// Set the the channel to be shutdown (see [`AdjustControlHandle::shutdown`])
502/// if the responder is dropped without sending a response, so that the client
503/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
504impl std::ops::Drop for AdjustReportBootToUtcMappingResponder {
505    fn drop(&mut self) {
506        self.control_handle.shutdown();
507        // Safety: drops once, never accessed again
508        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
509    }
510}
511
512impl fidl::endpoints::Responder for AdjustReportBootToUtcMappingResponder {
513    type ControlHandle = AdjustControlHandle;
514
515    fn control_handle(&self) -> &AdjustControlHandle {
516        &self.control_handle
517    }
518
519    fn drop_without_shutdown(mut self) {
520        // Safety: drops once, never accessed again due to mem::forget
521        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
522        // Prevent Drop from running (which would shut down the channel)
523        std::mem::forget(self);
524    }
525}
526
527impl AdjustReportBootToUtcMappingResponder {
528    /// Sends a response to the FIDL transaction.
529    ///
530    /// Sets the channel to shutdown if an error occurs.
531    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
532        let _result = self.send_raw(result);
533        if _result.is_err() {
534            self.control_handle.shutdown();
535        }
536        self.drop_without_shutdown();
537        _result
538    }
539
540    /// Similar to "send" but does not shutdown the channel if an error occurs.
541    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
542        let _result = self.send_raw(result);
543        self.drop_without_shutdown();
544        _result
545    }
546
547    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
548        self.control_handle
549            .inner
550            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
551                result,
552                self.tx_id,
553                0x1186fc4a8c7f7fbe,
554                fidl::encoding::DynamicFlags::empty(),
555            )
556    }
557}
558
559#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
560pub struct PullSourceMarker;
561
562impl fidl::endpoints::ProtocolMarker for PullSourceMarker {
563    type Proxy = PullSourceProxy;
564    type RequestStream = PullSourceRequestStream;
565    #[cfg(target_os = "fuchsia")]
566    type SynchronousProxy = PullSourceSynchronousProxy;
567
568    const DEBUG_NAME: &'static str = "fuchsia.time.external.PullSource";
569}
570impl fidl::endpoints::DiscoverableProtocolMarker for PullSourceMarker {}
571pub type PullSourceSampleResult = Result<TimeSample, Error>;
572pub type PullSourceShutdownResult = Result<fidl_fuchsia_inspect::EscrowToken, EscrowError>;
573
574pub trait PullSourceProxyInterface: Send + Sync {
575    fn r#update_device_properties(&self, properties: &Properties) -> Result<(), fidl::Error>;
576    type SampleResponseFut: std::future::Future<Output = Result<PullSourceSampleResult, fidl::Error>>
577        + Send;
578    fn r#sample(&self, urgency: Urgency) -> Self::SampleResponseFut;
579    type NextPossibleSampleTimeResponseFut: std::future::Future<Output = Result<i64, fidl::Error>>
580        + Send;
581    fn r#next_possible_sample_time(&self) -> Self::NextPossibleSampleTimeResponseFut;
582    type ShutdownResponseFut: std::future::Future<Output = Result<PullSourceShutdownResult, fidl::Error>>
583        + Send;
584    fn r#shutdown(&self) -> Self::ShutdownResponseFut;
585}
586#[derive(Debug)]
587#[cfg(target_os = "fuchsia")]
588pub struct PullSourceSynchronousProxy {
589    client: fidl::client::sync::Client,
590}
591
592#[cfg(target_os = "fuchsia")]
593impl fidl::endpoints::SynchronousProxy for PullSourceSynchronousProxy {
594    type Proxy = PullSourceProxy;
595    type Protocol = PullSourceMarker;
596
597    fn from_channel(inner: fidl::Channel) -> Self {
598        Self::new(inner)
599    }
600
601    fn into_channel(self) -> fidl::Channel {
602        self.client.into_channel()
603    }
604
605    fn as_channel(&self) -> &fidl::Channel {
606        self.client.as_channel()
607    }
608}
609
610#[cfg(target_os = "fuchsia")]
611impl PullSourceSynchronousProxy {
612    pub fn new(channel: fidl::Channel) -> Self {
613        Self { client: fidl::client::sync::Client::new(channel) }
614    }
615
616    pub fn into_channel(self) -> fidl::Channel {
617        self.client.into_channel()
618    }
619
620    /// Waits until an event arrives and returns it. It is safe for other
621    /// threads to make concurrent requests while waiting for an event.
622    pub fn wait_for_event(
623        &self,
624        deadline: zx::MonotonicInstant,
625    ) -> Result<PullSourceEvent, fidl::Error> {
626        PullSourceEvent::decode(self.client.wait_for_event::<PullSourceMarker>(deadline)?)
627    }
628
629    /// Notifies the time source of changes to global properties of the device
630    /// that it may use to increase accuracy of time measurements.
631    pub fn r#update_device_properties(
632        &self,
633        mut properties: &Properties,
634    ) -> Result<(), fidl::Error> {
635        self.client.send::<TimeSourceUpdateDevicePropertiesRequest>(
636            (properties,),
637            0x63704f8bd0962f00,
638            fidl::encoding::DynamicFlags::empty(),
639        )
640    }
641
642    /// Produce a new time sample.
643    ///
644    /// The server may consider the supplied urgency and will potentially
645    /// produce a sample more quickly but with lower accuracy when a request
646    /// is marked urgent.
647    ///
648    /// The server will return an error for permanent errors but will block
649    /// on conditions that are not known to be permanent (e.g. network not
650    /// connected).
651    ///
652    /// The server will return a RATE_LIMITED error if the client should wait
653    /// before requesting another sample. In this case the client may call
654    /// `NextPossibleSampleTime` to determine when the time source will be
655    /// willing to produce another sample.
656    pub fn r#sample(
657        &self,
658        mut urgency: Urgency,
659        ___deadline: zx::MonotonicInstant,
660    ) -> Result<PullSourceSampleResult, fidl::Error> {
661        let _response = self.client.send_query::<
662            PullSourceSampleRequest,
663            fidl::encoding::ResultType<PullSourceSampleResponse, Error>,
664            PullSourceMarker,
665        >(
666            (urgency,),
667            0x2d29007d8c9cb45a,
668            fidl::encoding::DynamicFlags::empty(),
669            ___deadline,
670        )?;
671        Ok(_response.map(|x| x.sample))
672    }
673
674    /// Returns the monotonic time at which the PullSource is willing to produce
675    /// another sample. If the PullSource is not rate limited it will return a
676    /// time less than or equal to current monotonic time.
677    pub fn r#next_possible_sample_time(
678        &self,
679        ___deadline: zx::MonotonicInstant,
680    ) -> Result<i64, fidl::Error> {
681        let _response = self.client.send_query::<
682            fidl::encoding::EmptyPayload,
683            PullSourceNextPossibleSampleTimeResponse,
684            PullSourceMarker,
685        >(
686            (),
687            0x69ca2b1fd63e88a5,
688            fidl::encoding::DynamicFlags::empty(),
689            ___deadline,
690        )?;
691        Ok(_response.next_possible_time)
692    }
693
694    /// Notifies the time source that it is about to be shut down.
695    ///
696    /// The time source should escrow its Inspect data to allow it to be
697    /// retrieved after the component has stopped.
698    pub fn r#shutdown(
699        &self,
700        ___deadline: zx::MonotonicInstant,
701    ) -> Result<PullSourceShutdownResult, fidl::Error> {
702        let _response = self.client.send_query::<
703            fidl::encoding::EmptyPayload,
704            fidl::encoding::ResultType<PullSourceShutdownResponse, EscrowError>,
705            PullSourceMarker,
706        >(
707            (),
708            0x5af7be0454cfa942,
709            fidl::encoding::DynamicFlags::empty(),
710            ___deadline,
711        )?;
712        Ok(_response.map(|x| x.escrow_token))
713    }
714}
715
716#[cfg(target_os = "fuchsia")]
717impl From<PullSourceSynchronousProxy> for zx::NullableHandle {
718    fn from(value: PullSourceSynchronousProxy) -> Self {
719        value.into_channel().into()
720    }
721}
722
723#[cfg(target_os = "fuchsia")]
724impl From<fidl::Channel> for PullSourceSynchronousProxy {
725    fn from(value: fidl::Channel) -> Self {
726        Self::new(value)
727    }
728}
729
730#[cfg(target_os = "fuchsia")]
731impl fidl::endpoints::FromClient for PullSourceSynchronousProxy {
732    type Protocol = PullSourceMarker;
733
734    fn from_client(value: fidl::endpoints::ClientEnd<PullSourceMarker>) -> Self {
735        Self::new(value.into_channel())
736    }
737}
738
739#[derive(Debug, Clone)]
740pub struct PullSourceProxy {
741    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
742}
743
744impl fidl::endpoints::Proxy for PullSourceProxy {
745    type Protocol = PullSourceMarker;
746
747    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
748        Self::new(inner)
749    }
750
751    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
752        self.client.into_channel().map_err(|client| Self { client })
753    }
754
755    fn as_channel(&self) -> &::fidl::AsyncChannel {
756        self.client.as_channel()
757    }
758}
759
760impl PullSourceProxy {
761    /// Create a new Proxy for fuchsia.time.external/PullSource.
762    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
763        let protocol_name = <PullSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
764        Self { client: fidl::client::Client::new(channel, protocol_name) }
765    }
766
767    /// Get a Stream of events from the remote end of the protocol.
768    ///
769    /// # Panics
770    ///
771    /// Panics if the event stream was already taken.
772    pub fn take_event_stream(&self) -> PullSourceEventStream {
773        PullSourceEventStream { event_receiver: self.client.take_event_receiver() }
774    }
775
776    /// Notifies the time source of changes to global properties of the device
777    /// that it may use to increase accuracy of time measurements.
778    pub fn r#update_device_properties(
779        &self,
780        mut properties: &Properties,
781    ) -> Result<(), fidl::Error> {
782        PullSourceProxyInterface::r#update_device_properties(self, properties)
783    }
784
785    /// Produce a new time sample.
786    ///
787    /// The server may consider the supplied urgency and will potentially
788    /// produce a sample more quickly but with lower accuracy when a request
789    /// is marked urgent.
790    ///
791    /// The server will return an error for permanent errors but will block
792    /// on conditions that are not known to be permanent (e.g. network not
793    /// connected).
794    ///
795    /// The server will return a RATE_LIMITED error if the client should wait
796    /// before requesting another sample. In this case the client may call
797    /// `NextPossibleSampleTime` to determine when the time source will be
798    /// willing to produce another sample.
799    pub fn r#sample(
800        &self,
801        mut urgency: Urgency,
802    ) -> fidl::client::QueryResponseFut<
803        PullSourceSampleResult,
804        fidl::encoding::DefaultFuchsiaResourceDialect,
805    > {
806        PullSourceProxyInterface::r#sample(self, urgency)
807    }
808
809    /// Returns the monotonic time at which the PullSource is willing to produce
810    /// another sample. If the PullSource is not rate limited it will return a
811    /// time less than or equal to current monotonic time.
812    pub fn r#next_possible_sample_time(
813        &self,
814    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
815        PullSourceProxyInterface::r#next_possible_sample_time(self)
816    }
817
818    /// Notifies the time source that it is about to be shut down.
819    ///
820    /// The time source should escrow its Inspect data to allow it to be
821    /// retrieved after the component has stopped.
822    pub fn r#shutdown(
823        &self,
824    ) -> fidl::client::QueryResponseFut<
825        PullSourceShutdownResult,
826        fidl::encoding::DefaultFuchsiaResourceDialect,
827    > {
828        PullSourceProxyInterface::r#shutdown(self)
829    }
830}
831
832impl PullSourceProxyInterface for PullSourceProxy {
833    fn r#update_device_properties(&self, mut properties: &Properties) -> Result<(), fidl::Error> {
834        self.client.send::<TimeSourceUpdateDevicePropertiesRequest>(
835            (properties,),
836            0x63704f8bd0962f00,
837            fidl::encoding::DynamicFlags::empty(),
838        )
839    }
840
841    type SampleResponseFut = fidl::client::QueryResponseFut<
842        PullSourceSampleResult,
843        fidl::encoding::DefaultFuchsiaResourceDialect,
844    >;
845    fn r#sample(&self, mut urgency: Urgency) -> Self::SampleResponseFut {
846        fn _decode(
847            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
848        ) -> Result<PullSourceSampleResult, fidl::Error> {
849            let _response = fidl::client::decode_transaction_body::<
850                fidl::encoding::ResultType<PullSourceSampleResponse, Error>,
851                fidl::encoding::DefaultFuchsiaResourceDialect,
852                0x2d29007d8c9cb45a,
853            >(_buf?)?;
854            Ok(_response.map(|x| x.sample))
855        }
856        self.client.send_query_and_decode::<PullSourceSampleRequest, PullSourceSampleResult>(
857            (urgency,),
858            0x2d29007d8c9cb45a,
859            fidl::encoding::DynamicFlags::empty(),
860            _decode,
861        )
862    }
863
864    type NextPossibleSampleTimeResponseFut =
865        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
866    fn r#next_possible_sample_time(&self) -> Self::NextPossibleSampleTimeResponseFut {
867        fn _decode(
868            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
869        ) -> Result<i64, fidl::Error> {
870            let _response = fidl::client::decode_transaction_body::<
871                PullSourceNextPossibleSampleTimeResponse,
872                fidl::encoding::DefaultFuchsiaResourceDialect,
873                0x69ca2b1fd63e88a5,
874            >(_buf?)?;
875            Ok(_response.next_possible_time)
876        }
877        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
878            (),
879            0x69ca2b1fd63e88a5,
880            fidl::encoding::DynamicFlags::empty(),
881            _decode,
882        )
883    }
884
885    type ShutdownResponseFut = fidl::client::QueryResponseFut<
886        PullSourceShutdownResult,
887        fidl::encoding::DefaultFuchsiaResourceDialect,
888    >;
889    fn r#shutdown(&self) -> Self::ShutdownResponseFut {
890        fn _decode(
891            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
892        ) -> Result<PullSourceShutdownResult, fidl::Error> {
893            let _response = fidl::client::decode_transaction_body::<
894                fidl::encoding::ResultType<PullSourceShutdownResponse, EscrowError>,
895                fidl::encoding::DefaultFuchsiaResourceDialect,
896                0x5af7be0454cfa942,
897            >(_buf?)?;
898            Ok(_response.map(|x| x.escrow_token))
899        }
900        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PullSourceShutdownResult>(
901            (),
902            0x5af7be0454cfa942,
903            fidl::encoding::DynamicFlags::empty(),
904            _decode,
905        )
906    }
907}
908
909pub struct PullSourceEventStream {
910    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
911}
912
913impl std::marker::Unpin for PullSourceEventStream {}
914
915impl futures::stream::FusedStream for PullSourceEventStream {
916    fn is_terminated(&self) -> bool {
917        self.event_receiver.is_terminated()
918    }
919}
920
921impl futures::Stream for PullSourceEventStream {
922    type Item = Result<PullSourceEvent, fidl::Error>;
923
924    fn poll_next(
925        mut self: std::pin::Pin<&mut Self>,
926        cx: &mut std::task::Context<'_>,
927    ) -> std::task::Poll<Option<Self::Item>> {
928        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
929            &mut self.event_receiver,
930            cx
931        )?) {
932            Some(buf) => std::task::Poll::Ready(Some(PullSourceEvent::decode(buf))),
933            None => std::task::Poll::Ready(None),
934        }
935    }
936}
937
938#[derive(Debug)]
939pub enum PullSourceEvent {}
940
941impl PullSourceEvent {
942    /// Decodes a message buffer as a [`PullSourceEvent`].
943    fn decode(
944        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
945    ) -> Result<PullSourceEvent, fidl::Error> {
946        let (bytes, _handles) = buf.split_mut();
947        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
948        debug_assert_eq!(tx_header.tx_id, 0);
949        match tx_header.ordinal {
950            _ => Err(fidl::Error::UnknownOrdinal {
951                ordinal: tx_header.ordinal,
952                protocol_name: <PullSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
953            }),
954        }
955    }
956}
957
958/// A Stream of incoming requests for fuchsia.time.external/PullSource.
959pub struct PullSourceRequestStream {
960    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
961    is_terminated: bool,
962}
963
964impl std::marker::Unpin for PullSourceRequestStream {}
965
966impl futures::stream::FusedStream for PullSourceRequestStream {
967    fn is_terminated(&self) -> bool {
968        self.is_terminated
969    }
970}
971
972impl fidl::endpoints::RequestStream for PullSourceRequestStream {
973    type Protocol = PullSourceMarker;
974    type ControlHandle = PullSourceControlHandle;
975
976    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
977        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
978    }
979
980    fn control_handle(&self) -> Self::ControlHandle {
981        PullSourceControlHandle { inner: self.inner.clone() }
982    }
983
984    fn into_inner(
985        self,
986    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
987    {
988        (self.inner, self.is_terminated)
989    }
990
991    fn from_inner(
992        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
993        is_terminated: bool,
994    ) -> Self {
995        Self { inner, is_terminated }
996    }
997}
998
999impl futures::Stream for PullSourceRequestStream {
1000    type Item = Result<PullSourceRequest, fidl::Error>;
1001
1002    fn poll_next(
1003        mut self: std::pin::Pin<&mut Self>,
1004        cx: &mut std::task::Context<'_>,
1005    ) -> std::task::Poll<Option<Self::Item>> {
1006        let this = &mut *self;
1007        if this.inner.check_shutdown(cx) {
1008            this.is_terminated = true;
1009            return std::task::Poll::Ready(None);
1010        }
1011        if this.is_terminated {
1012            panic!("polled PullSourceRequestStream after completion");
1013        }
1014        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1015            |bytes, handles| {
1016                match this.inner.channel().read_etc(cx, bytes, handles) {
1017                    std::task::Poll::Ready(Ok(())) => {}
1018                    std::task::Poll::Pending => return std::task::Poll::Pending,
1019                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1020                        this.is_terminated = true;
1021                        return std::task::Poll::Ready(None);
1022                    }
1023                    std::task::Poll::Ready(Err(e)) => {
1024                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1025                            e.into(),
1026                        ))));
1027                    }
1028                }
1029
1030                // A message has been received from the channel
1031                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1032
1033                std::task::Poll::Ready(Some(match header.ordinal {
1034                    0x63704f8bd0962f00 => {
1035                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1036                        let mut req = fidl::new_empty!(
1037                            TimeSourceUpdateDevicePropertiesRequest,
1038                            fidl::encoding::DefaultFuchsiaResourceDialect
1039                        );
1040                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TimeSourceUpdateDevicePropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
1041                        let control_handle = PullSourceControlHandle { inner: this.inner.clone() };
1042                        Ok(PullSourceRequest::UpdateDeviceProperties {
1043                            properties: req.properties,
1044
1045                            control_handle,
1046                        })
1047                    }
1048                    0x2d29007d8c9cb45a => {
1049                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1050                        let mut req = fidl::new_empty!(
1051                            PullSourceSampleRequest,
1052                            fidl::encoding::DefaultFuchsiaResourceDialect
1053                        );
1054                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PullSourceSampleRequest>(&header, _body_bytes, handles, &mut req)?;
1055                        let control_handle = PullSourceControlHandle { inner: this.inner.clone() };
1056                        Ok(PullSourceRequest::Sample {
1057                            urgency: req.urgency,
1058
1059                            responder: PullSourceSampleResponder {
1060                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1061                                tx_id: header.tx_id,
1062                            },
1063                        })
1064                    }
1065                    0x69ca2b1fd63e88a5 => {
1066                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1067                        let mut req = fidl::new_empty!(
1068                            fidl::encoding::EmptyPayload,
1069                            fidl::encoding::DefaultFuchsiaResourceDialect
1070                        );
1071                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1072                        let control_handle = PullSourceControlHandle { inner: this.inner.clone() };
1073                        Ok(PullSourceRequest::NextPossibleSampleTime {
1074                            responder: PullSourceNextPossibleSampleTimeResponder {
1075                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1076                                tx_id: header.tx_id,
1077                            },
1078                        })
1079                    }
1080                    0x5af7be0454cfa942 => {
1081                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1082                        let mut req = fidl::new_empty!(
1083                            fidl::encoding::EmptyPayload,
1084                            fidl::encoding::DefaultFuchsiaResourceDialect
1085                        );
1086                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1087                        let control_handle = PullSourceControlHandle { inner: this.inner.clone() };
1088                        Ok(PullSourceRequest::Shutdown {
1089                            responder: PullSourceShutdownResponder {
1090                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1091                                tx_id: header.tx_id,
1092                            },
1093                        })
1094                    }
1095                    _ => Err(fidl::Error::UnknownOrdinal {
1096                        ordinal: header.ordinal,
1097                        protocol_name:
1098                            <PullSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1099                    }),
1100                }))
1101            },
1102        )
1103    }
1104}
1105
1106/// A protocol for time sources that produce time samples on demand.
1107#[derive(Debug)]
1108pub enum PullSourceRequest {
1109    /// Notifies the time source of changes to global properties of the device
1110    /// that it may use to increase accuracy of time measurements.
1111    UpdateDeviceProperties { properties: Properties, control_handle: PullSourceControlHandle },
1112    /// Produce a new time sample.
1113    ///
1114    /// The server may consider the supplied urgency and will potentially
1115    /// produce a sample more quickly but with lower accuracy when a request
1116    /// is marked urgent.
1117    ///
1118    /// The server will return an error for permanent errors but will block
1119    /// on conditions that are not known to be permanent (e.g. network not
1120    /// connected).
1121    ///
1122    /// The server will return a RATE_LIMITED error if the client should wait
1123    /// before requesting another sample. In this case the client may call
1124    /// `NextPossibleSampleTime` to determine when the time source will be
1125    /// willing to produce another sample.
1126    Sample { urgency: Urgency, responder: PullSourceSampleResponder },
1127    /// Returns the monotonic time at which the PullSource is willing to produce
1128    /// another sample. If the PullSource is not rate limited it will return a
1129    /// time less than or equal to current monotonic time.
1130    NextPossibleSampleTime { responder: PullSourceNextPossibleSampleTimeResponder },
1131    /// Notifies the time source that it is about to be shut down.
1132    ///
1133    /// The time source should escrow its Inspect data to allow it to be
1134    /// retrieved after the component has stopped.
1135    Shutdown { responder: PullSourceShutdownResponder },
1136}
1137
1138impl PullSourceRequest {
1139    #[allow(irrefutable_let_patterns)]
1140    pub fn into_update_device_properties(self) -> Option<(Properties, PullSourceControlHandle)> {
1141        if let PullSourceRequest::UpdateDeviceProperties { properties, control_handle } = self {
1142            Some((properties, control_handle))
1143        } else {
1144            None
1145        }
1146    }
1147
1148    #[allow(irrefutable_let_patterns)]
1149    pub fn into_sample(self) -> Option<(Urgency, PullSourceSampleResponder)> {
1150        if let PullSourceRequest::Sample { urgency, responder } = self {
1151            Some((urgency, responder))
1152        } else {
1153            None
1154        }
1155    }
1156
1157    #[allow(irrefutable_let_patterns)]
1158    pub fn into_next_possible_sample_time(
1159        self,
1160    ) -> Option<(PullSourceNextPossibleSampleTimeResponder)> {
1161        if let PullSourceRequest::NextPossibleSampleTime { responder } = self {
1162            Some((responder))
1163        } else {
1164            None
1165        }
1166    }
1167
1168    #[allow(irrefutable_let_patterns)]
1169    pub fn into_shutdown(self) -> Option<(PullSourceShutdownResponder)> {
1170        if let PullSourceRequest::Shutdown { responder } = self { Some((responder)) } else { None }
1171    }
1172
1173    /// Name of the method defined in FIDL
1174    pub fn method_name(&self) -> &'static str {
1175        match *self {
1176            PullSourceRequest::UpdateDeviceProperties { .. } => "update_device_properties",
1177            PullSourceRequest::Sample { .. } => "sample",
1178            PullSourceRequest::NextPossibleSampleTime { .. } => "next_possible_sample_time",
1179            PullSourceRequest::Shutdown { .. } => "shutdown",
1180        }
1181    }
1182}
1183
1184#[derive(Debug, Clone)]
1185pub struct PullSourceControlHandle {
1186    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1187}
1188
1189impl PullSourceControlHandle {
1190    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1191        self.inner.shutdown_with_epitaph(status.into())
1192    }
1193}
1194
1195impl fidl::endpoints::ControlHandle for PullSourceControlHandle {
1196    fn shutdown(&self) {
1197        self.inner.shutdown()
1198    }
1199
1200    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1201        self.inner.shutdown_with_epitaph(status)
1202    }
1203
1204    fn is_closed(&self) -> bool {
1205        self.inner.channel().is_closed()
1206    }
1207    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1208        self.inner.channel().on_closed()
1209    }
1210
1211    #[cfg(target_os = "fuchsia")]
1212    fn signal_peer(
1213        &self,
1214        clear_mask: zx::Signals,
1215        set_mask: zx::Signals,
1216    ) -> Result<(), zx_status::Status> {
1217        use fidl::Peered;
1218        self.inner.channel().signal_peer(clear_mask, set_mask)
1219    }
1220}
1221
1222impl PullSourceControlHandle {}
1223
1224#[must_use = "FIDL methods require a response to be sent"]
1225#[derive(Debug)]
1226pub struct PullSourceSampleResponder {
1227    control_handle: std::mem::ManuallyDrop<PullSourceControlHandle>,
1228    tx_id: u32,
1229}
1230
1231/// Set the the channel to be shutdown (see [`PullSourceControlHandle::shutdown`])
1232/// if the responder is dropped without sending a response, so that the client
1233/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1234impl std::ops::Drop for PullSourceSampleResponder {
1235    fn drop(&mut self) {
1236        self.control_handle.shutdown();
1237        // Safety: drops once, never accessed again
1238        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1239    }
1240}
1241
1242impl fidl::endpoints::Responder for PullSourceSampleResponder {
1243    type ControlHandle = PullSourceControlHandle;
1244
1245    fn control_handle(&self) -> &PullSourceControlHandle {
1246        &self.control_handle
1247    }
1248
1249    fn drop_without_shutdown(mut self) {
1250        // Safety: drops once, never accessed again due to mem::forget
1251        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1252        // Prevent Drop from running (which would shut down the channel)
1253        std::mem::forget(self);
1254    }
1255}
1256
1257impl PullSourceSampleResponder {
1258    /// Sends a response to the FIDL transaction.
1259    ///
1260    /// Sets the channel to shutdown if an error occurs.
1261    pub fn send(self, mut result: Result<&TimeSample, Error>) -> Result<(), fidl::Error> {
1262        let _result = self.send_raw(result);
1263        if _result.is_err() {
1264            self.control_handle.shutdown();
1265        }
1266        self.drop_without_shutdown();
1267        _result
1268    }
1269
1270    /// Similar to "send" but does not shutdown the channel if an error occurs.
1271    pub fn send_no_shutdown_on_err(
1272        self,
1273        mut result: Result<&TimeSample, Error>,
1274    ) -> Result<(), fidl::Error> {
1275        let _result = self.send_raw(result);
1276        self.drop_without_shutdown();
1277        _result
1278    }
1279
1280    fn send_raw(&self, mut result: Result<&TimeSample, Error>) -> Result<(), fidl::Error> {
1281        self.control_handle
1282            .inner
1283            .send::<fidl::encoding::ResultType<PullSourceSampleResponse, Error>>(
1284                result.map(|sample| (sample,)),
1285                self.tx_id,
1286                0x2d29007d8c9cb45a,
1287                fidl::encoding::DynamicFlags::empty(),
1288            )
1289    }
1290}
1291
1292#[must_use = "FIDL methods require a response to be sent"]
1293#[derive(Debug)]
1294pub struct PullSourceNextPossibleSampleTimeResponder {
1295    control_handle: std::mem::ManuallyDrop<PullSourceControlHandle>,
1296    tx_id: u32,
1297}
1298
1299/// Set the the channel to be shutdown (see [`PullSourceControlHandle::shutdown`])
1300/// if the responder is dropped without sending a response, so that the client
1301/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1302impl std::ops::Drop for PullSourceNextPossibleSampleTimeResponder {
1303    fn drop(&mut self) {
1304        self.control_handle.shutdown();
1305        // Safety: drops once, never accessed again
1306        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1307    }
1308}
1309
1310impl fidl::endpoints::Responder for PullSourceNextPossibleSampleTimeResponder {
1311    type ControlHandle = PullSourceControlHandle;
1312
1313    fn control_handle(&self) -> &PullSourceControlHandle {
1314        &self.control_handle
1315    }
1316
1317    fn drop_without_shutdown(mut self) {
1318        // Safety: drops once, never accessed again due to mem::forget
1319        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1320        // Prevent Drop from running (which would shut down the channel)
1321        std::mem::forget(self);
1322    }
1323}
1324
1325impl PullSourceNextPossibleSampleTimeResponder {
1326    /// Sends a response to the FIDL transaction.
1327    ///
1328    /// Sets the channel to shutdown if an error occurs.
1329    pub fn send(self, mut next_possible_time: i64) -> Result<(), fidl::Error> {
1330        let _result = self.send_raw(next_possible_time);
1331        if _result.is_err() {
1332            self.control_handle.shutdown();
1333        }
1334        self.drop_without_shutdown();
1335        _result
1336    }
1337
1338    /// Similar to "send" but does not shutdown the channel if an error occurs.
1339    pub fn send_no_shutdown_on_err(self, mut next_possible_time: i64) -> Result<(), fidl::Error> {
1340        let _result = self.send_raw(next_possible_time);
1341        self.drop_without_shutdown();
1342        _result
1343    }
1344
1345    fn send_raw(&self, mut next_possible_time: i64) -> Result<(), fidl::Error> {
1346        self.control_handle.inner.send::<PullSourceNextPossibleSampleTimeResponse>(
1347            (next_possible_time,),
1348            self.tx_id,
1349            0x69ca2b1fd63e88a5,
1350            fidl::encoding::DynamicFlags::empty(),
1351        )
1352    }
1353}
1354
1355#[must_use = "FIDL methods require a response to be sent"]
1356#[derive(Debug)]
1357pub struct PullSourceShutdownResponder {
1358    control_handle: std::mem::ManuallyDrop<PullSourceControlHandle>,
1359    tx_id: u32,
1360}
1361
1362/// Set the the channel to be shutdown (see [`PullSourceControlHandle::shutdown`])
1363/// if the responder is dropped without sending a response, so that the client
1364/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1365impl std::ops::Drop for PullSourceShutdownResponder {
1366    fn drop(&mut self) {
1367        self.control_handle.shutdown();
1368        // Safety: drops once, never accessed again
1369        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1370    }
1371}
1372
1373impl fidl::endpoints::Responder for PullSourceShutdownResponder {
1374    type ControlHandle = PullSourceControlHandle;
1375
1376    fn control_handle(&self) -> &PullSourceControlHandle {
1377        &self.control_handle
1378    }
1379
1380    fn drop_without_shutdown(mut self) {
1381        // Safety: drops once, never accessed again due to mem::forget
1382        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1383        // Prevent Drop from running (which would shut down the channel)
1384        std::mem::forget(self);
1385    }
1386}
1387
1388impl PullSourceShutdownResponder {
1389    /// Sends a response to the FIDL transaction.
1390    ///
1391    /// Sets the channel to shutdown if an error occurs.
1392    pub fn send(
1393        self,
1394        mut result: Result<fidl_fuchsia_inspect::EscrowToken, EscrowError>,
1395    ) -> Result<(), fidl::Error> {
1396        let _result = self.send_raw(result);
1397        if _result.is_err() {
1398            self.control_handle.shutdown();
1399        }
1400        self.drop_without_shutdown();
1401        _result
1402    }
1403
1404    /// Similar to "send" but does not shutdown the channel if an error occurs.
1405    pub fn send_no_shutdown_on_err(
1406        self,
1407        mut result: Result<fidl_fuchsia_inspect::EscrowToken, EscrowError>,
1408    ) -> Result<(), fidl::Error> {
1409        let _result = self.send_raw(result);
1410        self.drop_without_shutdown();
1411        _result
1412    }
1413
1414    fn send_raw(
1415        &self,
1416        mut result: Result<fidl_fuchsia_inspect::EscrowToken, EscrowError>,
1417    ) -> Result<(), fidl::Error> {
1418        self.control_handle
1419            .inner
1420            .send::<fidl::encoding::ResultType<PullSourceShutdownResponse, EscrowError>>(
1421                result.as_mut().map_err(|e| *e).map(|escrow_token| (escrow_token,)),
1422                self.tx_id,
1423                0x5af7be0454cfa942,
1424                fidl::encoding::DynamicFlags::empty(),
1425            )
1426    }
1427}
1428
1429#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1430pub struct PushSourceMarker;
1431
1432impl fidl::endpoints::ProtocolMarker for PushSourceMarker {
1433    type Proxy = PushSourceProxy;
1434    type RequestStream = PushSourceRequestStream;
1435    #[cfg(target_os = "fuchsia")]
1436    type SynchronousProxy = PushSourceSynchronousProxy;
1437
1438    const DEBUG_NAME: &'static str = "fuchsia.time.external.PushSource";
1439}
1440impl fidl::endpoints::DiscoverableProtocolMarker for PushSourceMarker {}
1441
1442pub trait PushSourceProxyInterface: Send + Sync {
1443    fn r#update_device_properties(&self, properties: &Properties) -> Result<(), fidl::Error>;
1444    type WatchSampleResponseFut: std::future::Future<Output = Result<TimeSample, fidl::Error>>
1445        + Send;
1446    fn r#watch_sample(&self) -> Self::WatchSampleResponseFut;
1447    type WatchStatusResponseFut: std::future::Future<Output = Result<Status, fidl::Error>> + Send;
1448    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
1449}
1450#[derive(Debug)]
1451#[cfg(target_os = "fuchsia")]
1452pub struct PushSourceSynchronousProxy {
1453    client: fidl::client::sync::Client,
1454}
1455
1456#[cfg(target_os = "fuchsia")]
1457impl fidl::endpoints::SynchronousProxy for PushSourceSynchronousProxy {
1458    type Proxy = PushSourceProxy;
1459    type Protocol = PushSourceMarker;
1460
1461    fn from_channel(inner: fidl::Channel) -> Self {
1462        Self::new(inner)
1463    }
1464
1465    fn into_channel(self) -> fidl::Channel {
1466        self.client.into_channel()
1467    }
1468
1469    fn as_channel(&self) -> &fidl::Channel {
1470        self.client.as_channel()
1471    }
1472}
1473
1474#[cfg(target_os = "fuchsia")]
1475impl PushSourceSynchronousProxy {
1476    pub fn new(channel: fidl::Channel) -> Self {
1477        Self { client: fidl::client::sync::Client::new(channel) }
1478    }
1479
1480    pub fn into_channel(self) -> fidl::Channel {
1481        self.client.into_channel()
1482    }
1483
1484    /// Waits until an event arrives and returns it. It is safe for other
1485    /// threads to make concurrent requests while waiting for an event.
1486    pub fn wait_for_event(
1487        &self,
1488        deadline: zx::MonotonicInstant,
1489    ) -> Result<PushSourceEvent, fidl::Error> {
1490        PushSourceEvent::decode(self.client.wait_for_event::<PushSourceMarker>(deadline)?)
1491    }
1492
1493    /// Notifies the time source of changes to global properties of the device
1494    /// that it may use to increase accuracy of time measurements.
1495    pub fn r#update_device_properties(
1496        &self,
1497        mut properties: &Properties,
1498    ) -> Result<(), fidl::Error> {
1499        self.client.send::<TimeSourceUpdateDevicePropertiesRequest>(
1500            (properties,),
1501            0x63704f8bd0962f00,
1502            fidl::encoding::DynamicFlags::empty(),
1503        )
1504    }
1505
1506    /// Watch for new time samples from the time source. This method is a
1507    /// hanging get and returns the latest time sample if one is available and
1508    /// has not already been returned to the client. If no such sample is
1509    /// available, the method will hang until one is produced and return it
1510    /// then.
1511    ///
1512    /// Note that it is entirely at the discretion of the PushSource
1513    /// implementation when to produce a sample; a call to WatchSample does
1514    /// not necessarily trigger sample collection.
1515    ///
1516    /// In the case a client sends a second WatchSample request while another
1517    /// request is active, the channel is closed with a ZX_ERR_BAD_STATE
1518    /// epitaph.
1519    pub fn r#watch_sample(
1520        &self,
1521        ___deadline: zx::MonotonicInstant,
1522    ) -> Result<TimeSample, fidl::Error> {
1523        let _response = self.client.send_query::<
1524            fidl::encoding::EmptyPayload,
1525            PushSourceWatchSampleResponse,
1526            PushSourceMarker,
1527        >(
1528            (),
1529            0x44d515a56e8304dc,
1530            fidl::encoding::DynamicFlags::empty(),
1531            ___deadline,
1532        )?;
1533        Ok(_response.sample)
1534    }
1535
1536    /// Watch for changes in the status of the time source.
1537    ///
1538    /// This method is a hanging get that returns when the status changes from
1539    /// the last status reported to the client.
1540    ///
1541    /// In the case a client sends a second WatchStatus request while another
1542    /// request is active, the channel is closed with a ZX_ERR_BAD_STATE
1543    /// epitaph.
1544    pub fn r#watch_status(&self, ___deadline: zx::MonotonicInstant) -> Result<Status, fidl::Error> {
1545        let _response = self.client.send_query::<
1546            fidl::encoding::EmptyPayload,
1547            PushSourceWatchStatusResponse,
1548            PushSourceMarker,
1549        >(
1550            (),
1551            0x60621a545f488bb1,
1552            fidl::encoding::DynamicFlags::empty(),
1553            ___deadline,
1554        )?;
1555        Ok(_response.status)
1556    }
1557}
1558
1559#[cfg(target_os = "fuchsia")]
1560impl From<PushSourceSynchronousProxy> for zx::NullableHandle {
1561    fn from(value: PushSourceSynchronousProxy) -> Self {
1562        value.into_channel().into()
1563    }
1564}
1565
1566#[cfg(target_os = "fuchsia")]
1567impl From<fidl::Channel> for PushSourceSynchronousProxy {
1568    fn from(value: fidl::Channel) -> Self {
1569        Self::new(value)
1570    }
1571}
1572
1573#[cfg(target_os = "fuchsia")]
1574impl fidl::endpoints::FromClient for PushSourceSynchronousProxy {
1575    type Protocol = PushSourceMarker;
1576
1577    fn from_client(value: fidl::endpoints::ClientEnd<PushSourceMarker>) -> Self {
1578        Self::new(value.into_channel())
1579    }
1580}
1581
1582#[derive(Debug, Clone)]
1583pub struct PushSourceProxy {
1584    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1585}
1586
1587impl fidl::endpoints::Proxy for PushSourceProxy {
1588    type Protocol = PushSourceMarker;
1589
1590    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1591        Self::new(inner)
1592    }
1593
1594    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1595        self.client.into_channel().map_err(|client| Self { client })
1596    }
1597
1598    fn as_channel(&self) -> &::fidl::AsyncChannel {
1599        self.client.as_channel()
1600    }
1601}
1602
1603impl PushSourceProxy {
1604    /// Create a new Proxy for fuchsia.time.external/PushSource.
1605    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1606        let protocol_name = <PushSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1607        Self { client: fidl::client::Client::new(channel, protocol_name) }
1608    }
1609
1610    /// Get a Stream of events from the remote end of the protocol.
1611    ///
1612    /// # Panics
1613    ///
1614    /// Panics if the event stream was already taken.
1615    pub fn take_event_stream(&self) -> PushSourceEventStream {
1616        PushSourceEventStream { event_receiver: self.client.take_event_receiver() }
1617    }
1618
1619    /// Notifies the time source of changes to global properties of the device
1620    /// that it may use to increase accuracy of time measurements.
1621    pub fn r#update_device_properties(
1622        &self,
1623        mut properties: &Properties,
1624    ) -> Result<(), fidl::Error> {
1625        PushSourceProxyInterface::r#update_device_properties(self, properties)
1626    }
1627
1628    /// Watch for new time samples from the time source. This method is a
1629    /// hanging get and returns the latest time sample if one is available and
1630    /// has not already been returned to the client. If no such sample is
1631    /// available, the method will hang until one is produced and return it
1632    /// then.
1633    ///
1634    /// Note that it is entirely at the discretion of the PushSource
1635    /// implementation when to produce a sample; a call to WatchSample does
1636    /// not necessarily trigger sample collection.
1637    ///
1638    /// In the case a client sends a second WatchSample request while another
1639    /// request is active, the channel is closed with a ZX_ERR_BAD_STATE
1640    /// epitaph.
1641    pub fn r#watch_sample(
1642        &self,
1643    ) -> fidl::client::QueryResponseFut<TimeSample, fidl::encoding::DefaultFuchsiaResourceDialect>
1644    {
1645        PushSourceProxyInterface::r#watch_sample(self)
1646    }
1647
1648    /// Watch for changes in the status of the time source.
1649    ///
1650    /// This method is a hanging get that returns when the status changes from
1651    /// the last status reported to the client.
1652    ///
1653    /// In the case a client sends a second WatchStatus request while another
1654    /// request is active, the channel is closed with a ZX_ERR_BAD_STATE
1655    /// epitaph.
1656    pub fn r#watch_status(
1657        &self,
1658    ) -> fidl::client::QueryResponseFut<Status, fidl::encoding::DefaultFuchsiaResourceDialect> {
1659        PushSourceProxyInterface::r#watch_status(self)
1660    }
1661}
1662
1663impl PushSourceProxyInterface for PushSourceProxy {
1664    fn r#update_device_properties(&self, mut properties: &Properties) -> Result<(), fidl::Error> {
1665        self.client.send::<TimeSourceUpdateDevicePropertiesRequest>(
1666            (properties,),
1667            0x63704f8bd0962f00,
1668            fidl::encoding::DynamicFlags::empty(),
1669        )
1670    }
1671
1672    type WatchSampleResponseFut =
1673        fidl::client::QueryResponseFut<TimeSample, fidl::encoding::DefaultFuchsiaResourceDialect>;
1674    fn r#watch_sample(&self) -> Self::WatchSampleResponseFut {
1675        fn _decode(
1676            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1677        ) -> Result<TimeSample, fidl::Error> {
1678            let _response = fidl::client::decode_transaction_body::<
1679                PushSourceWatchSampleResponse,
1680                fidl::encoding::DefaultFuchsiaResourceDialect,
1681                0x44d515a56e8304dc,
1682            >(_buf?)?;
1683            Ok(_response.sample)
1684        }
1685        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, TimeSample>(
1686            (),
1687            0x44d515a56e8304dc,
1688            fidl::encoding::DynamicFlags::empty(),
1689            _decode,
1690        )
1691    }
1692
1693    type WatchStatusResponseFut =
1694        fidl::client::QueryResponseFut<Status, fidl::encoding::DefaultFuchsiaResourceDialect>;
1695    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
1696        fn _decode(
1697            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1698        ) -> Result<Status, fidl::Error> {
1699            let _response = fidl::client::decode_transaction_body::<
1700                PushSourceWatchStatusResponse,
1701                fidl::encoding::DefaultFuchsiaResourceDialect,
1702                0x60621a545f488bb1,
1703            >(_buf?)?;
1704            Ok(_response.status)
1705        }
1706        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Status>(
1707            (),
1708            0x60621a545f488bb1,
1709            fidl::encoding::DynamicFlags::empty(),
1710            _decode,
1711        )
1712    }
1713}
1714
1715pub struct PushSourceEventStream {
1716    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1717}
1718
1719impl std::marker::Unpin for PushSourceEventStream {}
1720
1721impl futures::stream::FusedStream for PushSourceEventStream {
1722    fn is_terminated(&self) -> bool {
1723        self.event_receiver.is_terminated()
1724    }
1725}
1726
1727impl futures::Stream for PushSourceEventStream {
1728    type Item = Result<PushSourceEvent, fidl::Error>;
1729
1730    fn poll_next(
1731        mut self: std::pin::Pin<&mut Self>,
1732        cx: &mut std::task::Context<'_>,
1733    ) -> std::task::Poll<Option<Self::Item>> {
1734        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1735            &mut self.event_receiver,
1736            cx
1737        )?) {
1738            Some(buf) => std::task::Poll::Ready(Some(PushSourceEvent::decode(buf))),
1739            None => std::task::Poll::Ready(None),
1740        }
1741    }
1742}
1743
1744#[derive(Debug)]
1745pub enum PushSourceEvent {}
1746
1747impl PushSourceEvent {
1748    /// Decodes a message buffer as a [`PushSourceEvent`].
1749    fn decode(
1750        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1751    ) -> Result<PushSourceEvent, fidl::Error> {
1752        let (bytes, _handles) = buf.split_mut();
1753        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1754        debug_assert_eq!(tx_header.tx_id, 0);
1755        match tx_header.ordinal {
1756            _ => Err(fidl::Error::UnknownOrdinal {
1757                ordinal: tx_header.ordinal,
1758                protocol_name: <PushSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1759            }),
1760        }
1761    }
1762}
1763
1764/// A Stream of incoming requests for fuchsia.time.external/PushSource.
1765pub struct PushSourceRequestStream {
1766    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1767    is_terminated: bool,
1768}
1769
1770impl std::marker::Unpin for PushSourceRequestStream {}
1771
1772impl futures::stream::FusedStream for PushSourceRequestStream {
1773    fn is_terminated(&self) -> bool {
1774        self.is_terminated
1775    }
1776}
1777
1778impl fidl::endpoints::RequestStream for PushSourceRequestStream {
1779    type Protocol = PushSourceMarker;
1780    type ControlHandle = PushSourceControlHandle;
1781
1782    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1783        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1784    }
1785
1786    fn control_handle(&self) -> Self::ControlHandle {
1787        PushSourceControlHandle { inner: self.inner.clone() }
1788    }
1789
1790    fn into_inner(
1791        self,
1792    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1793    {
1794        (self.inner, self.is_terminated)
1795    }
1796
1797    fn from_inner(
1798        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1799        is_terminated: bool,
1800    ) -> Self {
1801        Self { inner, is_terminated }
1802    }
1803}
1804
1805impl futures::Stream for PushSourceRequestStream {
1806    type Item = Result<PushSourceRequest, fidl::Error>;
1807
1808    fn poll_next(
1809        mut self: std::pin::Pin<&mut Self>,
1810        cx: &mut std::task::Context<'_>,
1811    ) -> std::task::Poll<Option<Self::Item>> {
1812        let this = &mut *self;
1813        if this.inner.check_shutdown(cx) {
1814            this.is_terminated = true;
1815            return std::task::Poll::Ready(None);
1816        }
1817        if this.is_terminated {
1818            panic!("polled PushSourceRequestStream after completion");
1819        }
1820        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1821            |bytes, handles| {
1822                match this.inner.channel().read_etc(cx, bytes, handles) {
1823                    std::task::Poll::Ready(Ok(())) => {}
1824                    std::task::Poll::Pending => return std::task::Poll::Pending,
1825                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1826                        this.is_terminated = true;
1827                        return std::task::Poll::Ready(None);
1828                    }
1829                    std::task::Poll::Ready(Err(e)) => {
1830                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1831                            e.into(),
1832                        ))));
1833                    }
1834                }
1835
1836                // A message has been received from the channel
1837                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1838
1839                std::task::Poll::Ready(Some(match header.ordinal {
1840                    0x63704f8bd0962f00 => {
1841                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1842                        let mut req = fidl::new_empty!(
1843                            TimeSourceUpdateDevicePropertiesRequest,
1844                            fidl::encoding::DefaultFuchsiaResourceDialect
1845                        );
1846                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TimeSourceUpdateDevicePropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
1847                        let control_handle = PushSourceControlHandle { inner: this.inner.clone() };
1848                        Ok(PushSourceRequest::UpdateDeviceProperties {
1849                            properties: req.properties,
1850
1851                            control_handle,
1852                        })
1853                    }
1854                    0x44d515a56e8304dc => {
1855                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1856                        let mut req = fidl::new_empty!(
1857                            fidl::encoding::EmptyPayload,
1858                            fidl::encoding::DefaultFuchsiaResourceDialect
1859                        );
1860                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1861                        let control_handle = PushSourceControlHandle { inner: this.inner.clone() };
1862                        Ok(PushSourceRequest::WatchSample {
1863                            responder: PushSourceWatchSampleResponder {
1864                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1865                                tx_id: header.tx_id,
1866                            },
1867                        })
1868                    }
1869                    0x60621a545f488bb1 => {
1870                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1871                        let mut req = fidl::new_empty!(
1872                            fidl::encoding::EmptyPayload,
1873                            fidl::encoding::DefaultFuchsiaResourceDialect
1874                        );
1875                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1876                        let control_handle = PushSourceControlHandle { inner: this.inner.clone() };
1877                        Ok(PushSourceRequest::WatchStatus {
1878                            responder: PushSourceWatchStatusResponder {
1879                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1880                                tx_id: header.tx_id,
1881                            },
1882                        })
1883                    }
1884                    _ => Err(fidl::Error::UnknownOrdinal {
1885                        ordinal: header.ordinal,
1886                        protocol_name:
1887                            <PushSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1888                    }),
1889                }))
1890            },
1891        )
1892    }
1893}
1894
1895/// A protocol for time sources that produce time samples on a schedule that it
1896/// dictates. A PushSource does not report errors to clients as it is
1897/// responsible for handling them internally. Instead, a PushSource reports a
1898/// general health indication through the `WatchHealth` method to reflect
1899/// whether or not it expects to successfully produce time samples.
1900#[derive(Debug)]
1901pub enum PushSourceRequest {
1902    /// Notifies the time source of changes to global properties of the device
1903    /// that it may use to increase accuracy of time measurements.
1904    UpdateDeviceProperties { properties: Properties, control_handle: PushSourceControlHandle },
1905    /// Watch for new time samples from the time source. This method is a
1906    /// hanging get and returns the latest time sample if one is available and
1907    /// has not already been returned to the client. If no such sample is
1908    /// available, the method will hang until one is produced and return it
1909    /// then.
1910    ///
1911    /// Note that it is entirely at the discretion of the PushSource
1912    /// implementation when to produce a sample; a call to WatchSample does
1913    /// not necessarily trigger sample collection.
1914    ///
1915    /// In the case a client sends a second WatchSample request while another
1916    /// request is active, the channel is closed with a ZX_ERR_BAD_STATE
1917    /// epitaph.
1918    WatchSample { responder: PushSourceWatchSampleResponder },
1919    /// Watch for changes in the status of the time source.
1920    ///
1921    /// This method is a hanging get that returns when the status changes from
1922    /// the last status reported to the client.
1923    ///
1924    /// In the case a client sends a second WatchStatus request while another
1925    /// request is active, the channel is closed with a ZX_ERR_BAD_STATE
1926    /// epitaph.
1927    WatchStatus { responder: PushSourceWatchStatusResponder },
1928}
1929
1930impl PushSourceRequest {
1931    #[allow(irrefutable_let_patterns)]
1932    pub fn into_update_device_properties(self) -> Option<(Properties, PushSourceControlHandle)> {
1933        if let PushSourceRequest::UpdateDeviceProperties { properties, control_handle } = self {
1934            Some((properties, control_handle))
1935        } else {
1936            None
1937        }
1938    }
1939
1940    #[allow(irrefutable_let_patterns)]
1941    pub fn into_watch_sample(self) -> Option<(PushSourceWatchSampleResponder)> {
1942        if let PushSourceRequest::WatchSample { responder } = self {
1943            Some((responder))
1944        } else {
1945            None
1946        }
1947    }
1948
1949    #[allow(irrefutable_let_patterns)]
1950    pub fn into_watch_status(self) -> Option<(PushSourceWatchStatusResponder)> {
1951        if let PushSourceRequest::WatchStatus { responder } = self {
1952            Some((responder))
1953        } else {
1954            None
1955        }
1956    }
1957
1958    /// Name of the method defined in FIDL
1959    pub fn method_name(&self) -> &'static str {
1960        match *self {
1961            PushSourceRequest::UpdateDeviceProperties { .. } => "update_device_properties",
1962            PushSourceRequest::WatchSample { .. } => "watch_sample",
1963            PushSourceRequest::WatchStatus { .. } => "watch_status",
1964        }
1965    }
1966}
1967
1968#[derive(Debug, Clone)]
1969pub struct PushSourceControlHandle {
1970    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1971}
1972
1973impl PushSourceControlHandle {
1974    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1975        self.inner.shutdown_with_epitaph(status.into())
1976    }
1977}
1978
1979impl fidl::endpoints::ControlHandle for PushSourceControlHandle {
1980    fn shutdown(&self) {
1981        self.inner.shutdown()
1982    }
1983
1984    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1985        self.inner.shutdown_with_epitaph(status)
1986    }
1987
1988    fn is_closed(&self) -> bool {
1989        self.inner.channel().is_closed()
1990    }
1991    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1992        self.inner.channel().on_closed()
1993    }
1994
1995    #[cfg(target_os = "fuchsia")]
1996    fn signal_peer(
1997        &self,
1998        clear_mask: zx::Signals,
1999        set_mask: zx::Signals,
2000    ) -> Result<(), zx_status::Status> {
2001        use fidl::Peered;
2002        self.inner.channel().signal_peer(clear_mask, set_mask)
2003    }
2004}
2005
2006impl PushSourceControlHandle {}
2007
2008#[must_use = "FIDL methods require a response to be sent"]
2009#[derive(Debug)]
2010pub struct PushSourceWatchSampleResponder {
2011    control_handle: std::mem::ManuallyDrop<PushSourceControlHandle>,
2012    tx_id: u32,
2013}
2014
2015/// Set the the channel to be shutdown (see [`PushSourceControlHandle::shutdown`])
2016/// if the responder is dropped without sending a response, so that the client
2017/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2018impl std::ops::Drop for PushSourceWatchSampleResponder {
2019    fn drop(&mut self) {
2020        self.control_handle.shutdown();
2021        // Safety: drops once, never accessed again
2022        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2023    }
2024}
2025
2026impl fidl::endpoints::Responder for PushSourceWatchSampleResponder {
2027    type ControlHandle = PushSourceControlHandle;
2028
2029    fn control_handle(&self) -> &PushSourceControlHandle {
2030        &self.control_handle
2031    }
2032
2033    fn drop_without_shutdown(mut self) {
2034        // Safety: drops once, never accessed again due to mem::forget
2035        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2036        // Prevent Drop from running (which would shut down the channel)
2037        std::mem::forget(self);
2038    }
2039}
2040
2041impl PushSourceWatchSampleResponder {
2042    /// Sends a response to the FIDL transaction.
2043    ///
2044    /// Sets the channel to shutdown if an error occurs.
2045    pub fn send(self, mut sample: &TimeSample) -> Result<(), fidl::Error> {
2046        let _result = self.send_raw(sample);
2047        if _result.is_err() {
2048            self.control_handle.shutdown();
2049        }
2050        self.drop_without_shutdown();
2051        _result
2052    }
2053
2054    /// Similar to "send" but does not shutdown the channel if an error occurs.
2055    pub fn send_no_shutdown_on_err(self, mut sample: &TimeSample) -> Result<(), fidl::Error> {
2056        let _result = self.send_raw(sample);
2057        self.drop_without_shutdown();
2058        _result
2059    }
2060
2061    fn send_raw(&self, mut sample: &TimeSample) -> Result<(), fidl::Error> {
2062        self.control_handle.inner.send::<PushSourceWatchSampleResponse>(
2063            (sample,),
2064            self.tx_id,
2065            0x44d515a56e8304dc,
2066            fidl::encoding::DynamicFlags::empty(),
2067        )
2068    }
2069}
2070
2071#[must_use = "FIDL methods require a response to be sent"]
2072#[derive(Debug)]
2073pub struct PushSourceWatchStatusResponder {
2074    control_handle: std::mem::ManuallyDrop<PushSourceControlHandle>,
2075    tx_id: u32,
2076}
2077
2078/// Set the the channel to be shutdown (see [`PushSourceControlHandle::shutdown`])
2079/// if the responder is dropped without sending a response, so that the client
2080/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2081impl std::ops::Drop for PushSourceWatchStatusResponder {
2082    fn drop(&mut self) {
2083        self.control_handle.shutdown();
2084        // Safety: drops once, never accessed again
2085        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2086    }
2087}
2088
2089impl fidl::endpoints::Responder for PushSourceWatchStatusResponder {
2090    type ControlHandle = PushSourceControlHandle;
2091
2092    fn control_handle(&self) -> &PushSourceControlHandle {
2093        &self.control_handle
2094    }
2095
2096    fn drop_without_shutdown(mut self) {
2097        // Safety: drops once, never accessed again due to mem::forget
2098        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2099        // Prevent Drop from running (which would shut down the channel)
2100        std::mem::forget(self);
2101    }
2102}
2103
2104impl PushSourceWatchStatusResponder {
2105    /// Sends a response to the FIDL transaction.
2106    ///
2107    /// Sets the channel to shutdown if an error occurs.
2108    pub fn send(self, mut status: Status) -> Result<(), fidl::Error> {
2109        let _result = self.send_raw(status);
2110        if _result.is_err() {
2111            self.control_handle.shutdown();
2112        }
2113        self.drop_without_shutdown();
2114        _result
2115    }
2116
2117    /// Similar to "send" but does not shutdown the channel if an error occurs.
2118    pub fn send_no_shutdown_on_err(self, mut status: Status) -> Result<(), fidl::Error> {
2119        let _result = self.send_raw(status);
2120        self.drop_without_shutdown();
2121        _result
2122    }
2123
2124    fn send_raw(&self, mut status: Status) -> Result<(), fidl::Error> {
2125        self.control_handle.inner.send::<PushSourceWatchStatusResponse>(
2126            (status,),
2127            self.tx_id,
2128            0x60621a545f488bb1,
2129            fidl::encoding::DynamicFlags::empty(),
2130        )
2131    }
2132}
2133
2134#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2135pub struct TimeSourceMarker;
2136
2137impl fidl::endpoints::ProtocolMarker for TimeSourceMarker {
2138    type Proxy = TimeSourceProxy;
2139    type RequestStream = TimeSourceRequestStream;
2140    #[cfg(target_os = "fuchsia")]
2141    type SynchronousProxy = TimeSourceSynchronousProxy;
2142
2143    const DEBUG_NAME: &'static str = "(anonymous) TimeSource";
2144}
2145
2146pub trait TimeSourceProxyInterface: Send + Sync {
2147    fn r#update_device_properties(&self, properties: &Properties) -> Result<(), fidl::Error>;
2148}
2149#[derive(Debug)]
2150#[cfg(target_os = "fuchsia")]
2151pub struct TimeSourceSynchronousProxy {
2152    client: fidl::client::sync::Client,
2153}
2154
2155#[cfg(target_os = "fuchsia")]
2156impl fidl::endpoints::SynchronousProxy for TimeSourceSynchronousProxy {
2157    type Proxy = TimeSourceProxy;
2158    type Protocol = TimeSourceMarker;
2159
2160    fn from_channel(inner: fidl::Channel) -> Self {
2161        Self::new(inner)
2162    }
2163
2164    fn into_channel(self) -> fidl::Channel {
2165        self.client.into_channel()
2166    }
2167
2168    fn as_channel(&self) -> &fidl::Channel {
2169        self.client.as_channel()
2170    }
2171}
2172
2173#[cfg(target_os = "fuchsia")]
2174impl TimeSourceSynchronousProxy {
2175    pub fn new(channel: fidl::Channel) -> Self {
2176        Self { client: fidl::client::sync::Client::new(channel) }
2177    }
2178
2179    pub fn into_channel(self) -> fidl::Channel {
2180        self.client.into_channel()
2181    }
2182
2183    /// Waits until an event arrives and returns it. It is safe for other
2184    /// threads to make concurrent requests while waiting for an event.
2185    pub fn wait_for_event(
2186        &self,
2187        deadline: zx::MonotonicInstant,
2188    ) -> Result<TimeSourceEvent, fidl::Error> {
2189        TimeSourceEvent::decode(self.client.wait_for_event::<TimeSourceMarker>(deadline)?)
2190    }
2191
2192    /// Notifies the time source of changes to global properties of the device
2193    /// that it may use to increase accuracy of time measurements.
2194    pub fn r#update_device_properties(
2195        &self,
2196        mut properties: &Properties,
2197    ) -> Result<(), fidl::Error> {
2198        self.client.send::<TimeSourceUpdateDevicePropertiesRequest>(
2199            (properties,),
2200            0x63704f8bd0962f00,
2201            fidl::encoding::DynamicFlags::empty(),
2202        )
2203    }
2204}
2205
2206#[cfg(target_os = "fuchsia")]
2207impl From<TimeSourceSynchronousProxy> for zx::NullableHandle {
2208    fn from(value: TimeSourceSynchronousProxy) -> Self {
2209        value.into_channel().into()
2210    }
2211}
2212
2213#[cfg(target_os = "fuchsia")]
2214impl From<fidl::Channel> for TimeSourceSynchronousProxy {
2215    fn from(value: fidl::Channel) -> Self {
2216        Self::new(value)
2217    }
2218}
2219
2220#[cfg(target_os = "fuchsia")]
2221impl fidl::endpoints::FromClient for TimeSourceSynchronousProxy {
2222    type Protocol = TimeSourceMarker;
2223
2224    fn from_client(value: fidl::endpoints::ClientEnd<TimeSourceMarker>) -> Self {
2225        Self::new(value.into_channel())
2226    }
2227}
2228
2229#[derive(Debug, Clone)]
2230pub struct TimeSourceProxy {
2231    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2232}
2233
2234impl fidl::endpoints::Proxy for TimeSourceProxy {
2235    type Protocol = TimeSourceMarker;
2236
2237    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2238        Self::new(inner)
2239    }
2240
2241    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2242        self.client.into_channel().map_err(|client| Self { client })
2243    }
2244
2245    fn as_channel(&self) -> &::fidl::AsyncChannel {
2246        self.client.as_channel()
2247    }
2248}
2249
2250impl TimeSourceProxy {
2251    /// Create a new Proxy for fuchsia.time.external/TimeSource.
2252    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2253        let protocol_name = <TimeSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2254        Self { client: fidl::client::Client::new(channel, protocol_name) }
2255    }
2256
2257    /// Get a Stream of events from the remote end of the protocol.
2258    ///
2259    /// # Panics
2260    ///
2261    /// Panics if the event stream was already taken.
2262    pub fn take_event_stream(&self) -> TimeSourceEventStream {
2263        TimeSourceEventStream { event_receiver: self.client.take_event_receiver() }
2264    }
2265
2266    /// Notifies the time source of changes to global properties of the device
2267    /// that it may use to increase accuracy of time measurements.
2268    pub fn r#update_device_properties(
2269        &self,
2270        mut properties: &Properties,
2271    ) -> Result<(), fidl::Error> {
2272        TimeSourceProxyInterface::r#update_device_properties(self, properties)
2273    }
2274}
2275
2276impl TimeSourceProxyInterface for TimeSourceProxy {
2277    fn r#update_device_properties(&self, mut properties: &Properties) -> Result<(), fidl::Error> {
2278        self.client.send::<TimeSourceUpdateDevicePropertiesRequest>(
2279            (properties,),
2280            0x63704f8bd0962f00,
2281            fidl::encoding::DynamicFlags::empty(),
2282        )
2283    }
2284}
2285
2286pub struct TimeSourceEventStream {
2287    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2288}
2289
2290impl std::marker::Unpin for TimeSourceEventStream {}
2291
2292impl futures::stream::FusedStream for TimeSourceEventStream {
2293    fn is_terminated(&self) -> bool {
2294        self.event_receiver.is_terminated()
2295    }
2296}
2297
2298impl futures::Stream for TimeSourceEventStream {
2299    type Item = Result<TimeSourceEvent, fidl::Error>;
2300
2301    fn poll_next(
2302        mut self: std::pin::Pin<&mut Self>,
2303        cx: &mut std::task::Context<'_>,
2304    ) -> std::task::Poll<Option<Self::Item>> {
2305        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2306            &mut self.event_receiver,
2307            cx
2308        )?) {
2309            Some(buf) => std::task::Poll::Ready(Some(TimeSourceEvent::decode(buf))),
2310            None => std::task::Poll::Ready(None),
2311        }
2312    }
2313}
2314
2315#[derive(Debug)]
2316pub enum TimeSourceEvent {}
2317
2318impl TimeSourceEvent {
2319    /// Decodes a message buffer as a [`TimeSourceEvent`].
2320    fn decode(
2321        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2322    ) -> Result<TimeSourceEvent, fidl::Error> {
2323        let (bytes, _handles) = buf.split_mut();
2324        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2325        debug_assert_eq!(tx_header.tx_id, 0);
2326        match tx_header.ordinal {
2327            _ => Err(fidl::Error::UnknownOrdinal {
2328                ordinal: tx_header.ordinal,
2329                protocol_name: <TimeSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2330            }),
2331        }
2332    }
2333}
2334
2335/// A Stream of incoming requests for fuchsia.time.external/TimeSource.
2336pub struct TimeSourceRequestStream {
2337    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2338    is_terminated: bool,
2339}
2340
2341impl std::marker::Unpin for TimeSourceRequestStream {}
2342
2343impl futures::stream::FusedStream for TimeSourceRequestStream {
2344    fn is_terminated(&self) -> bool {
2345        self.is_terminated
2346    }
2347}
2348
2349impl fidl::endpoints::RequestStream for TimeSourceRequestStream {
2350    type Protocol = TimeSourceMarker;
2351    type ControlHandle = TimeSourceControlHandle;
2352
2353    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2354        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2355    }
2356
2357    fn control_handle(&self) -> Self::ControlHandle {
2358        TimeSourceControlHandle { inner: self.inner.clone() }
2359    }
2360
2361    fn into_inner(
2362        self,
2363    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2364    {
2365        (self.inner, self.is_terminated)
2366    }
2367
2368    fn from_inner(
2369        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2370        is_terminated: bool,
2371    ) -> Self {
2372        Self { inner, is_terminated }
2373    }
2374}
2375
2376impl futures::Stream for TimeSourceRequestStream {
2377    type Item = Result<TimeSourceRequest, fidl::Error>;
2378
2379    fn poll_next(
2380        mut self: std::pin::Pin<&mut Self>,
2381        cx: &mut std::task::Context<'_>,
2382    ) -> std::task::Poll<Option<Self::Item>> {
2383        let this = &mut *self;
2384        if this.inner.check_shutdown(cx) {
2385            this.is_terminated = true;
2386            return std::task::Poll::Ready(None);
2387        }
2388        if this.is_terminated {
2389            panic!("polled TimeSourceRequestStream after completion");
2390        }
2391        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2392            |bytes, handles| {
2393                match this.inner.channel().read_etc(cx, bytes, handles) {
2394                    std::task::Poll::Ready(Ok(())) => {}
2395                    std::task::Poll::Pending => return std::task::Poll::Pending,
2396                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2397                        this.is_terminated = true;
2398                        return std::task::Poll::Ready(None);
2399                    }
2400                    std::task::Poll::Ready(Err(e)) => {
2401                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2402                            e.into(),
2403                        ))));
2404                    }
2405                }
2406
2407                // A message has been received from the channel
2408                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2409
2410                std::task::Poll::Ready(Some(match header.ordinal {
2411                    0x63704f8bd0962f00 => {
2412                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2413                        let mut req = fidl::new_empty!(
2414                            TimeSourceUpdateDevicePropertiesRequest,
2415                            fidl::encoding::DefaultFuchsiaResourceDialect
2416                        );
2417                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TimeSourceUpdateDevicePropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
2418                        let control_handle = TimeSourceControlHandle { inner: this.inner.clone() };
2419                        Ok(TimeSourceRequest::UpdateDeviceProperties {
2420                            properties: req.properties,
2421
2422                            control_handle,
2423                        })
2424                    }
2425                    _ => Err(fidl::Error::UnknownOrdinal {
2426                        ordinal: header.ordinal,
2427                        protocol_name:
2428                            <TimeSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2429                    }),
2430                }))
2431            },
2432        )
2433    }
2434}
2435
2436/// A protocol which defines common methods for all time sources. Should not be
2437/// implemented directly.
2438#[derive(Debug)]
2439pub enum TimeSourceRequest {
2440    /// Notifies the time source of changes to global properties of the device
2441    /// that it may use to increase accuracy of time measurements.
2442    UpdateDeviceProperties { properties: Properties, control_handle: TimeSourceControlHandle },
2443}
2444
2445impl TimeSourceRequest {
2446    #[allow(irrefutable_let_patterns)]
2447    pub fn into_update_device_properties(self) -> Option<(Properties, TimeSourceControlHandle)> {
2448        if let TimeSourceRequest::UpdateDeviceProperties { properties, control_handle } = self {
2449            Some((properties, control_handle))
2450        } else {
2451            None
2452        }
2453    }
2454
2455    /// Name of the method defined in FIDL
2456    pub fn method_name(&self) -> &'static str {
2457        match *self {
2458            TimeSourceRequest::UpdateDeviceProperties { .. } => "update_device_properties",
2459        }
2460    }
2461}
2462
2463#[derive(Debug, Clone)]
2464pub struct TimeSourceControlHandle {
2465    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2466}
2467
2468impl TimeSourceControlHandle {
2469    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2470        self.inner.shutdown_with_epitaph(status.into())
2471    }
2472}
2473
2474impl fidl::endpoints::ControlHandle for TimeSourceControlHandle {
2475    fn shutdown(&self) {
2476        self.inner.shutdown()
2477    }
2478
2479    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2480        self.inner.shutdown_with_epitaph(status)
2481    }
2482
2483    fn is_closed(&self) -> bool {
2484        self.inner.channel().is_closed()
2485    }
2486    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2487        self.inner.channel().on_closed()
2488    }
2489
2490    #[cfg(target_os = "fuchsia")]
2491    fn signal_peer(
2492        &self,
2493        clear_mask: zx::Signals,
2494        set_mask: zx::Signals,
2495    ) -> Result<(), zx_status::Status> {
2496        use fidl::Peered;
2497        self.inner.channel().signal_peer(clear_mask, set_mask)
2498    }
2499}
2500
2501impl TimeSourceControlHandle {}
2502
2503mod internal {
2504    use super::*;
2505
2506    impl fidl::encoding::ResourceTypeMarker for PullSourceShutdownResponse {
2507        type Borrowed<'a> = &'a mut Self;
2508        fn take_or_borrow<'a>(
2509            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2510        ) -> Self::Borrowed<'a> {
2511            value
2512        }
2513    }
2514
2515    unsafe impl fidl::encoding::TypeMarker for PullSourceShutdownResponse {
2516        type Owned = Self;
2517
2518        #[inline(always)]
2519        fn inline_align(_context: fidl::encoding::Context) -> usize {
2520            4
2521        }
2522
2523        #[inline(always)]
2524        fn inline_size(_context: fidl::encoding::Context) -> usize {
2525            4
2526        }
2527    }
2528
2529    unsafe impl
2530        fidl::encoding::Encode<
2531            PullSourceShutdownResponse,
2532            fidl::encoding::DefaultFuchsiaResourceDialect,
2533        > for &mut PullSourceShutdownResponse
2534    {
2535        #[inline]
2536        unsafe fn encode(
2537            self,
2538            encoder: &mut fidl::encoding::Encoder<
2539                '_,
2540                fidl::encoding::DefaultFuchsiaResourceDialect,
2541            >,
2542            offset: usize,
2543            _depth: fidl::encoding::Depth,
2544        ) -> fidl::Result<()> {
2545            encoder.debug_check_bounds::<PullSourceShutdownResponse>(offset);
2546            // Delegate to tuple encoding.
2547            fidl::encoding::Encode::<PullSourceShutdownResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2548                (
2549                    <fidl_fuchsia_inspect::EscrowToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.escrow_token),
2550                ),
2551                encoder, offset, _depth
2552            )
2553        }
2554    }
2555    unsafe impl<
2556        T0: fidl::encoding::Encode<
2557                fidl_fuchsia_inspect::EscrowToken,
2558                fidl::encoding::DefaultFuchsiaResourceDialect,
2559            >,
2560    >
2561        fidl::encoding::Encode<
2562            PullSourceShutdownResponse,
2563            fidl::encoding::DefaultFuchsiaResourceDialect,
2564        > for (T0,)
2565    {
2566        #[inline]
2567        unsafe fn encode(
2568            self,
2569            encoder: &mut fidl::encoding::Encoder<
2570                '_,
2571                fidl::encoding::DefaultFuchsiaResourceDialect,
2572            >,
2573            offset: usize,
2574            depth: fidl::encoding::Depth,
2575        ) -> fidl::Result<()> {
2576            encoder.debug_check_bounds::<PullSourceShutdownResponse>(offset);
2577            // Zero out padding regions. There's no need to apply masks
2578            // because the unmasked parts will be overwritten by fields.
2579            // Write the fields.
2580            self.0.encode(encoder, offset + 0, depth)?;
2581            Ok(())
2582        }
2583    }
2584
2585    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2586        for PullSourceShutdownResponse
2587    {
2588        #[inline(always)]
2589        fn new_empty() -> Self {
2590            Self {
2591                escrow_token: fidl::new_empty!(
2592                    fidl_fuchsia_inspect::EscrowToken,
2593                    fidl::encoding::DefaultFuchsiaResourceDialect
2594                ),
2595            }
2596        }
2597
2598        #[inline]
2599        unsafe fn decode(
2600            &mut self,
2601            decoder: &mut fidl::encoding::Decoder<
2602                '_,
2603                fidl::encoding::DefaultFuchsiaResourceDialect,
2604            >,
2605            offset: usize,
2606            _depth: fidl::encoding::Depth,
2607        ) -> fidl::Result<()> {
2608            decoder.debug_check_bounds::<Self>(offset);
2609            // Verify that padding bytes are zero.
2610            fidl::decode!(
2611                fidl_fuchsia_inspect::EscrowToken,
2612                fidl::encoding::DefaultFuchsiaResourceDialect,
2613                &mut self.escrow_token,
2614                decoder,
2615                offset + 0,
2616                _depth
2617            )?;
2618            Ok(())
2619        }
2620    }
2621}