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