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 PropertyProviderControlHandle {
390    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
391        self.inner.shutdown_with_epitaph(status.into())
392    }
393}
394
395impl fidl::endpoints::ControlHandle for PropertyProviderControlHandle {
396    fn shutdown(&self) {
397        self.inner.shutdown()
398    }
399
400    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
401        self.inner.shutdown_with_epitaph(status)
402    }
403
404    fn is_closed(&self) -> bool {
405        self.inner.channel().is_closed()
406    }
407    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
408        self.inner.channel().on_closed()
409    }
410
411    #[cfg(target_os = "fuchsia")]
412    fn signal_peer(
413        &self,
414        clear_mask: zx::Signals,
415        set_mask: zx::Signals,
416    ) -> Result<(), zx_status::Status> {
417        use fidl::Peered;
418        self.inner.channel().signal_peer(clear_mask, set_mask)
419    }
420}
421
422impl PropertyProviderControlHandle {
423    pub fn send_on_change(&self) -> Result<(), fidl::Error> {
424        self.inner.send::<fidl::encoding::EmptyPayload>(
425            (),
426            0,
427            0x26b9ed6e23c46991,
428            fidl::encoding::DynamicFlags::empty(),
429        )
430    }
431}
432
433#[must_use = "FIDL methods require a response to be sent"]
434#[derive(Debug)]
435pub struct PropertyProviderGetProfileResponder {
436    control_handle: std::mem::ManuallyDrop<PropertyProviderControlHandle>,
437    tx_id: u32,
438}
439
440/// Set the the channel to be shutdown (see [`PropertyProviderControlHandle::shutdown`])
441/// if the responder is dropped without sending a response, so that the client
442/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
443impl std::ops::Drop for PropertyProviderGetProfileResponder {
444    fn drop(&mut self) {
445        self.control_handle.shutdown();
446        // Safety: drops once, never accessed again
447        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
448    }
449}
450
451impl fidl::endpoints::Responder for PropertyProviderGetProfileResponder {
452    type ControlHandle = PropertyProviderControlHandle;
453
454    fn control_handle(&self) -> &PropertyProviderControlHandle {
455        &self.control_handle
456    }
457
458    fn drop_without_shutdown(mut self) {
459        // Safety: drops once, never accessed again due to mem::forget
460        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
461        // Prevent Drop from running (which would shut down the channel)
462        std::mem::forget(self);
463    }
464}
465
466impl PropertyProviderGetProfileResponder {
467    /// Sends a response to the FIDL transaction.
468    ///
469    /// Sets the channel to shutdown if an error occurs.
470    pub fn send(self, mut profile: &Profile) -> Result<(), fidl::Error> {
471        let _result = self.send_raw(profile);
472        if _result.is_err() {
473            self.control_handle.shutdown();
474        }
475        self.drop_without_shutdown();
476        _result
477    }
478
479    /// Similar to "send" but does not shutdown the channel if an error occurs.
480    pub fn send_no_shutdown_on_err(self, mut profile: &Profile) -> Result<(), fidl::Error> {
481        let _result = self.send_raw(profile);
482        self.drop_without_shutdown();
483        _result
484    }
485
486    fn send_raw(&self, mut profile: &Profile) -> Result<(), fidl::Error> {
487        self.control_handle.inner.send::<PropertyProviderGetProfileResponse>(
488            (profile,),
489            self.tx_id,
490            0x10bf06e68d36d3eb,
491            fidl::encoding::DynamicFlags::empty(),
492        )
493    }
494}
495
496#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
497pub struct TimeZonesMarker;
498
499impl fidl::endpoints::ProtocolMarker for TimeZonesMarker {
500    type Proxy = TimeZonesProxy;
501    type RequestStream = TimeZonesRequestStream;
502    #[cfg(target_os = "fuchsia")]
503    type SynchronousProxy = TimeZonesSynchronousProxy;
504
505    const DEBUG_NAME: &'static str = "fuchsia.intl.TimeZones";
506}
507impl fidl::endpoints::DiscoverableProtocolMarker for TimeZonesMarker {}
508pub type TimeZonesAbsoluteToCivilTimeResult = Result<CivilTime, TimeZonesError>;
509pub type TimeZonesCivilToAbsoluteTimeResult = Result<i64, TimeZonesError>;
510pub type TimeZonesGetTimeZoneInfoResult = Result<TimeZoneInfo, TimeZonesError>;
511
512pub trait TimeZonesProxyInterface: Send + Sync {
513    type AbsoluteToCivilTimeResponseFut: std::future::Future<Output = Result<TimeZonesAbsoluteToCivilTimeResult, fidl::Error>>
514        + Send;
515    fn r#absolute_to_civil_time(
516        &self,
517        time_zone_id: &TimeZoneId,
518        absolute_time: i64,
519    ) -> Self::AbsoluteToCivilTimeResponseFut;
520    type CivilToAbsoluteTimeResponseFut: std::future::Future<Output = Result<TimeZonesCivilToAbsoluteTimeResult, fidl::Error>>
521        + Send;
522    fn r#civil_to_absolute_time(
523        &self,
524        civil_time: &CivilTime,
525        options: &CivilToAbsoluteTimeOptions,
526    ) -> Self::CivilToAbsoluteTimeResponseFut;
527    type GetTimeZoneInfoResponseFut: std::future::Future<Output = Result<TimeZonesGetTimeZoneInfoResult, fidl::Error>>
528        + Send;
529    fn r#get_time_zone_info(
530        &self,
531        time_zone_id: &TimeZoneId,
532        at_time: i64,
533    ) -> Self::GetTimeZoneInfoResponseFut;
534}
535#[derive(Debug)]
536#[cfg(target_os = "fuchsia")]
537pub struct TimeZonesSynchronousProxy {
538    client: fidl::client::sync::Client,
539}
540
541#[cfg(target_os = "fuchsia")]
542impl fidl::endpoints::SynchronousProxy for TimeZonesSynchronousProxy {
543    type Proxy = TimeZonesProxy;
544    type Protocol = TimeZonesMarker;
545
546    fn from_channel(inner: fidl::Channel) -> Self {
547        Self::new(inner)
548    }
549
550    fn into_channel(self) -> fidl::Channel {
551        self.client.into_channel()
552    }
553
554    fn as_channel(&self) -> &fidl::Channel {
555        self.client.as_channel()
556    }
557}
558
559#[cfg(target_os = "fuchsia")]
560impl TimeZonesSynchronousProxy {
561    pub fn new(channel: fidl::Channel) -> Self {
562        Self { client: fidl::client::sync::Client::new(channel) }
563    }
564
565    pub fn into_channel(self) -> fidl::Channel {
566        self.client.into_channel()
567    }
568
569    /// Waits until an event arrives and returns it. It is safe for other
570    /// threads to make concurrent requests while waiting for an event.
571    pub fn wait_for_event(
572        &self,
573        deadline: zx::MonotonicInstant,
574    ) -> Result<TimeZonesEvent, fidl::Error> {
575        TimeZonesEvent::decode(self.client.wait_for_event::<TimeZonesMarker>(deadline)?)
576    }
577
578    /// Converts the given absolute time to a civil date and time in the given time zone, using the
579    /// Gregorian calendar.
580    pub fn r#absolute_to_civil_time(
581        &self,
582        mut time_zone_id: &TimeZoneId,
583        mut absolute_time: i64,
584        ___deadline: zx::MonotonicInstant,
585    ) -> Result<TimeZonesAbsoluteToCivilTimeResult, fidl::Error> {
586        let _response = self.client.send_query::<
587            TimeZonesAbsoluteToCivilTimeRequest,
588            fidl::encoding::ResultType<TimeZonesAbsoluteToCivilTimeResponse, TimeZonesError>,
589            TimeZonesMarker,
590        >(
591            (time_zone_id, absolute_time,),
592            0x25377a4d9196e205,
593            fidl::encoding::DynamicFlags::empty(),
594            ___deadline,
595        )?;
596        Ok(_response.map(|x| x.civil_time))
597    }
598
599    /// Converts the given civil date and time in the given time zone to nanoseconds since the Unix
600    /// epoch.
601    pub fn r#civil_to_absolute_time(
602        &self,
603        mut civil_time: &CivilTime,
604        mut options: &CivilToAbsoluteTimeOptions,
605        ___deadline: zx::MonotonicInstant,
606    ) -> Result<TimeZonesCivilToAbsoluteTimeResult, fidl::Error> {
607        let _response = self.client.send_query::<
608            TimeZonesCivilToAbsoluteTimeRequest,
609            fidl::encoding::ResultType<TimeZonesCivilToAbsoluteTimeResponse, TimeZonesError>,
610            TimeZonesMarker,
611        >(
612            (civil_time, options,),
613            0xc1277c7a1413aa6,
614            fidl::encoding::DynamicFlags::empty(),
615            ___deadline,
616        )?;
617        Ok(_response.map(|x| x.absolute_time))
618    }
619
620    /// Retrieves details about a time zone at a specified one.
621    pub fn r#get_time_zone_info(
622        &self,
623        mut time_zone_id: &TimeZoneId,
624        mut at_time: i64,
625        ___deadline: zx::MonotonicInstant,
626    ) -> Result<TimeZonesGetTimeZoneInfoResult, fidl::Error> {
627        let _response =
628            self.client.send_query::<TimeZonesGetTimeZoneInfoRequest, fidl::encoding::ResultType<
629                TimeZonesGetTimeZoneInfoResponse,
630                TimeZonesError,
631            >, TimeZonesMarker>(
632                (time_zone_id, at_time),
633                0x2144cbac1d76fe65,
634                fidl::encoding::DynamicFlags::empty(),
635                ___deadline,
636            )?;
637        Ok(_response.map(|x| x.time_zone_info))
638    }
639}
640
641#[cfg(target_os = "fuchsia")]
642impl From<TimeZonesSynchronousProxy> for zx::NullableHandle {
643    fn from(value: TimeZonesSynchronousProxy) -> Self {
644        value.into_channel().into()
645    }
646}
647
648#[cfg(target_os = "fuchsia")]
649impl From<fidl::Channel> for TimeZonesSynchronousProxy {
650    fn from(value: fidl::Channel) -> Self {
651        Self::new(value)
652    }
653}
654
655#[cfg(target_os = "fuchsia")]
656impl fidl::endpoints::FromClient for TimeZonesSynchronousProxy {
657    type Protocol = TimeZonesMarker;
658
659    fn from_client(value: fidl::endpoints::ClientEnd<TimeZonesMarker>) -> Self {
660        Self::new(value.into_channel())
661    }
662}
663
664#[derive(Debug, Clone)]
665pub struct TimeZonesProxy {
666    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
667}
668
669impl fidl::endpoints::Proxy for TimeZonesProxy {
670    type Protocol = TimeZonesMarker;
671
672    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
673        Self::new(inner)
674    }
675
676    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
677        self.client.into_channel().map_err(|client| Self { client })
678    }
679
680    fn as_channel(&self) -> &::fidl::AsyncChannel {
681        self.client.as_channel()
682    }
683}
684
685impl TimeZonesProxy {
686    /// Create a new Proxy for fuchsia.intl/TimeZones.
687    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
688        let protocol_name = <TimeZonesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
689        Self { client: fidl::client::Client::new(channel, protocol_name) }
690    }
691
692    /// Get a Stream of events from the remote end of the protocol.
693    ///
694    /// # Panics
695    ///
696    /// Panics if the event stream was already taken.
697    pub fn take_event_stream(&self) -> TimeZonesEventStream {
698        TimeZonesEventStream { event_receiver: self.client.take_event_receiver() }
699    }
700
701    /// Converts the given absolute time to a civil date and time in the given time zone, using the
702    /// Gregorian calendar.
703    pub fn r#absolute_to_civil_time(
704        &self,
705        mut time_zone_id: &TimeZoneId,
706        mut absolute_time: i64,
707    ) -> fidl::client::QueryResponseFut<
708        TimeZonesAbsoluteToCivilTimeResult,
709        fidl::encoding::DefaultFuchsiaResourceDialect,
710    > {
711        TimeZonesProxyInterface::r#absolute_to_civil_time(self, time_zone_id, absolute_time)
712    }
713
714    /// Converts the given civil date and time in the given time zone to nanoseconds since the Unix
715    /// epoch.
716    pub fn r#civil_to_absolute_time(
717        &self,
718        mut civil_time: &CivilTime,
719        mut options: &CivilToAbsoluteTimeOptions,
720    ) -> fidl::client::QueryResponseFut<
721        TimeZonesCivilToAbsoluteTimeResult,
722        fidl::encoding::DefaultFuchsiaResourceDialect,
723    > {
724        TimeZonesProxyInterface::r#civil_to_absolute_time(self, civil_time, options)
725    }
726
727    /// Retrieves details about a time zone at a specified one.
728    pub fn r#get_time_zone_info(
729        &self,
730        mut time_zone_id: &TimeZoneId,
731        mut at_time: i64,
732    ) -> fidl::client::QueryResponseFut<
733        TimeZonesGetTimeZoneInfoResult,
734        fidl::encoding::DefaultFuchsiaResourceDialect,
735    > {
736        TimeZonesProxyInterface::r#get_time_zone_info(self, time_zone_id, at_time)
737    }
738}
739
740impl TimeZonesProxyInterface for TimeZonesProxy {
741    type AbsoluteToCivilTimeResponseFut = fidl::client::QueryResponseFut<
742        TimeZonesAbsoluteToCivilTimeResult,
743        fidl::encoding::DefaultFuchsiaResourceDialect,
744    >;
745    fn r#absolute_to_civil_time(
746        &self,
747        mut time_zone_id: &TimeZoneId,
748        mut absolute_time: i64,
749    ) -> Self::AbsoluteToCivilTimeResponseFut {
750        fn _decode(
751            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
752        ) -> Result<TimeZonesAbsoluteToCivilTimeResult, fidl::Error> {
753            let _response = fidl::client::decode_transaction_body::<
754                fidl::encoding::ResultType<TimeZonesAbsoluteToCivilTimeResponse, TimeZonesError>,
755                fidl::encoding::DefaultFuchsiaResourceDialect,
756                0x25377a4d9196e205,
757            >(_buf?)?;
758            Ok(_response.map(|x| x.civil_time))
759        }
760        self.client.send_query_and_decode::<
761            TimeZonesAbsoluteToCivilTimeRequest,
762            TimeZonesAbsoluteToCivilTimeResult,
763        >(
764            (time_zone_id, absolute_time,),
765            0x25377a4d9196e205,
766            fidl::encoding::DynamicFlags::empty(),
767            _decode,
768        )
769    }
770
771    type CivilToAbsoluteTimeResponseFut = fidl::client::QueryResponseFut<
772        TimeZonesCivilToAbsoluteTimeResult,
773        fidl::encoding::DefaultFuchsiaResourceDialect,
774    >;
775    fn r#civil_to_absolute_time(
776        &self,
777        mut civil_time: &CivilTime,
778        mut options: &CivilToAbsoluteTimeOptions,
779    ) -> Self::CivilToAbsoluteTimeResponseFut {
780        fn _decode(
781            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
782        ) -> Result<TimeZonesCivilToAbsoluteTimeResult, fidl::Error> {
783            let _response = fidl::client::decode_transaction_body::<
784                fidl::encoding::ResultType<TimeZonesCivilToAbsoluteTimeResponse, TimeZonesError>,
785                fidl::encoding::DefaultFuchsiaResourceDialect,
786                0xc1277c7a1413aa6,
787            >(_buf?)?;
788            Ok(_response.map(|x| x.absolute_time))
789        }
790        self.client.send_query_and_decode::<
791            TimeZonesCivilToAbsoluteTimeRequest,
792            TimeZonesCivilToAbsoluteTimeResult,
793        >(
794            (civil_time, options,),
795            0xc1277c7a1413aa6,
796            fidl::encoding::DynamicFlags::empty(),
797            _decode,
798        )
799    }
800
801    type GetTimeZoneInfoResponseFut = fidl::client::QueryResponseFut<
802        TimeZonesGetTimeZoneInfoResult,
803        fidl::encoding::DefaultFuchsiaResourceDialect,
804    >;
805    fn r#get_time_zone_info(
806        &self,
807        mut time_zone_id: &TimeZoneId,
808        mut at_time: i64,
809    ) -> Self::GetTimeZoneInfoResponseFut {
810        fn _decode(
811            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
812        ) -> Result<TimeZonesGetTimeZoneInfoResult, fidl::Error> {
813            let _response = fidl::client::decode_transaction_body::<
814                fidl::encoding::ResultType<TimeZonesGetTimeZoneInfoResponse, TimeZonesError>,
815                fidl::encoding::DefaultFuchsiaResourceDialect,
816                0x2144cbac1d76fe65,
817            >(_buf?)?;
818            Ok(_response.map(|x| x.time_zone_info))
819        }
820        self.client.send_query_and_decode::<
821            TimeZonesGetTimeZoneInfoRequest,
822            TimeZonesGetTimeZoneInfoResult,
823        >(
824            (time_zone_id, at_time,),
825            0x2144cbac1d76fe65,
826            fidl::encoding::DynamicFlags::empty(),
827            _decode,
828        )
829    }
830}
831
832pub struct TimeZonesEventStream {
833    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
834}
835
836impl std::marker::Unpin for TimeZonesEventStream {}
837
838impl futures::stream::FusedStream for TimeZonesEventStream {
839    fn is_terminated(&self) -> bool {
840        self.event_receiver.is_terminated()
841    }
842}
843
844impl futures::Stream for TimeZonesEventStream {
845    type Item = Result<TimeZonesEvent, fidl::Error>;
846
847    fn poll_next(
848        mut self: std::pin::Pin<&mut Self>,
849        cx: &mut std::task::Context<'_>,
850    ) -> std::task::Poll<Option<Self::Item>> {
851        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
852            &mut self.event_receiver,
853            cx
854        )?) {
855            Some(buf) => std::task::Poll::Ready(Some(TimeZonesEvent::decode(buf))),
856            None => std::task::Poll::Ready(None),
857        }
858    }
859}
860
861#[derive(Debug)]
862pub enum TimeZonesEvent {}
863
864impl TimeZonesEvent {
865    /// Decodes a message buffer as a [`TimeZonesEvent`].
866    fn decode(
867        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
868    ) -> Result<TimeZonesEvent, fidl::Error> {
869        let (bytes, _handles) = buf.split_mut();
870        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
871        debug_assert_eq!(tx_header.tx_id, 0);
872        match tx_header.ordinal {
873            _ => Err(fidl::Error::UnknownOrdinal {
874                ordinal: tx_header.ordinal,
875                protocol_name: <TimeZonesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
876            }),
877        }
878    }
879}
880
881/// A Stream of incoming requests for fuchsia.intl/TimeZones.
882pub struct TimeZonesRequestStream {
883    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
884    is_terminated: bool,
885}
886
887impl std::marker::Unpin for TimeZonesRequestStream {}
888
889impl futures::stream::FusedStream for TimeZonesRequestStream {
890    fn is_terminated(&self) -> bool {
891        self.is_terminated
892    }
893}
894
895impl fidl::endpoints::RequestStream for TimeZonesRequestStream {
896    type Protocol = TimeZonesMarker;
897    type ControlHandle = TimeZonesControlHandle;
898
899    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
900        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
901    }
902
903    fn control_handle(&self) -> Self::ControlHandle {
904        TimeZonesControlHandle { inner: self.inner.clone() }
905    }
906
907    fn into_inner(
908        self,
909    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
910    {
911        (self.inner, self.is_terminated)
912    }
913
914    fn from_inner(
915        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
916        is_terminated: bool,
917    ) -> Self {
918        Self { inner, is_terminated }
919    }
920}
921
922impl futures::Stream for TimeZonesRequestStream {
923    type Item = Result<TimeZonesRequest, fidl::Error>;
924
925    fn poll_next(
926        mut self: std::pin::Pin<&mut Self>,
927        cx: &mut std::task::Context<'_>,
928    ) -> std::task::Poll<Option<Self::Item>> {
929        let this = &mut *self;
930        if this.inner.check_shutdown(cx) {
931            this.is_terminated = true;
932            return std::task::Poll::Ready(None);
933        }
934        if this.is_terminated {
935            panic!("polled TimeZonesRequestStream after completion");
936        }
937        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
938            |bytes, handles| {
939                match this.inner.channel().read_etc(cx, bytes, handles) {
940                    std::task::Poll::Ready(Ok(())) => {}
941                    std::task::Poll::Pending => return std::task::Poll::Pending,
942                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
943                        this.is_terminated = true;
944                        return std::task::Poll::Ready(None);
945                    }
946                    std::task::Poll::Ready(Err(e)) => {
947                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
948                            e.into(),
949                        ))));
950                    }
951                }
952
953                // A message has been received from the channel
954                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
955
956                std::task::Poll::Ready(Some(match header.ordinal {
957                    0x25377a4d9196e205 => {
958                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
959                        let mut req = fidl::new_empty!(
960                            TimeZonesAbsoluteToCivilTimeRequest,
961                            fidl::encoding::DefaultFuchsiaResourceDialect
962                        );
963                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TimeZonesAbsoluteToCivilTimeRequest>(&header, _body_bytes, handles, &mut req)?;
964                        let control_handle = TimeZonesControlHandle { inner: this.inner.clone() };
965                        Ok(TimeZonesRequest::AbsoluteToCivilTime {
966                            time_zone_id: req.time_zone_id,
967                            absolute_time: req.absolute_time,
968
969                            responder: TimeZonesAbsoluteToCivilTimeResponder {
970                                control_handle: std::mem::ManuallyDrop::new(control_handle),
971                                tx_id: header.tx_id,
972                            },
973                        })
974                    }
975                    0xc1277c7a1413aa6 => {
976                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
977                        let mut req = fidl::new_empty!(
978                            TimeZonesCivilToAbsoluteTimeRequest,
979                            fidl::encoding::DefaultFuchsiaResourceDialect
980                        );
981                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TimeZonesCivilToAbsoluteTimeRequest>(&header, _body_bytes, handles, &mut req)?;
982                        let control_handle = TimeZonesControlHandle { inner: this.inner.clone() };
983                        Ok(TimeZonesRequest::CivilToAbsoluteTime {
984                            civil_time: req.civil_time,
985                            options: req.options,
986
987                            responder: TimeZonesCivilToAbsoluteTimeResponder {
988                                control_handle: std::mem::ManuallyDrop::new(control_handle),
989                                tx_id: header.tx_id,
990                            },
991                        })
992                    }
993                    0x2144cbac1d76fe65 => {
994                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
995                        let mut req = fidl::new_empty!(
996                            TimeZonesGetTimeZoneInfoRequest,
997                            fidl::encoding::DefaultFuchsiaResourceDialect
998                        );
999                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TimeZonesGetTimeZoneInfoRequest>(&header, _body_bytes, handles, &mut req)?;
1000                        let control_handle = TimeZonesControlHandle { inner: this.inner.clone() };
1001                        Ok(TimeZonesRequest::GetTimeZoneInfo {
1002                            time_zone_id: req.time_zone_id,
1003                            at_time: req.at_time,
1004
1005                            responder: TimeZonesGetTimeZoneInfoResponder {
1006                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1007                                tx_id: header.tx_id,
1008                            },
1009                        })
1010                    }
1011                    _ => Err(fidl::Error::UnknownOrdinal {
1012                        ordinal: header.ordinal,
1013                        protocol_name:
1014                            <TimeZonesMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1015                    }),
1016                }))
1017            },
1018        )
1019    }
1020}
1021
1022/// Provides information about time zones and offers date-time conversion methods.
1023///
1024/// TODO(https://fxbug.dev/42162409): Add time zone info methods, including offsets from UTC.
1025#[derive(Debug)]
1026pub enum TimeZonesRequest {
1027    /// Converts the given absolute time to a civil date and time in the given time zone, using the
1028    /// Gregorian calendar.
1029    AbsoluteToCivilTime {
1030        time_zone_id: TimeZoneId,
1031        absolute_time: i64,
1032        responder: TimeZonesAbsoluteToCivilTimeResponder,
1033    },
1034    /// Converts the given civil date and time in the given time zone to nanoseconds since the Unix
1035    /// epoch.
1036    CivilToAbsoluteTime {
1037        civil_time: CivilTime,
1038        options: CivilToAbsoluteTimeOptions,
1039        responder: TimeZonesCivilToAbsoluteTimeResponder,
1040    },
1041    /// Retrieves details about a time zone at a specified one.
1042    GetTimeZoneInfo {
1043        time_zone_id: TimeZoneId,
1044        at_time: i64,
1045        responder: TimeZonesGetTimeZoneInfoResponder,
1046    },
1047}
1048
1049impl TimeZonesRequest {
1050    #[allow(irrefutable_let_patterns)]
1051    pub fn into_absolute_to_civil_time(
1052        self,
1053    ) -> Option<(TimeZoneId, i64, TimeZonesAbsoluteToCivilTimeResponder)> {
1054        if let TimeZonesRequest::AbsoluteToCivilTime { time_zone_id, absolute_time, responder } =
1055            self
1056        {
1057            Some((time_zone_id, absolute_time, responder))
1058        } else {
1059            None
1060        }
1061    }
1062
1063    #[allow(irrefutable_let_patterns)]
1064    pub fn into_civil_to_absolute_time(
1065        self,
1066    ) -> Option<(CivilTime, CivilToAbsoluteTimeOptions, TimeZonesCivilToAbsoluteTimeResponder)>
1067    {
1068        if let TimeZonesRequest::CivilToAbsoluteTime { civil_time, options, responder } = self {
1069            Some((civil_time, options, responder))
1070        } else {
1071            None
1072        }
1073    }
1074
1075    #[allow(irrefutable_let_patterns)]
1076    pub fn into_get_time_zone_info(
1077        self,
1078    ) -> Option<(TimeZoneId, i64, TimeZonesGetTimeZoneInfoResponder)> {
1079        if let TimeZonesRequest::GetTimeZoneInfo { time_zone_id, at_time, responder } = self {
1080            Some((time_zone_id, at_time, responder))
1081        } else {
1082            None
1083        }
1084    }
1085
1086    /// Name of the method defined in FIDL
1087    pub fn method_name(&self) -> &'static str {
1088        match *self {
1089            TimeZonesRequest::AbsoluteToCivilTime { .. } => "absolute_to_civil_time",
1090            TimeZonesRequest::CivilToAbsoluteTime { .. } => "civil_to_absolute_time",
1091            TimeZonesRequest::GetTimeZoneInfo { .. } => "get_time_zone_info",
1092        }
1093    }
1094}
1095
1096#[derive(Debug, Clone)]
1097pub struct TimeZonesControlHandle {
1098    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1099}
1100
1101impl TimeZonesControlHandle {
1102    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1103        self.inner.shutdown_with_epitaph(status.into())
1104    }
1105}
1106
1107impl fidl::endpoints::ControlHandle for TimeZonesControlHandle {
1108    fn shutdown(&self) {
1109        self.inner.shutdown()
1110    }
1111
1112    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1113        self.inner.shutdown_with_epitaph(status)
1114    }
1115
1116    fn is_closed(&self) -> bool {
1117        self.inner.channel().is_closed()
1118    }
1119    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1120        self.inner.channel().on_closed()
1121    }
1122
1123    #[cfg(target_os = "fuchsia")]
1124    fn signal_peer(
1125        &self,
1126        clear_mask: zx::Signals,
1127        set_mask: zx::Signals,
1128    ) -> Result<(), zx_status::Status> {
1129        use fidl::Peered;
1130        self.inner.channel().signal_peer(clear_mask, set_mask)
1131    }
1132}
1133
1134impl TimeZonesControlHandle {}
1135
1136#[must_use = "FIDL methods require a response to be sent"]
1137#[derive(Debug)]
1138pub struct TimeZonesAbsoluteToCivilTimeResponder {
1139    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
1140    tx_id: u32,
1141}
1142
1143/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
1144/// if the responder is dropped without sending a response, so that the client
1145/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1146impl std::ops::Drop for TimeZonesAbsoluteToCivilTimeResponder {
1147    fn drop(&mut self) {
1148        self.control_handle.shutdown();
1149        // Safety: drops once, never accessed again
1150        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1151    }
1152}
1153
1154impl fidl::endpoints::Responder for TimeZonesAbsoluteToCivilTimeResponder {
1155    type ControlHandle = TimeZonesControlHandle;
1156
1157    fn control_handle(&self) -> &TimeZonesControlHandle {
1158        &self.control_handle
1159    }
1160
1161    fn drop_without_shutdown(mut self) {
1162        // Safety: drops once, never accessed again due to mem::forget
1163        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1164        // Prevent Drop from running (which would shut down the channel)
1165        std::mem::forget(self);
1166    }
1167}
1168
1169impl TimeZonesAbsoluteToCivilTimeResponder {
1170    /// Sends a response to the FIDL transaction.
1171    ///
1172    /// Sets the channel to shutdown if an error occurs.
1173    pub fn send(self, mut result: Result<&CivilTime, TimeZonesError>) -> Result<(), fidl::Error> {
1174        let _result = self.send_raw(result);
1175        if _result.is_err() {
1176            self.control_handle.shutdown();
1177        }
1178        self.drop_without_shutdown();
1179        _result
1180    }
1181
1182    /// Similar to "send" but does not shutdown the channel if an error occurs.
1183    pub fn send_no_shutdown_on_err(
1184        self,
1185        mut result: Result<&CivilTime, TimeZonesError>,
1186    ) -> Result<(), fidl::Error> {
1187        let _result = self.send_raw(result);
1188        self.drop_without_shutdown();
1189        _result
1190    }
1191
1192    fn send_raw(&self, mut result: Result<&CivilTime, TimeZonesError>) -> Result<(), fidl::Error> {
1193        self.control_handle.inner.send::<fidl::encoding::ResultType<
1194            TimeZonesAbsoluteToCivilTimeResponse,
1195            TimeZonesError,
1196        >>(
1197            result.map(|civil_time| (civil_time,)),
1198            self.tx_id,
1199            0x25377a4d9196e205,
1200            fidl::encoding::DynamicFlags::empty(),
1201        )
1202    }
1203}
1204
1205#[must_use = "FIDL methods require a response to be sent"]
1206#[derive(Debug)]
1207pub struct TimeZonesCivilToAbsoluteTimeResponder {
1208    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
1209    tx_id: u32,
1210}
1211
1212/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
1213/// if the responder is dropped without sending a response, so that the client
1214/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1215impl std::ops::Drop for TimeZonesCivilToAbsoluteTimeResponder {
1216    fn drop(&mut self) {
1217        self.control_handle.shutdown();
1218        // Safety: drops once, never accessed again
1219        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1220    }
1221}
1222
1223impl fidl::endpoints::Responder for TimeZonesCivilToAbsoluteTimeResponder {
1224    type ControlHandle = TimeZonesControlHandle;
1225
1226    fn control_handle(&self) -> &TimeZonesControlHandle {
1227        &self.control_handle
1228    }
1229
1230    fn drop_without_shutdown(mut self) {
1231        // Safety: drops once, never accessed again due to mem::forget
1232        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1233        // Prevent Drop from running (which would shut down the channel)
1234        std::mem::forget(self);
1235    }
1236}
1237
1238impl TimeZonesCivilToAbsoluteTimeResponder {
1239    /// Sends a response to the FIDL transaction.
1240    ///
1241    /// Sets the channel to shutdown if an error occurs.
1242    pub fn send(self, mut result: Result<i64, TimeZonesError>) -> Result<(), fidl::Error> {
1243        let _result = self.send_raw(result);
1244        if _result.is_err() {
1245            self.control_handle.shutdown();
1246        }
1247        self.drop_without_shutdown();
1248        _result
1249    }
1250
1251    /// Similar to "send" but does not shutdown the channel if an error occurs.
1252    pub fn send_no_shutdown_on_err(
1253        self,
1254        mut result: Result<i64, TimeZonesError>,
1255    ) -> Result<(), fidl::Error> {
1256        let _result = self.send_raw(result);
1257        self.drop_without_shutdown();
1258        _result
1259    }
1260
1261    fn send_raw(&self, mut result: Result<i64, TimeZonesError>) -> Result<(), fidl::Error> {
1262        self.control_handle.inner.send::<fidl::encoding::ResultType<
1263            TimeZonesCivilToAbsoluteTimeResponse,
1264            TimeZonesError,
1265        >>(
1266            result.map(|absolute_time| (absolute_time,)),
1267            self.tx_id,
1268            0xc1277c7a1413aa6,
1269            fidl::encoding::DynamicFlags::empty(),
1270        )
1271    }
1272}
1273
1274#[must_use = "FIDL methods require a response to be sent"]
1275#[derive(Debug)]
1276pub struct TimeZonesGetTimeZoneInfoResponder {
1277    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
1278    tx_id: u32,
1279}
1280
1281/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
1282/// if the responder is dropped without sending a response, so that the client
1283/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1284impl std::ops::Drop for TimeZonesGetTimeZoneInfoResponder {
1285    fn drop(&mut self) {
1286        self.control_handle.shutdown();
1287        // Safety: drops once, never accessed again
1288        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1289    }
1290}
1291
1292impl fidl::endpoints::Responder for TimeZonesGetTimeZoneInfoResponder {
1293    type ControlHandle = TimeZonesControlHandle;
1294
1295    fn control_handle(&self) -> &TimeZonesControlHandle {
1296        &self.control_handle
1297    }
1298
1299    fn drop_without_shutdown(mut self) {
1300        // Safety: drops once, never accessed again due to mem::forget
1301        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1302        // Prevent Drop from running (which would shut down the channel)
1303        std::mem::forget(self);
1304    }
1305}
1306
1307impl TimeZonesGetTimeZoneInfoResponder {
1308    /// Sends a response to the FIDL transaction.
1309    ///
1310    /// Sets the channel to shutdown if an error occurs.
1311    pub fn send(
1312        self,
1313        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1314    ) -> Result<(), fidl::Error> {
1315        let _result = self.send_raw(result);
1316        if _result.is_err() {
1317            self.control_handle.shutdown();
1318        }
1319        self.drop_without_shutdown();
1320        _result
1321    }
1322
1323    /// Similar to "send" but does not shutdown the channel if an error occurs.
1324    pub fn send_no_shutdown_on_err(
1325        self,
1326        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1327    ) -> Result<(), fidl::Error> {
1328        let _result = self.send_raw(result);
1329        self.drop_without_shutdown();
1330        _result
1331    }
1332
1333    fn send_raw(
1334        &self,
1335        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1336    ) -> Result<(), fidl::Error> {
1337        self.control_handle.inner.send::<fidl::encoding::ResultType<
1338            TimeZonesGetTimeZoneInfoResponse,
1339            TimeZonesError,
1340        >>(
1341            result.map(|time_zone_info| (time_zone_info,)),
1342            self.tx_id,
1343            0x2144cbac1d76fe65,
1344            fidl::encoding::DynamicFlags::empty(),
1345        )
1346    }
1347}
1348
1349mod internal {
1350    use super::*;
1351}