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 fdomain_client::fidl::ControlHandle for PropertyProviderControlHandle {
301    fn shutdown(&self) {
302        self.inner.shutdown()
303    }
304
305    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
306        self.inner.shutdown_with_epitaph(status)
307    }
308
309    fn is_closed(&self) -> bool {
310        self.inner.channel().is_closed()
311    }
312    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
313        self.inner.channel().on_closed()
314    }
315}
316
317impl PropertyProviderControlHandle {
318    pub fn send_on_change(&self) -> Result<(), fidl::Error> {
319        self.inner.send::<fidl::encoding::EmptyPayload>(
320            (),
321            0,
322            0x26b9ed6e23c46991,
323            fidl::encoding::DynamicFlags::empty(),
324        )
325    }
326}
327
328#[must_use = "FIDL methods require a response to be sent"]
329#[derive(Debug)]
330pub struct PropertyProviderGetProfileResponder {
331    control_handle: std::mem::ManuallyDrop<PropertyProviderControlHandle>,
332    tx_id: u32,
333}
334
335/// Set the the channel to be shutdown (see [`PropertyProviderControlHandle::shutdown`])
336/// if the responder is dropped without sending a response, so that the client
337/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
338impl std::ops::Drop for PropertyProviderGetProfileResponder {
339    fn drop(&mut self) {
340        self.control_handle.shutdown();
341        // Safety: drops once, never accessed again
342        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
343    }
344}
345
346impl fdomain_client::fidl::Responder for PropertyProviderGetProfileResponder {
347    type ControlHandle = PropertyProviderControlHandle;
348
349    fn control_handle(&self) -> &PropertyProviderControlHandle {
350        &self.control_handle
351    }
352
353    fn drop_without_shutdown(mut self) {
354        // Safety: drops once, never accessed again due to mem::forget
355        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
356        // Prevent Drop from running (which would shut down the channel)
357        std::mem::forget(self);
358    }
359}
360
361impl PropertyProviderGetProfileResponder {
362    /// Sends a response to the FIDL transaction.
363    ///
364    /// Sets the channel to shutdown if an error occurs.
365    pub fn send(self, mut profile: &Profile) -> Result<(), fidl::Error> {
366        let _result = self.send_raw(profile);
367        if _result.is_err() {
368            self.control_handle.shutdown();
369        }
370        self.drop_without_shutdown();
371        _result
372    }
373
374    /// Similar to "send" but does not shutdown the channel if an error occurs.
375    pub fn send_no_shutdown_on_err(self, mut profile: &Profile) -> Result<(), fidl::Error> {
376        let _result = self.send_raw(profile);
377        self.drop_without_shutdown();
378        _result
379    }
380
381    fn send_raw(&self, mut profile: &Profile) -> Result<(), fidl::Error> {
382        self.control_handle.inner.send::<PropertyProviderGetProfileResponse>(
383            (profile,),
384            self.tx_id,
385            0x10bf06e68d36d3eb,
386            fidl::encoding::DynamicFlags::empty(),
387        )
388    }
389}
390
391#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
392pub struct TimeZonesMarker;
393
394impl fdomain_client::fidl::ProtocolMarker for TimeZonesMarker {
395    type Proxy = TimeZonesProxy;
396    type RequestStream = TimeZonesRequestStream;
397
398    const DEBUG_NAME: &'static str = "fuchsia.intl.TimeZones";
399}
400impl fdomain_client::fidl::DiscoverableProtocolMarker for TimeZonesMarker {}
401pub type TimeZonesAbsoluteToCivilTimeResult = Result<CivilTime, TimeZonesError>;
402pub type TimeZonesCivilToAbsoluteTimeResult = Result<i64, TimeZonesError>;
403pub type TimeZonesGetTimeZoneInfoResult = Result<TimeZoneInfo, TimeZonesError>;
404
405pub trait TimeZonesProxyInterface: Send + Sync {
406    type AbsoluteToCivilTimeResponseFut: std::future::Future<Output = Result<TimeZonesAbsoluteToCivilTimeResult, fidl::Error>>
407        + Send;
408    fn r#absolute_to_civil_time(
409        &self,
410        time_zone_id: &TimeZoneId,
411        absolute_time: i64,
412    ) -> Self::AbsoluteToCivilTimeResponseFut;
413    type CivilToAbsoluteTimeResponseFut: std::future::Future<Output = Result<TimeZonesCivilToAbsoluteTimeResult, fidl::Error>>
414        + Send;
415    fn r#civil_to_absolute_time(
416        &self,
417        civil_time: &CivilTime,
418        options: &CivilToAbsoluteTimeOptions,
419    ) -> Self::CivilToAbsoluteTimeResponseFut;
420    type GetTimeZoneInfoResponseFut: std::future::Future<Output = Result<TimeZonesGetTimeZoneInfoResult, fidl::Error>>
421        + Send;
422    fn r#get_time_zone_info(
423        &self,
424        time_zone_id: &TimeZoneId,
425        at_time: i64,
426    ) -> Self::GetTimeZoneInfoResponseFut;
427}
428
429#[derive(Debug, Clone)]
430pub struct TimeZonesProxy {
431    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
432}
433
434impl fdomain_client::fidl::Proxy for TimeZonesProxy {
435    type Protocol = TimeZonesMarker;
436
437    fn from_channel(inner: fdomain_client::Channel) -> Self {
438        Self::new(inner)
439    }
440
441    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
442        self.client.into_channel().map_err(|client| Self { client })
443    }
444
445    fn as_channel(&self) -> &fdomain_client::Channel {
446        self.client.as_channel()
447    }
448}
449
450impl TimeZonesProxy {
451    /// Create a new Proxy for fuchsia.intl/TimeZones.
452    pub fn new(channel: fdomain_client::Channel) -> Self {
453        let protocol_name = <TimeZonesMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
454        Self { client: fidl::client::Client::new(channel, protocol_name) }
455    }
456
457    /// Get a Stream of events from the remote end of the protocol.
458    ///
459    /// # Panics
460    ///
461    /// Panics if the event stream was already taken.
462    pub fn take_event_stream(&self) -> TimeZonesEventStream {
463        TimeZonesEventStream { event_receiver: self.client.take_event_receiver() }
464    }
465
466    /// Converts the given absolute time to a civil date and time in the given time zone, using the
467    /// Gregorian calendar.
468    pub fn r#absolute_to_civil_time(
469        &self,
470        mut time_zone_id: &TimeZoneId,
471        mut absolute_time: i64,
472    ) -> fidl::client::QueryResponseFut<
473        TimeZonesAbsoluteToCivilTimeResult,
474        fdomain_client::fidl::FDomainResourceDialect,
475    > {
476        TimeZonesProxyInterface::r#absolute_to_civil_time(self, time_zone_id, absolute_time)
477    }
478
479    /// Converts the given civil date and time in the given time zone to nanoseconds since the Unix
480    /// epoch.
481    pub fn r#civil_to_absolute_time(
482        &self,
483        mut civil_time: &CivilTime,
484        mut options: &CivilToAbsoluteTimeOptions,
485    ) -> fidl::client::QueryResponseFut<
486        TimeZonesCivilToAbsoluteTimeResult,
487        fdomain_client::fidl::FDomainResourceDialect,
488    > {
489        TimeZonesProxyInterface::r#civil_to_absolute_time(self, civil_time, options)
490    }
491
492    /// Retrieves details about a time zone at a specified one.
493    pub fn r#get_time_zone_info(
494        &self,
495        mut time_zone_id: &TimeZoneId,
496        mut at_time: i64,
497    ) -> fidl::client::QueryResponseFut<
498        TimeZonesGetTimeZoneInfoResult,
499        fdomain_client::fidl::FDomainResourceDialect,
500    > {
501        TimeZonesProxyInterface::r#get_time_zone_info(self, time_zone_id, at_time)
502    }
503}
504
505impl TimeZonesProxyInterface for TimeZonesProxy {
506    type AbsoluteToCivilTimeResponseFut = fidl::client::QueryResponseFut<
507        TimeZonesAbsoluteToCivilTimeResult,
508        fdomain_client::fidl::FDomainResourceDialect,
509    >;
510    fn r#absolute_to_civil_time(
511        &self,
512        mut time_zone_id: &TimeZoneId,
513        mut absolute_time: i64,
514    ) -> Self::AbsoluteToCivilTimeResponseFut {
515        fn _decode(
516            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
517        ) -> Result<TimeZonesAbsoluteToCivilTimeResult, fidl::Error> {
518            let _response = fidl::client::decode_transaction_body::<
519                fidl::encoding::ResultType<TimeZonesAbsoluteToCivilTimeResponse, TimeZonesError>,
520                fdomain_client::fidl::FDomainResourceDialect,
521                0x25377a4d9196e205,
522            >(_buf?)?;
523            Ok(_response.map(|x| x.civil_time))
524        }
525        self.client.send_query_and_decode::<
526            TimeZonesAbsoluteToCivilTimeRequest,
527            TimeZonesAbsoluteToCivilTimeResult,
528        >(
529            (time_zone_id, absolute_time,),
530            0x25377a4d9196e205,
531            fidl::encoding::DynamicFlags::empty(),
532            _decode,
533        )
534    }
535
536    type CivilToAbsoluteTimeResponseFut = fidl::client::QueryResponseFut<
537        TimeZonesCivilToAbsoluteTimeResult,
538        fdomain_client::fidl::FDomainResourceDialect,
539    >;
540    fn r#civil_to_absolute_time(
541        &self,
542        mut civil_time: &CivilTime,
543        mut options: &CivilToAbsoluteTimeOptions,
544    ) -> Self::CivilToAbsoluteTimeResponseFut {
545        fn _decode(
546            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
547        ) -> Result<TimeZonesCivilToAbsoluteTimeResult, fidl::Error> {
548            let _response = fidl::client::decode_transaction_body::<
549                fidl::encoding::ResultType<TimeZonesCivilToAbsoluteTimeResponse, TimeZonesError>,
550                fdomain_client::fidl::FDomainResourceDialect,
551                0xc1277c7a1413aa6,
552            >(_buf?)?;
553            Ok(_response.map(|x| x.absolute_time))
554        }
555        self.client.send_query_and_decode::<
556            TimeZonesCivilToAbsoluteTimeRequest,
557            TimeZonesCivilToAbsoluteTimeResult,
558        >(
559            (civil_time, options,),
560            0xc1277c7a1413aa6,
561            fidl::encoding::DynamicFlags::empty(),
562            _decode,
563        )
564    }
565
566    type GetTimeZoneInfoResponseFut = fidl::client::QueryResponseFut<
567        TimeZonesGetTimeZoneInfoResult,
568        fdomain_client::fidl::FDomainResourceDialect,
569    >;
570    fn r#get_time_zone_info(
571        &self,
572        mut time_zone_id: &TimeZoneId,
573        mut at_time: i64,
574    ) -> Self::GetTimeZoneInfoResponseFut {
575        fn _decode(
576            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
577        ) -> Result<TimeZonesGetTimeZoneInfoResult, fidl::Error> {
578            let _response = fidl::client::decode_transaction_body::<
579                fidl::encoding::ResultType<TimeZonesGetTimeZoneInfoResponse, TimeZonesError>,
580                fdomain_client::fidl::FDomainResourceDialect,
581                0x2144cbac1d76fe65,
582            >(_buf?)?;
583            Ok(_response.map(|x| x.time_zone_info))
584        }
585        self.client.send_query_and_decode::<
586            TimeZonesGetTimeZoneInfoRequest,
587            TimeZonesGetTimeZoneInfoResult,
588        >(
589            (time_zone_id, at_time,),
590            0x2144cbac1d76fe65,
591            fidl::encoding::DynamicFlags::empty(),
592            _decode,
593        )
594    }
595}
596
597pub struct TimeZonesEventStream {
598    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
599}
600
601impl std::marker::Unpin for TimeZonesEventStream {}
602
603impl futures::stream::FusedStream for TimeZonesEventStream {
604    fn is_terminated(&self) -> bool {
605        self.event_receiver.is_terminated()
606    }
607}
608
609impl futures::Stream for TimeZonesEventStream {
610    type Item = Result<TimeZonesEvent, fidl::Error>;
611
612    fn poll_next(
613        mut self: std::pin::Pin<&mut Self>,
614        cx: &mut std::task::Context<'_>,
615    ) -> std::task::Poll<Option<Self::Item>> {
616        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
617            &mut self.event_receiver,
618            cx
619        )?) {
620            Some(buf) => std::task::Poll::Ready(Some(TimeZonesEvent::decode(buf))),
621            None => std::task::Poll::Ready(None),
622        }
623    }
624}
625
626#[derive(Debug)]
627pub enum TimeZonesEvent {}
628
629impl TimeZonesEvent {
630    /// Decodes a message buffer as a [`TimeZonesEvent`].
631    fn decode(
632        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
633    ) -> Result<TimeZonesEvent, fidl::Error> {
634        let (bytes, _handles) = buf.split_mut();
635        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
636        debug_assert_eq!(tx_header.tx_id, 0);
637        match tx_header.ordinal {
638            _ => Err(fidl::Error::UnknownOrdinal {
639                ordinal: tx_header.ordinal,
640                protocol_name:
641                    <TimeZonesMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
642            }),
643        }
644    }
645}
646
647/// A Stream of incoming requests for fuchsia.intl/TimeZones.
648pub struct TimeZonesRequestStream {
649    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
650    is_terminated: bool,
651}
652
653impl std::marker::Unpin for TimeZonesRequestStream {}
654
655impl futures::stream::FusedStream for TimeZonesRequestStream {
656    fn is_terminated(&self) -> bool {
657        self.is_terminated
658    }
659}
660
661impl fdomain_client::fidl::RequestStream for TimeZonesRequestStream {
662    type Protocol = TimeZonesMarker;
663    type ControlHandle = TimeZonesControlHandle;
664
665    fn from_channel(channel: fdomain_client::Channel) -> Self {
666        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
667    }
668
669    fn control_handle(&self) -> Self::ControlHandle {
670        TimeZonesControlHandle { inner: self.inner.clone() }
671    }
672
673    fn into_inner(
674        self,
675    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
676    {
677        (self.inner, self.is_terminated)
678    }
679
680    fn from_inner(
681        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
682        is_terminated: bool,
683    ) -> Self {
684        Self { inner, is_terminated }
685    }
686}
687
688impl futures::Stream for TimeZonesRequestStream {
689    type Item = Result<TimeZonesRequest, fidl::Error>;
690
691    fn poll_next(
692        mut self: std::pin::Pin<&mut Self>,
693        cx: &mut std::task::Context<'_>,
694    ) -> std::task::Poll<Option<Self::Item>> {
695        let this = &mut *self;
696        if this.inner.check_shutdown(cx) {
697            this.is_terminated = true;
698            return std::task::Poll::Ready(None);
699        }
700        if this.is_terminated {
701            panic!("polled TimeZonesRequestStream after completion");
702        }
703        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
704            |bytes, handles| {
705                match this.inner.channel().read_etc(cx, bytes, handles) {
706                    std::task::Poll::Ready(Ok(())) => {}
707                    std::task::Poll::Pending => return std::task::Poll::Pending,
708                    std::task::Poll::Ready(Err(None)) => {
709                        this.is_terminated = true;
710                        return std::task::Poll::Ready(None);
711                    }
712                    std::task::Poll::Ready(Err(Some(e))) => {
713                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
714                            e.into(),
715                        ))));
716                    }
717                }
718
719                // A message has been received from the channel
720                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
721
722                std::task::Poll::Ready(Some(match header.ordinal {
723                    0x25377a4d9196e205 => {
724                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
725                        let mut req = fidl::new_empty!(
726                            TimeZonesAbsoluteToCivilTimeRequest,
727                            fdomain_client::fidl::FDomainResourceDialect
728                        );
729                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<TimeZonesAbsoluteToCivilTimeRequest>(&header, _body_bytes, handles, &mut req)?;
730                        let control_handle = TimeZonesControlHandle { inner: this.inner.clone() };
731                        Ok(TimeZonesRequest::AbsoluteToCivilTime {
732                            time_zone_id: req.time_zone_id,
733                            absolute_time: req.absolute_time,
734
735                            responder: TimeZonesAbsoluteToCivilTimeResponder {
736                                control_handle: std::mem::ManuallyDrop::new(control_handle),
737                                tx_id: header.tx_id,
738                            },
739                        })
740                    }
741                    0xc1277c7a1413aa6 => {
742                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
743                        let mut req = fidl::new_empty!(
744                            TimeZonesCivilToAbsoluteTimeRequest,
745                            fdomain_client::fidl::FDomainResourceDialect
746                        );
747                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<TimeZonesCivilToAbsoluteTimeRequest>(&header, _body_bytes, handles, &mut req)?;
748                        let control_handle = TimeZonesControlHandle { inner: this.inner.clone() };
749                        Ok(TimeZonesRequest::CivilToAbsoluteTime {
750                            civil_time: req.civil_time,
751                            options: req.options,
752
753                            responder: TimeZonesCivilToAbsoluteTimeResponder {
754                                control_handle: std::mem::ManuallyDrop::new(control_handle),
755                                tx_id: header.tx_id,
756                            },
757                        })
758                    }
759                    0x2144cbac1d76fe65 => {
760                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
761                        let mut req = fidl::new_empty!(
762                            TimeZonesGetTimeZoneInfoRequest,
763                            fdomain_client::fidl::FDomainResourceDialect
764                        );
765                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<TimeZonesGetTimeZoneInfoRequest>(&header, _body_bytes, handles, &mut req)?;
766                        let control_handle = TimeZonesControlHandle { inner: this.inner.clone() };
767                        Ok(TimeZonesRequest::GetTimeZoneInfo {
768                            time_zone_id: req.time_zone_id,
769                            at_time: req.at_time,
770
771                            responder: TimeZonesGetTimeZoneInfoResponder {
772                                control_handle: std::mem::ManuallyDrop::new(control_handle),
773                                tx_id: header.tx_id,
774                            },
775                        })
776                    }
777                    _ => Err(fidl::Error::UnknownOrdinal {
778                        ordinal: header.ordinal,
779                        protocol_name:
780                            <TimeZonesMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
781                    }),
782                }))
783            },
784        )
785    }
786}
787
788/// Provides information about time zones and offers date-time conversion methods.
789///
790/// TODO(https://fxbug.dev/42162409): Add time zone info methods, including offsets from UTC.
791#[derive(Debug)]
792pub enum TimeZonesRequest {
793    /// Converts the given absolute time to a civil date and time in the given time zone, using the
794    /// Gregorian calendar.
795    AbsoluteToCivilTime {
796        time_zone_id: TimeZoneId,
797        absolute_time: i64,
798        responder: TimeZonesAbsoluteToCivilTimeResponder,
799    },
800    /// Converts the given civil date and time in the given time zone to nanoseconds since the Unix
801    /// epoch.
802    CivilToAbsoluteTime {
803        civil_time: CivilTime,
804        options: CivilToAbsoluteTimeOptions,
805        responder: TimeZonesCivilToAbsoluteTimeResponder,
806    },
807    /// Retrieves details about a time zone at a specified one.
808    GetTimeZoneInfo {
809        time_zone_id: TimeZoneId,
810        at_time: i64,
811        responder: TimeZonesGetTimeZoneInfoResponder,
812    },
813}
814
815impl TimeZonesRequest {
816    #[allow(irrefutable_let_patterns)]
817    pub fn into_absolute_to_civil_time(
818        self,
819    ) -> Option<(TimeZoneId, i64, TimeZonesAbsoluteToCivilTimeResponder)> {
820        if let TimeZonesRequest::AbsoluteToCivilTime { time_zone_id, absolute_time, responder } =
821            self
822        {
823            Some((time_zone_id, absolute_time, responder))
824        } else {
825            None
826        }
827    }
828
829    #[allow(irrefutable_let_patterns)]
830    pub fn into_civil_to_absolute_time(
831        self,
832    ) -> Option<(CivilTime, CivilToAbsoluteTimeOptions, TimeZonesCivilToAbsoluteTimeResponder)>
833    {
834        if let TimeZonesRequest::CivilToAbsoluteTime { civil_time, options, responder } = self {
835            Some((civil_time, options, responder))
836        } else {
837            None
838        }
839    }
840
841    #[allow(irrefutable_let_patterns)]
842    pub fn into_get_time_zone_info(
843        self,
844    ) -> Option<(TimeZoneId, i64, TimeZonesGetTimeZoneInfoResponder)> {
845        if let TimeZonesRequest::GetTimeZoneInfo { time_zone_id, at_time, responder } = self {
846            Some((time_zone_id, at_time, responder))
847        } else {
848            None
849        }
850    }
851
852    /// Name of the method defined in FIDL
853    pub fn method_name(&self) -> &'static str {
854        match *self {
855            TimeZonesRequest::AbsoluteToCivilTime { .. } => "absolute_to_civil_time",
856            TimeZonesRequest::CivilToAbsoluteTime { .. } => "civil_to_absolute_time",
857            TimeZonesRequest::GetTimeZoneInfo { .. } => "get_time_zone_info",
858        }
859    }
860}
861
862#[derive(Debug, Clone)]
863pub struct TimeZonesControlHandle {
864    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
865}
866
867impl fdomain_client::fidl::ControlHandle for TimeZonesControlHandle {
868    fn shutdown(&self) {
869        self.inner.shutdown()
870    }
871
872    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
873        self.inner.shutdown_with_epitaph(status)
874    }
875
876    fn is_closed(&self) -> bool {
877        self.inner.channel().is_closed()
878    }
879    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
880        self.inner.channel().on_closed()
881    }
882}
883
884impl TimeZonesControlHandle {}
885
886#[must_use = "FIDL methods require a response to be sent"]
887#[derive(Debug)]
888pub struct TimeZonesAbsoluteToCivilTimeResponder {
889    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
890    tx_id: u32,
891}
892
893/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
894/// if the responder is dropped without sending a response, so that the client
895/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
896impl std::ops::Drop for TimeZonesAbsoluteToCivilTimeResponder {
897    fn drop(&mut self) {
898        self.control_handle.shutdown();
899        // Safety: drops once, never accessed again
900        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
901    }
902}
903
904impl fdomain_client::fidl::Responder for TimeZonesAbsoluteToCivilTimeResponder {
905    type ControlHandle = TimeZonesControlHandle;
906
907    fn control_handle(&self) -> &TimeZonesControlHandle {
908        &self.control_handle
909    }
910
911    fn drop_without_shutdown(mut self) {
912        // Safety: drops once, never accessed again due to mem::forget
913        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
914        // Prevent Drop from running (which would shut down the channel)
915        std::mem::forget(self);
916    }
917}
918
919impl TimeZonesAbsoluteToCivilTimeResponder {
920    /// Sends a response to the FIDL transaction.
921    ///
922    /// Sets the channel to shutdown if an error occurs.
923    pub fn send(self, mut result: Result<&CivilTime, TimeZonesError>) -> Result<(), fidl::Error> {
924        let _result = self.send_raw(result);
925        if _result.is_err() {
926            self.control_handle.shutdown();
927        }
928        self.drop_without_shutdown();
929        _result
930    }
931
932    /// Similar to "send" but does not shutdown the channel if an error occurs.
933    pub fn send_no_shutdown_on_err(
934        self,
935        mut result: Result<&CivilTime, TimeZonesError>,
936    ) -> Result<(), fidl::Error> {
937        let _result = self.send_raw(result);
938        self.drop_without_shutdown();
939        _result
940    }
941
942    fn send_raw(&self, mut result: Result<&CivilTime, TimeZonesError>) -> Result<(), fidl::Error> {
943        self.control_handle.inner.send::<fidl::encoding::ResultType<
944            TimeZonesAbsoluteToCivilTimeResponse,
945            TimeZonesError,
946        >>(
947            result.map(|civil_time| (civil_time,)),
948            self.tx_id,
949            0x25377a4d9196e205,
950            fidl::encoding::DynamicFlags::empty(),
951        )
952    }
953}
954
955#[must_use = "FIDL methods require a response to be sent"]
956#[derive(Debug)]
957pub struct TimeZonesCivilToAbsoluteTimeResponder {
958    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
959    tx_id: u32,
960}
961
962/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
963/// if the responder is dropped without sending a response, so that the client
964/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
965impl std::ops::Drop for TimeZonesCivilToAbsoluteTimeResponder {
966    fn drop(&mut self) {
967        self.control_handle.shutdown();
968        // Safety: drops once, never accessed again
969        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
970    }
971}
972
973impl fdomain_client::fidl::Responder for TimeZonesCivilToAbsoluteTimeResponder {
974    type ControlHandle = TimeZonesControlHandle;
975
976    fn control_handle(&self) -> &TimeZonesControlHandle {
977        &self.control_handle
978    }
979
980    fn drop_without_shutdown(mut self) {
981        // Safety: drops once, never accessed again due to mem::forget
982        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
983        // Prevent Drop from running (which would shut down the channel)
984        std::mem::forget(self);
985    }
986}
987
988impl TimeZonesCivilToAbsoluteTimeResponder {
989    /// Sends a response to the FIDL transaction.
990    ///
991    /// Sets the channel to shutdown if an error occurs.
992    pub fn send(self, mut result: Result<i64, TimeZonesError>) -> Result<(), fidl::Error> {
993        let _result = self.send_raw(result);
994        if _result.is_err() {
995            self.control_handle.shutdown();
996        }
997        self.drop_without_shutdown();
998        _result
999    }
1000
1001    /// Similar to "send" but does not shutdown the channel if an error occurs.
1002    pub fn send_no_shutdown_on_err(
1003        self,
1004        mut result: Result<i64, TimeZonesError>,
1005    ) -> Result<(), fidl::Error> {
1006        let _result = self.send_raw(result);
1007        self.drop_without_shutdown();
1008        _result
1009    }
1010
1011    fn send_raw(&self, mut result: Result<i64, TimeZonesError>) -> Result<(), fidl::Error> {
1012        self.control_handle.inner.send::<fidl::encoding::ResultType<
1013            TimeZonesCivilToAbsoluteTimeResponse,
1014            TimeZonesError,
1015        >>(
1016            result.map(|absolute_time| (absolute_time,)),
1017            self.tx_id,
1018            0xc1277c7a1413aa6,
1019            fidl::encoding::DynamicFlags::empty(),
1020        )
1021    }
1022}
1023
1024#[must_use = "FIDL methods require a response to be sent"]
1025#[derive(Debug)]
1026pub struct TimeZonesGetTimeZoneInfoResponder {
1027    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
1028    tx_id: u32,
1029}
1030
1031/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
1032/// if the responder is dropped without sending a response, so that the client
1033/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1034impl std::ops::Drop for TimeZonesGetTimeZoneInfoResponder {
1035    fn drop(&mut self) {
1036        self.control_handle.shutdown();
1037        // Safety: drops once, never accessed again
1038        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1039    }
1040}
1041
1042impl fdomain_client::fidl::Responder for TimeZonesGetTimeZoneInfoResponder {
1043    type ControlHandle = TimeZonesControlHandle;
1044
1045    fn control_handle(&self) -> &TimeZonesControlHandle {
1046        &self.control_handle
1047    }
1048
1049    fn drop_without_shutdown(mut self) {
1050        // Safety: drops once, never accessed again due to mem::forget
1051        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1052        // Prevent Drop from running (which would shut down the channel)
1053        std::mem::forget(self);
1054    }
1055}
1056
1057impl TimeZonesGetTimeZoneInfoResponder {
1058    /// Sends a response to the FIDL transaction.
1059    ///
1060    /// Sets the channel to shutdown if an error occurs.
1061    pub fn send(
1062        self,
1063        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1064    ) -> Result<(), fidl::Error> {
1065        let _result = self.send_raw(result);
1066        if _result.is_err() {
1067            self.control_handle.shutdown();
1068        }
1069        self.drop_without_shutdown();
1070        _result
1071    }
1072
1073    /// Similar to "send" but does not shutdown the channel if an error occurs.
1074    pub fn send_no_shutdown_on_err(
1075        self,
1076        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1077    ) -> Result<(), fidl::Error> {
1078        let _result = self.send_raw(result);
1079        self.drop_without_shutdown();
1080        _result
1081    }
1082
1083    fn send_raw(
1084        &self,
1085        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1086    ) -> Result<(), fidl::Error> {
1087        self.control_handle.inner.send::<fidl::encoding::ResultType<
1088            TimeZonesGetTimeZoneInfoResponse,
1089            TimeZonesError,
1090        >>(
1091            result.map(|time_zone_info| (time_zone_info,)),
1092            self.tx_id,
1093            0x2144cbac1d76fe65,
1094            fidl::encoding::DynamicFlags::empty(),
1095        )
1096    }
1097}
1098
1099mod internal {
1100    use super::*;
1101}