Skip to main content

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