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 {
136            Some(())
137        } else {
138            None
139        }
140    }
141
142    /// Decodes a message buffer as a [`PropertyProviderEvent`].
143    fn decode(
144        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
145    ) -> Result<PropertyProviderEvent, fidl::Error> {
146        let (bytes, _handles) = buf.split_mut();
147        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
148        debug_assert_eq!(tx_header.tx_id, 0);
149        match tx_header.ordinal {
150            0x26b9ed6e23c46991 => {
151                let mut out = fidl::new_empty!(
152                    fidl::encoding::EmptyPayload,
153                    fdomain_client::fidl::FDomainResourceDialect
154                );
155                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
156                Ok((PropertyProviderEvent::OnChange {}))
157            }
158            _ => Err(fidl::Error::UnknownOrdinal {
159                ordinal: tx_header.ordinal,
160                protocol_name:
161                    <PropertyProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
162            }),
163        }
164    }
165}
166
167/// A Stream of incoming requests for fuchsia.intl/PropertyProvider.
168pub struct PropertyProviderRequestStream {
169    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
170    is_terminated: bool,
171}
172
173impl std::marker::Unpin for PropertyProviderRequestStream {}
174
175impl futures::stream::FusedStream for PropertyProviderRequestStream {
176    fn is_terminated(&self) -> bool {
177        self.is_terminated
178    }
179}
180
181impl fdomain_client::fidl::RequestStream for PropertyProviderRequestStream {
182    type Protocol = PropertyProviderMarker;
183    type ControlHandle = PropertyProviderControlHandle;
184
185    fn from_channel(channel: fdomain_client::Channel) -> Self {
186        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
187    }
188
189    fn control_handle(&self) -> Self::ControlHandle {
190        PropertyProviderControlHandle { inner: self.inner.clone() }
191    }
192
193    fn into_inner(
194        self,
195    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
196    {
197        (self.inner, self.is_terminated)
198    }
199
200    fn from_inner(
201        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
202        is_terminated: bool,
203    ) -> Self {
204        Self { inner, is_terminated }
205    }
206}
207
208impl futures::Stream for PropertyProviderRequestStream {
209    type Item = Result<PropertyProviderRequest, fidl::Error>;
210
211    fn poll_next(
212        mut self: std::pin::Pin<&mut Self>,
213        cx: &mut std::task::Context<'_>,
214    ) -> std::task::Poll<Option<Self::Item>> {
215        let this = &mut *self;
216        if this.inner.check_shutdown(cx) {
217            this.is_terminated = true;
218            return std::task::Poll::Ready(None);
219        }
220        if this.is_terminated {
221            panic!("polled PropertyProviderRequestStream after completion");
222        }
223        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
224            |bytes, handles| {
225                match this.inner.channel().read_etc(cx, bytes, handles) {
226                    std::task::Poll::Ready(Ok(())) => {}
227                    std::task::Poll::Pending => return std::task::Poll::Pending,
228                    std::task::Poll::Ready(Err(None)) => {
229                        this.is_terminated = true;
230                        return std::task::Poll::Ready(None);
231                    }
232                    std::task::Poll::Ready(Err(Some(e))) => {
233                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
234                            e.into(),
235                        ))))
236                    }
237                }
238
239                // A message has been received from the channel
240                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
241
242                std::task::Poll::Ready(Some(match header.ordinal {
243                0x10bf06e68d36d3eb => {
244                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
245                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
246                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
247                    let control_handle = PropertyProviderControlHandle {
248                        inner: this.inner.clone(),
249                    };
250                    Ok(PropertyProviderRequest::GetProfile {
251                        responder: PropertyProviderGetProfileResponder {
252                            control_handle: std::mem::ManuallyDrop::new(control_handle),
253                            tx_id: header.tx_id,
254                        },
255                    })
256                }
257                _ => Err(fidl::Error::UnknownOrdinal {
258                    ordinal: header.ordinal,
259                    protocol_name: <PropertyProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
260                }),
261            }))
262            },
263        )
264    }
265}
266
267/// Provides internationalization properties.
268///
269/// Components that need to change their behavior in response to the user's internationalization
270/// profile may request an instance of this service from their namespace, if available. A component
271/// may choose to pass along the service that it received from its parent to its own children, or to
272/// override it and apply additional customizations.
273///
274/// See also `fuchsia.ui.views.View`.
275#[derive(Debug)]
276pub enum PropertyProviderRequest {
277    /// Gets the user's internationalization profile.
278    GetProfile { responder: PropertyProviderGetProfileResponder },
279}
280
281impl PropertyProviderRequest {
282    #[allow(irrefutable_let_patterns)]
283    pub fn into_get_profile(self) -> Option<(PropertyProviderGetProfileResponder)> {
284        if let PropertyProviderRequest::GetProfile { responder } = self {
285            Some((responder))
286        } else {
287            None
288        }
289    }
290
291    /// Name of the method defined in FIDL
292    pub fn method_name(&self) -> &'static str {
293        match *self {
294            PropertyProviderRequest::GetProfile { .. } => "get_profile",
295        }
296    }
297}
298
299#[derive(Debug, Clone)]
300pub struct PropertyProviderControlHandle {
301    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
302}
303
304impl fdomain_client::fidl::ControlHandle for PropertyProviderControlHandle {
305    fn shutdown(&self) {
306        self.inner.shutdown()
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 is_closed(&self) -> bool {
873        self.inner.channel().is_closed()
874    }
875    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
876        self.inner.channel().on_closed()
877    }
878}
879
880impl TimeZonesControlHandle {}
881
882#[must_use = "FIDL methods require a response to be sent"]
883#[derive(Debug)]
884pub struct TimeZonesAbsoluteToCivilTimeResponder {
885    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
886    tx_id: u32,
887}
888
889/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
890/// if the responder is dropped without sending a response, so that the client
891/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
892impl std::ops::Drop for TimeZonesAbsoluteToCivilTimeResponder {
893    fn drop(&mut self) {
894        self.control_handle.shutdown();
895        // Safety: drops once, never accessed again
896        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
897    }
898}
899
900impl fdomain_client::fidl::Responder for TimeZonesAbsoluteToCivilTimeResponder {
901    type ControlHandle = TimeZonesControlHandle;
902
903    fn control_handle(&self) -> &TimeZonesControlHandle {
904        &self.control_handle
905    }
906
907    fn drop_without_shutdown(mut self) {
908        // Safety: drops once, never accessed again due to mem::forget
909        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
910        // Prevent Drop from running (which would shut down the channel)
911        std::mem::forget(self);
912    }
913}
914
915impl TimeZonesAbsoluteToCivilTimeResponder {
916    /// Sends a response to the FIDL transaction.
917    ///
918    /// Sets the channel to shutdown if an error occurs.
919    pub fn send(self, mut result: Result<&CivilTime, TimeZonesError>) -> Result<(), fidl::Error> {
920        let _result = self.send_raw(result);
921        if _result.is_err() {
922            self.control_handle.shutdown();
923        }
924        self.drop_without_shutdown();
925        _result
926    }
927
928    /// Similar to "send" but does not shutdown the channel if an error occurs.
929    pub fn send_no_shutdown_on_err(
930        self,
931        mut result: Result<&CivilTime, TimeZonesError>,
932    ) -> Result<(), fidl::Error> {
933        let _result = self.send_raw(result);
934        self.drop_without_shutdown();
935        _result
936    }
937
938    fn send_raw(&self, mut result: Result<&CivilTime, TimeZonesError>) -> Result<(), fidl::Error> {
939        self.control_handle.inner.send::<fidl::encoding::ResultType<
940            TimeZonesAbsoluteToCivilTimeResponse,
941            TimeZonesError,
942        >>(
943            result.map(|civil_time| (civil_time,)),
944            self.tx_id,
945            0x25377a4d9196e205,
946            fidl::encoding::DynamicFlags::empty(),
947        )
948    }
949}
950
951#[must_use = "FIDL methods require a response to be sent"]
952#[derive(Debug)]
953pub struct TimeZonesCivilToAbsoluteTimeResponder {
954    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
955    tx_id: u32,
956}
957
958/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
959/// if the responder is dropped without sending a response, so that the client
960/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
961impl std::ops::Drop for TimeZonesCivilToAbsoluteTimeResponder {
962    fn drop(&mut self) {
963        self.control_handle.shutdown();
964        // Safety: drops once, never accessed again
965        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
966    }
967}
968
969impl fdomain_client::fidl::Responder for TimeZonesCivilToAbsoluteTimeResponder {
970    type ControlHandle = TimeZonesControlHandle;
971
972    fn control_handle(&self) -> &TimeZonesControlHandle {
973        &self.control_handle
974    }
975
976    fn drop_without_shutdown(mut self) {
977        // Safety: drops once, never accessed again due to mem::forget
978        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
979        // Prevent Drop from running (which would shut down the channel)
980        std::mem::forget(self);
981    }
982}
983
984impl TimeZonesCivilToAbsoluteTimeResponder {
985    /// Sends a response to the FIDL transaction.
986    ///
987    /// Sets the channel to shutdown if an error occurs.
988    pub fn send(self, mut result: Result<i64, TimeZonesError>) -> Result<(), fidl::Error> {
989        let _result = self.send_raw(result);
990        if _result.is_err() {
991            self.control_handle.shutdown();
992        }
993        self.drop_without_shutdown();
994        _result
995    }
996
997    /// Similar to "send" but does not shutdown the channel if an error occurs.
998    pub fn send_no_shutdown_on_err(
999        self,
1000        mut result: Result<i64, TimeZonesError>,
1001    ) -> Result<(), fidl::Error> {
1002        let _result = self.send_raw(result);
1003        self.drop_without_shutdown();
1004        _result
1005    }
1006
1007    fn send_raw(&self, mut result: Result<i64, TimeZonesError>) -> Result<(), fidl::Error> {
1008        self.control_handle.inner.send::<fidl::encoding::ResultType<
1009            TimeZonesCivilToAbsoluteTimeResponse,
1010            TimeZonesError,
1011        >>(
1012            result.map(|absolute_time| (absolute_time,)),
1013            self.tx_id,
1014            0xc1277c7a1413aa6,
1015            fidl::encoding::DynamicFlags::empty(),
1016        )
1017    }
1018}
1019
1020#[must_use = "FIDL methods require a response to be sent"]
1021#[derive(Debug)]
1022pub struct TimeZonesGetTimeZoneInfoResponder {
1023    control_handle: std::mem::ManuallyDrop<TimeZonesControlHandle>,
1024    tx_id: u32,
1025}
1026
1027/// Set the the channel to be shutdown (see [`TimeZonesControlHandle::shutdown`])
1028/// if the responder is dropped without sending a response, so that the client
1029/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1030impl std::ops::Drop for TimeZonesGetTimeZoneInfoResponder {
1031    fn drop(&mut self) {
1032        self.control_handle.shutdown();
1033        // Safety: drops once, never accessed again
1034        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1035    }
1036}
1037
1038impl fdomain_client::fidl::Responder for TimeZonesGetTimeZoneInfoResponder {
1039    type ControlHandle = TimeZonesControlHandle;
1040
1041    fn control_handle(&self) -> &TimeZonesControlHandle {
1042        &self.control_handle
1043    }
1044
1045    fn drop_without_shutdown(mut self) {
1046        // Safety: drops once, never accessed again due to mem::forget
1047        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1048        // Prevent Drop from running (which would shut down the channel)
1049        std::mem::forget(self);
1050    }
1051}
1052
1053impl TimeZonesGetTimeZoneInfoResponder {
1054    /// Sends a response to the FIDL transaction.
1055    ///
1056    /// Sets the channel to shutdown if an error occurs.
1057    pub fn send(
1058        self,
1059        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1060    ) -> Result<(), fidl::Error> {
1061        let _result = self.send_raw(result);
1062        if _result.is_err() {
1063            self.control_handle.shutdown();
1064        }
1065        self.drop_without_shutdown();
1066        _result
1067    }
1068
1069    /// Similar to "send" but does not shutdown the channel if an error occurs.
1070    pub fn send_no_shutdown_on_err(
1071        self,
1072        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1073    ) -> Result<(), fidl::Error> {
1074        let _result = self.send_raw(result);
1075        self.drop_without_shutdown();
1076        _result
1077    }
1078
1079    fn send_raw(
1080        &self,
1081        mut result: Result<&TimeZoneInfo, TimeZonesError>,
1082    ) -> Result<(), fidl::Error> {
1083        self.control_handle.inner.send::<fidl::encoding::ResultType<
1084            TimeZonesGetTimeZoneInfoResponse,
1085            TimeZonesError,
1086        >>(
1087            result.map(|time_zone_info| (time_zone_info,)),
1088            self.tx_id,
1089            0x2144cbac1d76fe65,
1090            fidl::encoding::DynamicFlags::empty(),
1091        )
1092    }
1093}
1094
1095mod internal {
1096    use super::*;
1097}