fidl_fuchsia_intl/
fidl_fuchsia_intl.rs

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