Skip to main content

fidl_fuchsia_intl/
fidl_fuchsia_intl.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_intl__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct PropertyProviderMarker;
16
17impl fidl::endpoints::ProtocolMarker for PropertyProviderMarker {
18    type Proxy = PropertyProviderProxy;
19    type RequestStream = PropertyProviderRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = PropertyProviderSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.intl.PropertyProvider";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for PropertyProviderMarker {}
26
27pub trait PropertyProviderProxyInterface: Send + Sync {
28    type GetProfileResponseFut: std::future::Future<Output = Result<Profile, fidl::Error>> + Send;
29    fn r#get_profile(&self) -> Self::GetProfileResponseFut;
30}
31#[derive(Debug)]
32#[cfg(target_os = "fuchsia")]
33pub struct PropertyProviderSynchronousProxy {
34    client: fidl::client::sync::Client,
35}
36
37#[cfg(target_os = "fuchsia")]
38impl fidl::endpoints::SynchronousProxy for PropertyProviderSynchronousProxy {
39    type Proxy = PropertyProviderProxy;
40    type Protocol = PropertyProviderMarker;
41
42    fn from_channel(inner: fidl::Channel) -> Self {
43        Self::new(inner)
44    }
45
46    fn into_channel(self) -> fidl::Channel {
47        self.client.into_channel()
48    }
49
50    fn as_channel(&self) -> &fidl::Channel {
51        self.client.as_channel()
52    }
53}
54
55#[cfg(target_os = "fuchsia")]
56impl PropertyProviderSynchronousProxy {
57    pub fn new(channel: fidl::Channel) -> Self {
58        Self { client: fidl::client::sync::Client::new(channel) }
59    }
60
61    pub fn into_channel(self) -> fidl::Channel {
62        self.client.into_channel()
63    }
64
65    /// Waits until an event arrives and returns it. It is safe for other
66    /// threads to make concurrent requests while waiting for an event.
67    pub fn wait_for_event(
68        &self,
69        deadline: zx::MonotonicInstant,
70    ) -> Result<PropertyProviderEvent, fidl::Error> {
71        PropertyProviderEvent::decode(
72            self.client.wait_for_event::<PropertyProviderMarker>(deadline)?,
73        )
74    }
75
76    /// Gets the user's internationalization profile.
77    pub fn r#get_profile(&self, ___deadline: zx::MonotonicInstant) -> Result<Profile, fidl::Error> {
78        let _response = self.client.send_query::<
79            fidl::encoding::EmptyPayload,
80            PropertyProviderGetProfileResponse,
81            PropertyProviderMarker,
82        >(
83            (),
84            0x10bf06e68d36d3eb,
85            fidl::encoding::DynamicFlags::empty(),
86            ___deadline,
87        )?;
88        Ok(_response.profile)
89    }
90}
91
92#[cfg(target_os = "fuchsia")]
93impl From<PropertyProviderSynchronousProxy> for zx::NullableHandle {
94    fn from(value: PropertyProviderSynchronousProxy) -> Self {
95        value.into_channel().into()
96    }
97}
98
99#[cfg(target_os = "fuchsia")]
100impl From<fidl::Channel> for PropertyProviderSynchronousProxy {
101    fn from(value: fidl::Channel) -> Self {
102        Self::new(value)
103    }
104}
105
106#[cfg(target_os = "fuchsia")]
107impl fidl::endpoints::FromClient for PropertyProviderSynchronousProxy {
108    type Protocol = PropertyProviderMarker;
109
110    fn from_client(value: fidl::endpoints::ClientEnd<PropertyProviderMarker>) -> Self {
111        Self::new(value.into_channel())
112    }
113}
114
115#[derive(Debug, Clone)]
116pub struct PropertyProviderProxy {
117    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
118}
119
120impl fidl::endpoints::Proxy for PropertyProviderProxy {
121    type Protocol = PropertyProviderMarker;
122
123    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
124        Self::new(inner)
125    }
126
127    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
128        self.client.into_channel().map_err(|client| Self { client })
129    }
130
131    fn as_channel(&self) -> &::fidl::AsyncChannel {
132        self.client.as_channel()
133    }
134}
135
136impl PropertyProviderProxy {
137    /// Create a new Proxy for fuchsia.intl/PropertyProvider.
138    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
139        let protocol_name = <PropertyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
140        Self { client: fidl::client::Client::new(channel, protocol_name) }
141    }
142
143    /// Get a Stream of events from the remote end of the protocol.
144    ///
145    /// # Panics
146    ///
147    /// Panics if the event stream was already taken.
148    pub fn take_event_stream(&self) -> PropertyProviderEventStream {
149        PropertyProviderEventStream { event_receiver: self.client.take_event_receiver() }
150    }
151
152    /// Gets the user's internationalization profile.
153    pub fn r#get_profile(
154        &self,
155    ) -> fidl::client::QueryResponseFut<Profile, fidl::encoding::DefaultFuchsiaResourceDialect>
156    {
157        PropertyProviderProxyInterface::r#get_profile(self)
158    }
159}
160
161impl PropertyProviderProxyInterface for PropertyProviderProxy {
162    type GetProfileResponseFut =
163        fidl::client::QueryResponseFut<Profile, fidl::encoding::DefaultFuchsiaResourceDialect>;
164    fn r#get_profile(&self) -> Self::GetProfileResponseFut {
165        fn _decode(
166            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
167        ) -> Result<Profile, fidl::Error> {
168            let _response = fidl::client::decode_transaction_body::<
169                PropertyProviderGetProfileResponse,
170                fidl::encoding::DefaultFuchsiaResourceDialect,
171                0x10bf06e68d36d3eb,
172            >(_buf?)?;
173            Ok(_response.profile)
174        }
175        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Profile>(
176            (),
177            0x10bf06e68d36d3eb,
178            fidl::encoding::DynamicFlags::empty(),
179            _decode,
180        )
181    }
182}
183
184pub struct PropertyProviderEventStream {
185    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
186}
187
188impl std::marker::Unpin for PropertyProviderEventStream {}
189
190impl futures::stream::FusedStream for PropertyProviderEventStream {
191    fn is_terminated(&self) -> bool {
192        self.event_receiver.is_terminated()
193    }
194}
195
196impl futures::Stream for PropertyProviderEventStream {
197    type Item = Result<PropertyProviderEvent, fidl::Error>;
198
199    fn poll_next(
200        mut self: std::pin::Pin<&mut Self>,
201        cx: &mut std::task::Context<'_>,
202    ) -> std::task::Poll<Option<Self::Item>> {
203        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
204            &mut self.event_receiver,
205            cx
206        )?) {
207            Some(buf) => std::task::Poll::Ready(Some(PropertyProviderEvent::decode(buf))),
208            None => std::task::Poll::Ready(None),
209        }
210    }
211}
212
213#[derive(Debug)]
214pub enum PropertyProviderEvent {
215    OnChange {},
216}
217
218impl PropertyProviderEvent {
219    #[allow(irrefutable_let_patterns)]
220    pub fn into_on_change(self) -> Option<()> {
221        if let PropertyProviderEvent::OnChange {} = self { Some(()) } else { None }
222    }
223
224    /// Decodes a message buffer as a [`PropertyProviderEvent`].
225    fn decode(
226        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
227    ) -> Result<PropertyProviderEvent, fidl::Error> {
228        let (bytes, _handles) = buf.split_mut();
229        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
230        debug_assert_eq!(tx_header.tx_id, 0);
231        match tx_header.ordinal {
232            0x26b9ed6e23c46991 => {
233                let mut out = fidl::new_empty!(
234                    fidl::encoding::EmptyPayload,
235                    fidl::encoding::DefaultFuchsiaResourceDialect
236                );
237                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
238                Ok((PropertyProviderEvent::OnChange {}))
239            }
240            _ => Err(fidl::Error::UnknownOrdinal {
241                ordinal: tx_header.ordinal,
242                protocol_name:
243                    <PropertyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
244            }),
245        }
246    }
247}
248
249/// A Stream of incoming requests for fuchsia.intl/PropertyProvider.
250pub struct PropertyProviderRequestStream {
251    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
252    is_terminated: bool,
253}
254
255impl std::marker::Unpin for PropertyProviderRequestStream {}
256
257impl futures::stream::FusedStream for PropertyProviderRequestStream {
258    fn is_terminated(&self) -> bool {
259        self.is_terminated
260    }
261}
262
263impl fidl::endpoints::RequestStream for PropertyProviderRequestStream {
264    type Protocol = PropertyProviderMarker;
265    type ControlHandle = PropertyProviderControlHandle;
266
267    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
268        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
269    }
270
271    fn control_handle(&self) -> Self::ControlHandle {
272        PropertyProviderControlHandle { inner: self.inner.clone() }
273    }
274
275    fn into_inner(
276        self,
277    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
278    {
279        (self.inner, self.is_terminated)
280    }
281
282    fn from_inner(
283        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
284        is_terminated: bool,
285    ) -> Self {
286        Self { inner, is_terminated }
287    }
288}
289
290impl futures::Stream for PropertyProviderRequestStream {
291    type Item = Result<PropertyProviderRequest, fidl::Error>;
292
293    fn poll_next(
294        mut self: std::pin::Pin<&mut Self>,
295        cx: &mut std::task::Context<'_>,
296    ) -> std::task::Poll<Option<Self::Item>> {
297        let this = &mut *self;
298        if this.inner.check_shutdown(cx) {
299            this.is_terminated = true;
300            return std::task::Poll::Ready(None);
301        }
302        if this.is_terminated {
303            panic!("polled PropertyProviderRequestStream after completion");
304        }
305        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
306            |bytes, handles| {
307                match this.inner.channel().read_etc(cx, bytes, handles) {
308                    std::task::Poll::Ready(Ok(())) => {}
309                    std::task::Poll::Pending => return std::task::Poll::Pending,
310                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
311                        this.is_terminated = true;
312                        return std::task::Poll::Ready(None);
313                    }
314                    std::task::Poll::Ready(Err(e)) => {
315                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
316                            e.into(),
317                        ))));
318                    }
319                }
320
321                // A message has been received from the channel
322                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
323
324                std::task::Poll::Ready(Some(match header.ordinal {
325                    0x10bf06e68d36d3eb => {
326                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
327                        let mut req = fidl::new_empty!(
328                            fidl::encoding::EmptyPayload,
329                            fidl::encoding::DefaultFuchsiaResourceDialect
330                        );
331                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
332                        let control_handle =
333                            PropertyProviderControlHandle { inner: this.inner.clone() };
334                        Ok(PropertyProviderRequest::GetProfile {
335                            responder: PropertyProviderGetProfileResponder {
336                                control_handle: std::mem::ManuallyDrop::new(control_handle),
337                                tx_id: header.tx_id,
338                            },
339                        })
340                    }
341                    _ => Err(fidl::Error::UnknownOrdinal {
342                        ordinal: header.ordinal,
343                        protocol_name:
344                            <PropertyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
345                    }),
346                }))
347            },
348        )
349    }
350}
351
352/// Provides internationalization properties.
353///
354/// Components that need to change their behavior in response to the user's internationalization
355/// profile may request an instance of this service from their namespace, if available. A component
356/// may choose to pass along the service that it received from its parent to its own children, or to
357/// override it and apply additional customizations.
358///
359/// See also `fuchsia.ui.views.View`.
360#[derive(Debug)]
361pub enum PropertyProviderRequest {
362    /// Gets the user's internationalization profile.
363    GetProfile { responder: PropertyProviderGetProfileResponder },
364}
365
366impl PropertyProviderRequest {
367    #[allow(irrefutable_let_patterns)]
368    pub fn into_get_profile(self) -> Option<(PropertyProviderGetProfileResponder)> {
369        if let PropertyProviderRequest::GetProfile { responder } = self {
370            Some((responder))
371        } else {
372            None
373        }
374    }
375
376    /// Name of the method defined in FIDL
377    pub fn method_name(&self) -> &'static str {
378        match *self {
379            PropertyProviderRequest::GetProfile { .. } => "get_profile",
380        }
381    }
382}
383
384#[derive(Debug, Clone)]
385pub struct PropertyProviderControlHandle {
386    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
387}
388
389impl fidl::endpoints::ControlHandle for PropertyProviderControlHandle {
390    fn shutdown(&self) {
391        self.inner.shutdown()
392    }
393
394    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
395        self.inner.shutdown_with_epitaph(status)
396    }
397
398    fn is_closed(&self) -> bool {
399        self.inner.channel().is_closed()
400    }
401    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
402        self.inner.channel().on_closed()
403    }
404
405    #[cfg(target_os = "fuchsia")]
406    fn signal_peer(
407        &self,
408        clear_mask: zx::Signals,
409        set_mask: zx::Signals,
410    ) -> Result<(), zx_status::Status> {
411        use fidl::Peered;
412        self.inner.channel().signal_peer(clear_mask, set_mask)
413    }
414}
415
416impl PropertyProviderControlHandle {
417    pub fn send_on_change(&self) -> Result<(), fidl::Error> {
418        self.inner.send::<fidl::encoding::EmptyPayload>(
419            (),
420            0,
421            0x26b9ed6e23c46991,
422            fidl::encoding::DynamicFlags::empty(),
423        )
424    }
425}
426
427#[must_use = "FIDL methods require a response to be sent"]
428#[derive(Debug)]
429pub struct PropertyProviderGetProfileResponder {
430    control_handle: std::mem::ManuallyDrop<PropertyProviderControlHandle>,
431    tx_id: u32,
432}
433
434/// Set the the channel to be shutdown (see [`PropertyProviderControlHandle::shutdown`])
435/// if the responder is dropped without sending a response, so that the client
436/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
437impl std::ops::Drop for PropertyProviderGetProfileResponder {
438    fn drop(&mut self) {
439        self.control_handle.shutdown();
440        // Safety: drops once, never accessed again
441        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
442    }
443}
444
445impl fidl::endpoints::Responder for PropertyProviderGetProfileResponder {
446    type ControlHandle = PropertyProviderControlHandle;
447
448    fn control_handle(&self) -> &PropertyProviderControlHandle {
449        &self.control_handle
450    }
451
452    fn drop_without_shutdown(mut self) {
453        // Safety: drops once, never accessed again due to mem::forget
454        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
455        // Prevent Drop from running (which would shut down the channel)
456        std::mem::forget(self);
457    }
458}
459
460impl PropertyProviderGetProfileResponder {
461    /// Sends a response to the FIDL transaction.
462    ///
463    /// Sets the channel to shutdown if an error occurs.
464    pub fn send(self, mut profile: &Profile) -> Result<(), fidl::Error> {
465        let _result = self.send_raw(profile);
466        if _result.is_err() {
467            self.control_handle.shutdown();
468        }
469        self.drop_without_shutdown();
470        _result
471    }
472
473    /// Similar to "send" but does not shutdown the channel if an error occurs.
474    pub fn send_no_shutdown_on_err(self, mut profile: &Profile) -> Result<(), fidl::Error> {
475        let _result = self.send_raw(profile);
476        self.drop_without_shutdown();
477        _result
478    }
479
480    fn send_raw(&self, mut profile: &Profile) -> Result<(), fidl::Error> {
481        self.control_handle.inner.send::<PropertyProviderGetProfileResponse>(
482            (profile,),
483            self.tx_id,
484            0x10bf06e68d36d3eb,
485            fidl::encoding::DynamicFlags::empty(),
486        )
487    }
488}
489
490#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
491pub struct TimeZonesMarker;
492
493impl fidl::endpoints::ProtocolMarker for TimeZonesMarker {
494    type Proxy = TimeZonesProxy;
495    type RequestStream = TimeZonesRequestStream;
496    #[cfg(target_os = "fuchsia")]
497    type SynchronousProxy = TimeZonesSynchronousProxy;
498
499    const DEBUG_NAME: &'static str = "fuchsia.intl.TimeZones";
500}
501impl fidl::endpoints::DiscoverableProtocolMarker for TimeZonesMarker {}
502pub type TimeZonesAbsoluteToCivilTimeResult = Result<CivilTime, TimeZonesError>;
503pub type TimeZonesCivilToAbsoluteTimeResult = Result<i64, TimeZonesError>;
504pub type TimeZonesGetTimeZoneInfoResult = Result<TimeZoneInfo, TimeZonesError>;
505
506pub trait TimeZonesProxyInterface: Send + Sync {
507    type AbsoluteToCivilTimeResponseFut: std::future::Future<Output = Result<TimeZonesAbsoluteToCivilTimeResult, fidl::Error>>
508        + Send;
509    fn r#absolute_to_civil_time(
510        &self,
511        time_zone_id: &TimeZoneId,
512        absolute_time: i64,
513    ) -> Self::AbsoluteToCivilTimeResponseFut;
514    type CivilToAbsoluteTimeResponseFut: std::future::Future<Output = Result<TimeZonesCivilToAbsoluteTimeResult, fidl::Error>>
515        + Send;
516    fn r#civil_to_absolute_time(
517        &self,
518        civil_time: &CivilTime,
519        options: &CivilToAbsoluteTimeOptions,
520    ) -> Self::CivilToAbsoluteTimeResponseFut;
521    type GetTimeZoneInfoResponseFut: std::future::Future<Output = Result<TimeZonesGetTimeZoneInfoResult, fidl::Error>>
522        + Send;
523    fn r#get_time_zone_info(
524        &self,
525        time_zone_id: &TimeZoneId,
526        at_time: i64,
527    ) -> Self::GetTimeZoneInfoResponseFut;
528}
529#[derive(Debug)]
530#[cfg(target_os = "fuchsia")]
531pub struct TimeZonesSynchronousProxy {
532    client: fidl::client::sync::Client,
533}
534
535#[cfg(target_os = "fuchsia")]
536impl fidl::endpoints::SynchronousProxy for TimeZonesSynchronousProxy {
537    type Proxy = TimeZonesProxy;
538    type Protocol = TimeZonesMarker;
539
540    fn from_channel(inner: fidl::Channel) -> Self {
541        Self::new(inner)
542    }
543
544    fn into_channel(self) -> fidl::Channel {
545        self.client.into_channel()
546    }
547
548    fn as_channel(&self) -> &fidl::Channel {
549        self.client.as_channel()
550    }
551}
552
553#[cfg(target_os = "fuchsia")]
554impl TimeZonesSynchronousProxy {
555    pub fn new(channel: fidl::Channel) -> Self {
556        Self { client: fidl::client::sync::Client::new(channel) }
557    }
558
559    pub fn into_channel(self) -> fidl::Channel {
560        self.client.into_channel()
561    }
562
563    /// Waits until an event arrives and returns it. It is safe for other
564    /// threads to make concurrent requests while waiting for an event.
565    pub fn wait_for_event(
566        &self,
567        deadline: zx::MonotonicInstant,
568    ) -> Result<TimeZonesEvent, fidl::Error> {
569        TimeZonesEvent::decode(self.client.wait_for_event::<TimeZonesMarker>(deadline)?)
570    }
571
572    /// Converts the given absolute time to a civil date and time in the given time zone, using the
573    /// Gregorian calendar.
574    pub fn r#absolute_to_civil_time(
575        &self,
576        mut time_zone_id: &TimeZoneId,
577        mut absolute_time: i64,
578        ___deadline: zx::MonotonicInstant,
579    ) -> Result<TimeZonesAbsoluteToCivilTimeResult, fidl::Error> {
580        let _response = self.client.send_query::<
581            TimeZonesAbsoluteToCivilTimeRequest,
582            fidl::encoding::ResultType<TimeZonesAbsoluteToCivilTimeResponse, TimeZonesError>,
583            TimeZonesMarker,
584        >(
585            (time_zone_id, absolute_time,),
586            0x25377a4d9196e205,
587            fidl::encoding::DynamicFlags::empty(),
588            ___deadline,
589        )?;
590        Ok(_response.map(|x| x.civil_time))
591    }
592
593    /// Converts the given civil date and time in the given time zone to nanoseconds since the Unix
594    /// epoch.
595    pub fn r#civil_to_absolute_time(
596        &self,
597        mut civil_time: &CivilTime,
598        mut options: &CivilToAbsoluteTimeOptions,
599        ___deadline: zx::MonotonicInstant,
600    ) -> Result<TimeZonesCivilToAbsoluteTimeResult, fidl::Error> {
601        let _response = self.client.send_query::<
602            TimeZonesCivilToAbsoluteTimeRequest,
603            fidl::encoding::ResultType<TimeZonesCivilToAbsoluteTimeResponse, TimeZonesError>,
604            TimeZonesMarker,
605        >(
606            (civil_time, options,),
607            0xc1277c7a1413aa6,
608            fidl::encoding::DynamicFlags::empty(),
609            ___deadline,
610        )?;
611        Ok(_response.map(|x| x.absolute_time))
612    }
613
614    /// Retrieves details about a time zone at a specified one.
615    pub fn r#get_time_zone_info(
616        &self,
617        mut time_zone_id: &TimeZoneId,
618        mut at_time: i64,
619        ___deadline: zx::MonotonicInstant,
620    ) -> Result<TimeZonesGetTimeZoneInfoResult, fidl::Error> {
621        let _response =
622            self.client.send_query::<TimeZonesGetTimeZoneInfoRequest, fidl::encoding::ResultType<
623                TimeZonesGetTimeZoneInfoResponse,
624                TimeZonesError,
625            >, TimeZonesMarker>(
626                (time_zone_id, at_time),
627                0x2144cbac1d76fe65,
628                fidl::encoding::DynamicFlags::empty(),
629                ___deadline,
630            )?;
631        Ok(_response.map(|x| x.time_zone_info))
632    }
633}
634
635#[cfg(target_os = "fuchsia")]
636impl From<TimeZonesSynchronousProxy> for zx::NullableHandle {
637    fn from(value: TimeZonesSynchronousProxy) -> Self {
638        value.into_channel().into()
639    }
640}
641
642#[cfg(target_os = "fuchsia")]
643impl From<fidl::Channel> for TimeZonesSynchronousProxy {
644    fn from(value: fidl::Channel) -> Self {
645        Self::new(value)
646    }
647}
648
649#[cfg(target_os = "fuchsia")]
650impl fidl::endpoints::FromClient for TimeZonesSynchronousProxy {
651    type Protocol = TimeZonesMarker;
652
653    fn from_client(value: fidl::endpoints::ClientEnd<TimeZonesMarker>) -> Self {
654        Self::new(value.into_channel())
655    }
656}
657
658#[derive(Debug, Clone)]
659pub struct TimeZonesProxy {
660    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
661}
662
663impl fidl::endpoints::Proxy for TimeZonesProxy {
664    type Protocol = TimeZonesMarker;
665
666    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
667        Self::new(inner)
668    }
669
670    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
671        self.client.into_channel().map_err(|client| Self { client })
672    }
673
674    fn as_channel(&self) -> &::fidl::AsyncChannel {
675        self.client.as_channel()
676    }
677}
678
679impl TimeZonesProxy {
680    /// Create a new Proxy for fuchsia.intl/TimeZones.
681    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
682        let protocol_name = <TimeZonesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
683        Self { client: fidl::client::Client::new(channel, protocol_name) }
684    }
685
686    /// Get a Stream of events from the remote end of the protocol.
687    ///
688    /// # Panics
689    ///
690    /// Panics if the event stream was already taken.
691    pub fn take_event_stream(&self) -> TimeZonesEventStream {
692        TimeZonesEventStream { event_receiver: self.client.take_event_receiver() }
693    }
694
695    /// Converts the given absolute time to a civil date and time in the given time zone, using the
696    /// Gregorian calendar.
697    pub fn r#absolute_to_civil_time(
698        &self,
699        mut time_zone_id: &TimeZoneId,
700        mut absolute_time: i64,
701    ) -> fidl::client::QueryResponseFut<
702        TimeZonesAbsoluteToCivilTimeResult,
703        fidl::encoding::DefaultFuchsiaResourceDialect,
704    > {
705        TimeZonesProxyInterface::r#absolute_to_civil_time(self, time_zone_id, absolute_time)
706    }
707
708    /// Converts the given civil date and time in the given time zone to nanoseconds since the Unix
709    /// epoch.
710    pub fn r#civil_to_absolute_time(
711        &self,
712        mut civil_time: &CivilTime,
713        mut options: &CivilToAbsoluteTimeOptions,
714    ) -> fidl::client::QueryResponseFut<
715        TimeZonesCivilToAbsoluteTimeResult,
716        fidl::encoding::DefaultFuchsiaResourceDialect,
717    > {
718        TimeZonesProxyInterface::r#civil_to_absolute_time(self, civil_time, options)
719    }
720
721    /// Retrieves details about a time zone at a specified one.
722    pub fn r#get_time_zone_info(
723        &self,
724        mut time_zone_id: &TimeZoneId,
725        mut at_time: i64,
726    ) -> fidl::client::QueryResponseFut<
727        TimeZonesGetTimeZoneInfoResult,
728        fidl::encoding::DefaultFuchsiaResourceDialect,
729    > {
730        TimeZonesProxyInterface::r#get_time_zone_info(self, time_zone_id, at_time)
731    }
732}
733
734impl TimeZonesProxyInterface for TimeZonesProxy {
735    type AbsoluteToCivilTimeResponseFut = fidl::client::QueryResponseFut<
736        TimeZonesAbsoluteToCivilTimeResult,
737        fidl::encoding::DefaultFuchsiaResourceDialect,
738    >;
739    fn r#absolute_to_civil_time(
740        &self,
741        mut time_zone_id: &TimeZoneId,
742        mut absolute_time: i64,
743    ) -> Self::AbsoluteToCivilTimeResponseFut {
744        fn _decode(
745            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
746        ) -> Result<TimeZonesAbsoluteToCivilTimeResult, fidl::Error> {
747            let _response = fidl::client::decode_transaction_body::<
748                fidl::encoding::ResultType<TimeZonesAbsoluteToCivilTimeResponse, TimeZonesError>,
749                fidl::encoding::DefaultFuchsiaResourceDialect,
750                0x25377a4d9196e205,
751            >(_buf?)?;
752            Ok(_response.map(|x| x.civil_time))
753        }
754        self.client.send_query_and_decode::<
755            TimeZonesAbsoluteToCivilTimeRequest,
756            TimeZonesAbsoluteToCivilTimeResult,
757        >(
758            (time_zone_id, absolute_time,),
759            0x25377a4d9196e205,
760            fidl::encoding::DynamicFlags::empty(),
761            _decode,
762        )
763    }
764
765    type CivilToAbsoluteTimeResponseFut = fidl::client::QueryResponseFut<
766        TimeZonesCivilToAbsoluteTimeResult,
767        fidl::encoding::DefaultFuchsiaResourceDialect,
768    >;
769    fn r#civil_to_absolute_time(
770        &self,
771        mut civil_time: &CivilTime,
772        mut options: &CivilToAbsoluteTimeOptions,
773    ) -> Self::CivilToAbsoluteTimeResponseFut {
774        fn _decode(
775            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
776        ) -> Result<TimeZonesCivilToAbsoluteTimeResult, fidl::Error> {
777            let _response = fidl::client::decode_transaction_body::<
778                fidl::encoding::ResultType<TimeZonesCivilToAbsoluteTimeResponse, TimeZonesError>,
779                fidl::encoding::DefaultFuchsiaResourceDialect,
780                0xc1277c7a1413aa6,
781            >(_buf?)?;
782            Ok(_response.map(|x| x.absolute_time))
783        }
784        self.client.send_query_and_decode::<
785            TimeZonesCivilToAbsoluteTimeRequest,
786            TimeZonesCivilToAbsoluteTimeResult,
787        >(
788            (civil_time, options,),
789            0xc1277c7a1413aa6,
790            fidl::encoding::DynamicFlags::empty(),
791            _decode,
792        )
793    }
794
795    type GetTimeZoneInfoResponseFut = fidl::client::QueryResponseFut<
796        TimeZonesGetTimeZoneInfoResult,
797        fidl::encoding::DefaultFuchsiaResourceDialect,
798    >;
799    fn r#get_time_zone_info(
800        &self,
801        mut time_zone_id: &TimeZoneId,
802        mut at_time: i64,
803    ) -> Self::GetTimeZoneInfoResponseFut {
804        fn _decode(
805            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
806        ) -> Result<TimeZonesGetTimeZoneInfoResult, fidl::Error> {
807            let _response = fidl::client::decode_transaction_body::<
808                fidl::encoding::ResultType<TimeZonesGetTimeZoneInfoResponse, TimeZonesError>,
809                fidl::encoding::DefaultFuchsiaResourceDialect,
810                0x2144cbac1d76fe65,
811            >(_buf?)?;
812            Ok(_response.map(|x| x.time_zone_info))
813        }
814        self.client.send_query_and_decode::<
815            TimeZonesGetTimeZoneInfoRequest,
816            TimeZonesGetTimeZoneInfoResult,
817        >(
818            (time_zone_id, at_time,),
819            0x2144cbac1d76fe65,
820            fidl::encoding::DynamicFlags::empty(),
821            _decode,
822        )
823    }
824}
825
826pub struct TimeZonesEventStream {
827    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
828}
829
830impl std::marker::Unpin for TimeZonesEventStream {}
831
832impl futures::stream::FusedStream for TimeZonesEventStream {
833    fn is_terminated(&self) -> bool {
834        self.event_receiver.is_terminated()
835    }
836}
837
838impl futures::Stream for TimeZonesEventStream {
839    type Item = Result<TimeZonesEvent, fidl::Error>;
840
841    fn poll_next(
842        mut self: std::pin::Pin<&mut Self>,
843        cx: &mut std::task::Context<'_>,
844    ) -> std::task::Poll<Option<Self::Item>> {
845        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
846            &mut self.event_receiver,
847            cx
848        )?) {
849            Some(buf) => std::task::Poll::Ready(Some(TimeZonesEvent::decode(buf))),
850            None => std::task::Poll::Ready(None),
851        }
852    }
853}
854
855#[derive(Debug)]
856pub enum TimeZonesEvent {}
857
858impl TimeZonesEvent {
859    /// Decodes a message buffer as a [`TimeZonesEvent`].
860    fn decode(
861        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
862    ) -> Result<TimeZonesEvent, fidl::Error> {
863        let (bytes, _handles) = buf.split_mut();
864        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
865        debug_assert_eq!(tx_header.tx_id, 0);
866        match tx_header.ordinal {
867            _ => Err(fidl::Error::UnknownOrdinal {
868                ordinal: tx_header.ordinal,
869                protocol_name: <TimeZonesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
870            }),
871        }
872    }
873}
874
875/// A Stream of incoming requests for fuchsia.intl/TimeZones.
876pub struct TimeZonesRequestStream {
877    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
878    is_terminated: bool,
879}
880
881impl std::marker::Unpin for TimeZonesRequestStream {}
882
883impl futures::stream::FusedStream for TimeZonesRequestStream {
884    fn is_terminated(&self) -> bool {
885        self.is_terminated
886    }
887}
888
889impl fidl::endpoints::RequestStream for TimeZonesRequestStream {
890    type Protocol = TimeZonesMarker;
891    type ControlHandle = TimeZonesControlHandle;
892
893    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
894        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
895    }
896
897    fn control_handle(&self) -> Self::ControlHandle {
898        TimeZonesControlHandle { inner: self.inner.clone() }
899    }
900
901    fn into_inner(
902        self,
903    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
904    {
905        (self.inner, self.is_terminated)
906    }
907
908    fn from_inner(
909        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
910        is_terminated: bool,
911    ) -> Self {
912        Self { inner, is_terminated }
913    }
914}
915
916impl futures::Stream for TimeZonesRequestStream {
917    type Item = Result<TimeZonesRequest, fidl::Error>;
918
919    fn poll_next(
920        mut self: std::pin::Pin<&mut Self>,
921        cx: &mut std::task::Context<'_>,
922    ) -> std::task::Poll<Option<Self::Item>> {
923        let this = &mut *self;
924        if this.inner.check_shutdown(cx) {
925            this.is_terminated = true;
926            return std::task::Poll::Ready(None);
927        }
928        if this.is_terminated {
929            panic!("polled TimeZonesRequestStream after completion");
930        }
931        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
932            |bytes, handles| {
933                match this.inner.channel().read_etc(cx, bytes, handles) {
934                    std::task::Poll::Ready(Ok(())) => {}
935                    std::task::Poll::Pending => return std::task::Poll::Pending,
936                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
937                        this.is_terminated = true;
938                        return std::task::Poll::Ready(None);
939                    }
940                    std::task::Poll::Ready(Err(e)) => {
941                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
942                            e.into(),
943                        ))));
944                    }
945                }
946
947                // A message has been received from the channel
948                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
949
950                std::task::Poll::Ready(Some(match header.ordinal {
951                    0x25377a4d9196e205 => {
952                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
953                        let mut req = fidl::new_empty!(
954                            TimeZonesAbsoluteToCivilTimeRequest,
955                            fidl::encoding::DefaultFuchsiaResourceDialect
956                        );
957                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TimeZonesAbsoluteToCivilTimeRequest>(&header, _body_bytes, handles, &mut req)?;
958                        let control_handle = TimeZonesControlHandle { inner: this.inner.clone() };
959                        Ok(TimeZonesRequest::AbsoluteToCivilTime {
960                            time_zone_id: req.time_zone_id,
961                            absolute_time: req.absolute_time,
962
963                            responder: TimeZonesAbsoluteToCivilTimeResponder {
964                                control_handle: std::mem::ManuallyDrop::new(control_handle),
965                                tx_id: header.tx_id,
966                            },
967                        })
968                    }
969                    0xc1277c7a1413aa6 => {
970                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
971                        let mut req = fidl::new_empty!(
972                            TimeZonesCivilToAbsoluteTimeRequest,
973                            fidl::encoding::DefaultFuchsiaResourceDialect
974                        );
975                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TimeZonesCivilToAbsoluteTimeRequest>(&header, _body_bytes, handles, &mut req)?;
976                        let control_handle = TimeZonesControlHandle { inner: this.inner.clone() };
977                        Ok(TimeZonesRequest::CivilToAbsoluteTime {
978                            civil_time: req.civil_time,
979                            options: req.options,
980
981                            responder: TimeZonesCivilToAbsoluteTimeResponder {
982                                control_handle: std::mem::ManuallyDrop::new(control_handle),
983                                tx_id: header.tx_id,
984                            },
985                        })
986                    }
987                    0x2144cbac1d76fe65 => {
988                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
989                        let mut req = fidl::new_empty!(
990                            TimeZonesGetTimeZoneInfoRequest,
991                            fidl::encoding::DefaultFuchsiaResourceDialect
992                        );
993                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TimeZonesGetTimeZoneInfoRequest>(&header, _body_bytes, handles, &mut req)?;
994                        let control_handle = TimeZonesControlHandle { inner: this.inner.clone() };
995                        Ok(TimeZonesRequest::GetTimeZoneInfo {
996                            time_zone_id: req.time_zone_id,
997                            at_time: req.at_time,
998
999                            responder: TimeZonesGetTimeZoneInfoResponder {
1000                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1001                                tx_id: header.tx_id,
1002                            },
1003                        })
1004                    }
1005                    _ => Err(fidl::Error::UnknownOrdinal {
1006                        ordinal: header.ordinal,
1007                        protocol_name:
1008                            <TimeZonesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1009                    }),
1010                }))
1011            },
1012        )
1013    }
1014}
1015
1016/// Provides information about time zones and offers date-time conversion methods.
1017///
1018/// TODO(https://fxbug.dev/42162409): Add time zone info methods, including offsets from UTC.
1019#[derive(Debug)]
1020pub enum TimeZonesRequest {
1021    /// Converts the given absolute time to a civil date and time in the given time zone, using the
1022    /// Gregorian calendar.
1023    AbsoluteToCivilTime {
1024        time_zone_id: TimeZoneId,
1025        absolute_time: i64,
1026        responder: TimeZonesAbsoluteToCivilTimeResponder,
1027    },
1028    /// Converts the given civil date and time in the given time zone to nanoseconds since the Unix
1029    /// epoch.
1030    CivilToAbsoluteTime {
1031        civil_time: CivilTime,
1032        options: CivilToAbsoluteTimeOptions,
1033        responder: TimeZonesCivilToAbsoluteTimeResponder,
1034    },
1035    /// Retrieves details about a time zone at a specified one.
1036    GetTimeZoneInfo {
1037        time_zone_id: TimeZoneId,
1038        at_time: i64,
1039        responder: TimeZonesGetTimeZoneInfoResponder,
1040    },
1041}
1042
1043impl TimeZonesRequest {
1044    #[allow(irrefutable_let_patterns)]
1045    pub fn into_absolute_to_civil_time(
1046        self,
1047    ) -> Option<(TimeZoneId, i64, TimeZonesAbsoluteToCivilTimeResponder)> {
1048        if let TimeZonesRequest::AbsoluteToCivilTime { time_zone_id, absolute_time, responder } =
1049            self
1050        {
1051            Some((time_zone_id, absolute_time, responder))
1052        } else {
1053            None
1054        }
1055    }
1056
1057    #[allow(irrefutable_let_patterns)]
1058    pub fn into_civil_to_absolute_time(
1059        self,
1060    ) -> Option<(CivilTime, CivilToAbsoluteTimeOptions, TimeZonesCivilToAbsoluteTimeResponder)>
1061    {
1062        if let TimeZonesRequest::CivilToAbsoluteTime { civil_time, options, responder } = self {
1063            Some((civil_time, options, responder))
1064        } else {
1065            None
1066        }
1067    }
1068
1069    #[allow(irrefutable_let_patterns)]
1070    pub fn into_get_time_zone_info(
1071        self,
1072    ) -> Option<(TimeZoneId, i64, TimeZonesGetTimeZoneInfoResponder)> {
1073        if let TimeZonesRequest::GetTimeZoneInfo { time_zone_id, at_time, responder } = self {
1074            Some((time_zone_id, at_time, responder))
1075        } else {
1076            None
1077        }
1078    }
1079
1080    /// Name of the method defined in FIDL
1081    pub fn method_name(&self) -> &'static str {
1082        match *self {
1083            TimeZonesRequest::AbsoluteToCivilTime { .. } => "absolute_to_civil_time",
1084            TimeZonesRequest::CivilToAbsoluteTime { .. } => "civil_to_absolute_time",
1085            TimeZonesRequest::GetTimeZoneInfo { .. } => "get_time_zone_info",
1086        }
1087    }
1088}
1089
1090#[derive(Debug, Clone)]
1091pub struct TimeZonesControlHandle {
1092    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1093}
1094
1095impl fidl::endpoints::ControlHandle for TimeZonesControlHandle {
1096    fn shutdown(&self) {
1097        self.inner.shutdown()
1098    }
1099
1100    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1101        self.inner.shutdown_with_epitaph(status)
1102    }
1103
1104    fn is_closed(&self) -> bool {
1105        self.inner.channel().is_closed()
1106    }
1107    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1108        self.inner.channel().on_closed()
1109    }
1110
1111    #[cfg(target_os = "fuchsia")]
1112    fn signal_peer(
1113        &self,
1114        clear_mask: zx::Signals,
1115        set_mask: zx::Signals,
1116    ) -> Result<(), zx_status::Status> {
1117        use fidl::Peered;
1118        self.inner.channel().signal_peer(clear_mask, set_mask)
1119    }
1120}
1121
1122impl TimeZonesControlHandle {}
1123
1124#[must_use = "FIDL methods require a response to be sent"]
1125#[derive(Debug)]
1126pub struct TimeZonesAbsoluteToCivilTimeResponder {
1127    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
1128    tx_id: u32,
1129}
1130
1131/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
1132/// if the responder is dropped without sending a response, so that the client
1133/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1134impl std::ops::Drop for TimeZonesAbsoluteToCivilTimeResponder {
1135    fn drop(&mut self) {
1136        self.control_handle.shutdown();
1137        // Safety: drops once, never accessed again
1138        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1139    }
1140}
1141
1142impl fidl::endpoints::Responder for TimeZonesAbsoluteToCivilTimeResponder {
1143    type ControlHandle = TimeZonesControlHandle;
1144
1145    fn control_handle(&self) -> &TimeZonesControlHandle {
1146        &self.control_handle
1147    }
1148
1149    fn drop_without_shutdown(mut self) {
1150        // Safety: drops once, never accessed again due to mem::forget
1151        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1152        // Prevent Drop from running (which would shut down the channel)
1153        std::mem::forget(self);
1154    }
1155}
1156
1157impl TimeZonesAbsoluteToCivilTimeResponder {
1158    /// Sends a response to the FIDL transaction.
1159    ///
1160    /// Sets the channel to shutdown if an error occurs.
1161    pub fn send(self, mut result: Result<&CivilTime, TimeZonesError>) -> Result<(), fidl::Error> {
1162        let _result = self.send_raw(result);
1163        if _result.is_err() {
1164            self.control_handle.shutdown();
1165        }
1166        self.drop_without_shutdown();
1167        _result
1168    }
1169
1170    /// Similar to "send" but does not shutdown the channel if an error occurs.
1171    pub fn send_no_shutdown_on_err(
1172        self,
1173        mut result: Result<&CivilTime, TimeZonesError>,
1174    ) -> Result<(), fidl::Error> {
1175        let _result = self.send_raw(result);
1176        self.drop_without_shutdown();
1177        _result
1178    }
1179
1180    fn send_raw(&self, mut result: Result<&CivilTime, TimeZonesError>) -> Result<(), fidl::Error> {
1181        self.control_handle.inner.send::<fidl::encoding::ResultType<
1182            TimeZonesAbsoluteToCivilTimeResponse,
1183            TimeZonesError,
1184        >>(
1185            result.map(|civil_time| (civil_time,)),
1186            self.tx_id,
1187            0x25377a4d9196e205,
1188            fidl::encoding::DynamicFlags::empty(),
1189        )
1190    }
1191}
1192
1193#[must_use = "FIDL methods require a response to be sent"]
1194#[derive(Debug)]
1195pub struct TimeZonesCivilToAbsoluteTimeResponder {
1196    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
1197    tx_id: u32,
1198}
1199
1200/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
1201/// if the responder is dropped without sending a response, so that the client
1202/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1203impl std::ops::Drop for TimeZonesCivilToAbsoluteTimeResponder {
1204    fn drop(&mut self) {
1205        self.control_handle.shutdown();
1206        // Safety: drops once, never accessed again
1207        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1208    }
1209}
1210
1211impl fidl::endpoints::Responder for TimeZonesCivilToAbsoluteTimeResponder {
1212    type ControlHandle = TimeZonesControlHandle;
1213
1214    fn control_handle(&self) -> &TimeZonesControlHandle {
1215        &self.control_handle
1216    }
1217
1218    fn drop_without_shutdown(mut self) {
1219        // Safety: drops once, never accessed again due to mem::forget
1220        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1221        // Prevent Drop from running (which would shut down the channel)
1222        std::mem::forget(self);
1223    }
1224}
1225
1226impl TimeZonesCivilToAbsoluteTimeResponder {
1227    /// Sends a response to the FIDL transaction.
1228    ///
1229    /// Sets the channel to shutdown if an error occurs.
1230    pub fn send(self, mut result: Result<i64, TimeZonesError>) -> Result<(), fidl::Error> {
1231        let _result = self.send_raw(result);
1232        if _result.is_err() {
1233            self.control_handle.shutdown();
1234        }
1235        self.drop_without_shutdown();
1236        _result
1237    }
1238
1239    /// Similar to "send" but does not shutdown the channel if an error occurs.
1240    pub fn send_no_shutdown_on_err(
1241        self,
1242        mut result: Result<i64, TimeZonesError>,
1243    ) -> Result<(), fidl::Error> {
1244        let _result = self.send_raw(result);
1245        self.drop_without_shutdown();
1246        _result
1247    }
1248
1249    fn send_raw(&self, mut result: Result<i64, TimeZonesError>) -> Result<(), fidl::Error> {
1250        self.control_handle.inner.send::<fidl::encoding::ResultType<
1251            TimeZonesCivilToAbsoluteTimeResponse,
1252            TimeZonesError,
1253        >>(
1254            result.map(|absolute_time| (absolute_time,)),
1255            self.tx_id,
1256            0xc1277c7a1413aa6,
1257            fidl::encoding::DynamicFlags::empty(),
1258        )
1259    }
1260}
1261
1262#[must_use = "FIDL methods require a response to be sent"]
1263#[derive(Debug)]
1264pub struct TimeZonesGetTimeZoneInfoResponder {
1265    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
1266    tx_id: u32,
1267}
1268
1269/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
1270/// if the responder is dropped without sending a response, so that the client
1271/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1272impl std::ops::Drop for TimeZonesGetTimeZoneInfoResponder {
1273    fn drop(&mut self) {
1274        self.control_handle.shutdown();
1275        // Safety: drops once, never accessed again
1276        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1277    }
1278}
1279
1280impl fidl::endpoints::Responder for TimeZonesGetTimeZoneInfoResponder {
1281    type ControlHandle = TimeZonesControlHandle;
1282
1283    fn control_handle(&self) -> &TimeZonesControlHandle {
1284        &self.control_handle
1285    }
1286
1287    fn drop_without_shutdown(mut self) {
1288        // Safety: drops once, never accessed again due to mem::forget
1289        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1290        // Prevent Drop from running (which would shut down the channel)
1291        std::mem::forget(self);
1292    }
1293}
1294
1295impl TimeZonesGetTimeZoneInfoResponder {
1296    /// Sends a response to the FIDL transaction.
1297    ///
1298    /// Sets the channel to shutdown if an error occurs.
1299    pub fn send(
1300        self,
1301        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1302    ) -> Result<(), fidl::Error> {
1303        let _result = self.send_raw(result);
1304        if _result.is_err() {
1305            self.control_handle.shutdown();
1306        }
1307        self.drop_without_shutdown();
1308        _result
1309    }
1310
1311    /// Similar to "send" but does not shutdown the channel if an error occurs.
1312    pub fn send_no_shutdown_on_err(
1313        self,
1314        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1315    ) -> Result<(), fidl::Error> {
1316        let _result = self.send_raw(result);
1317        self.drop_without_shutdown();
1318        _result
1319    }
1320
1321    fn send_raw(
1322        &self,
1323        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1324    ) -> Result<(), fidl::Error> {
1325        self.control_handle.inner.send::<fidl::encoding::ResultType<
1326            TimeZonesGetTimeZoneInfoResponse,
1327            TimeZonesError,
1328        >>(
1329            result.map(|time_zone_info| (time_zone_info,)),
1330            self.tx_id,
1331            0x2144cbac1d76fe65,
1332            fidl::encoding::DynamicFlags::empty(),
1333        )
1334    }
1335}
1336
1337mod internal {
1338    use super::*;
1339}