objc2_core_foundation/generated/
CFTimeZone.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7
8use crate::*;
9
10#[cfg(all(feature = "CFBase", feature = "CFDate"))]
11unsafe impl ConcreteType for CFTimeZone {
12    #[doc(alias = "CFTimeZoneGetTypeID")]
13    #[inline]
14    fn type_id() -> CFTypeID {
15        extern "C-unwind" {
16            fn CFTimeZoneGetTypeID() -> CFTypeID;
17        }
18        unsafe { CFTimeZoneGetTypeID() }
19    }
20}
21
22#[cfg(feature = "CFDate")]
23#[inline]
24pub unsafe extern "C-unwind" fn CFTimeZoneCopySystem() -> Option<CFRetained<CFTimeZone>> {
25    extern "C-unwind" {
26        fn CFTimeZoneCopySystem() -> Option<NonNull<CFTimeZone>>;
27    }
28    let ret = unsafe { CFTimeZoneCopySystem() };
29    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
30}
31
32extern "C-unwind" {
33    pub fn CFTimeZoneResetSystem();
34}
35
36#[cfg(feature = "CFDate")]
37#[inline]
38pub unsafe extern "C-unwind" fn CFTimeZoneCopyDefault() -> Option<CFRetained<CFTimeZone>> {
39    extern "C-unwind" {
40        fn CFTimeZoneCopyDefault() -> Option<NonNull<CFTimeZone>>;
41    }
42    let ret = unsafe { CFTimeZoneCopyDefault() };
43    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
44}
45
46extern "C-unwind" {
47    #[cfg(feature = "CFDate")]
48    pub fn CFTimeZoneSetDefault(tz: &CFTimeZone);
49}
50
51#[cfg(feature = "CFArray")]
52#[inline]
53pub unsafe extern "C-unwind" fn CFTimeZoneCopyKnownNames() -> Option<CFRetained<CFArray>> {
54    extern "C-unwind" {
55        fn CFTimeZoneCopyKnownNames() -> Option<NonNull<CFArray>>;
56    }
57    let ret = unsafe { CFTimeZoneCopyKnownNames() };
58    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
59}
60
61#[cfg(feature = "CFDictionary")]
62#[inline]
63pub unsafe extern "C-unwind" fn CFTimeZoneCopyAbbreviationDictionary(
64) -> Option<CFRetained<CFDictionary>> {
65    extern "C-unwind" {
66        fn CFTimeZoneCopyAbbreviationDictionary() -> Option<NonNull<CFDictionary>>;
67    }
68    let ret = unsafe { CFTimeZoneCopyAbbreviationDictionary() };
69    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
70}
71
72extern "C-unwind" {
73    #[cfg(feature = "CFDictionary")]
74    pub fn CFTimeZoneSetAbbreviationDictionary(dict: Option<&CFDictionary>);
75}
76
77#[cfg(all(feature = "CFBase", feature = "CFData", feature = "CFDate"))]
78#[inline]
79pub unsafe extern "C-unwind" fn CFTimeZoneCreate(
80    allocator: Option<&CFAllocator>,
81    name: Option<&CFString>,
82    data: Option<&CFData>,
83) -> Option<CFRetained<CFTimeZone>> {
84    extern "C-unwind" {
85        fn CFTimeZoneCreate(
86            allocator: Option<&CFAllocator>,
87            name: Option<&CFString>,
88            data: Option<&CFData>,
89        ) -> Option<NonNull<CFTimeZone>>;
90    }
91    let ret = unsafe { CFTimeZoneCreate(allocator, name, data) };
92    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
93}
94
95#[cfg(all(feature = "CFBase", feature = "CFDate"))]
96#[inline]
97pub unsafe extern "C-unwind" fn CFTimeZoneCreateWithTimeIntervalFromGMT(
98    allocator: Option<&CFAllocator>,
99    ti: CFTimeInterval,
100) -> Option<CFRetained<CFTimeZone>> {
101    extern "C-unwind" {
102        fn CFTimeZoneCreateWithTimeIntervalFromGMT(
103            allocator: Option<&CFAllocator>,
104            ti: CFTimeInterval,
105        ) -> Option<NonNull<CFTimeZone>>;
106    }
107    let ret = unsafe { CFTimeZoneCreateWithTimeIntervalFromGMT(allocator, ti) };
108    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
109}
110
111#[cfg(all(feature = "CFBase", feature = "CFDate"))]
112#[inline]
113pub unsafe extern "C-unwind" fn CFTimeZoneCreateWithName(
114    allocator: Option<&CFAllocator>,
115    name: Option<&CFString>,
116    try_abbrev: bool,
117) -> Option<CFRetained<CFTimeZone>> {
118    extern "C-unwind" {
119        fn CFTimeZoneCreateWithName(
120            allocator: Option<&CFAllocator>,
121            name: Option<&CFString>,
122            try_abbrev: Boolean,
123        ) -> Option<NonNull<CFTimeZone>>;
124    }
125    let ret = unsafe { CFTimeZoneCreateWithName(allocator, name, try_abbrev as _) };
126    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
127}
128
129#[cfg(all(feature = "CFBase", feature = "CFDate"))]
130#[inline]
131pub unsafe extern "C-unwind" fn CFTimeZoneGetName(tz: &CFTimeZone) -> Option<CFRetained<CFString>> {
132    extern "C-unwind" {
133        fn CFTimeZoneGetName(tz: &CFTimeZone) -> Option<NonNull<CFString>>;
134    }
135    let ret = unsafe { CFTimeZoneGetName(tz) };
136    ret.map(|ret| unsafe { CFRetained::retain(ret) })
137}
138
139#[cfg(all(feature = "CFData", feature = "CFDate"))]
140#[inline]
141pub unsafe extern "C-unwind" fn CFTimeZoneGetData(tz: &CFTimeZone) -> Option<CFRetained<CFData>> {
142    extern "C-unwind" {
143        fn CFTimeZoneGetData(tz: &CFTimeZone) -> Option<NonNull<CFData>>;
144    }
145    let ret = unsafe { CFTimeZoneGetData(tz) };
146    ret.map(|ret| unsafe { CFRetained::retain(ret) })
147}
148
149extern "C-unwind" {
150    #[cfg(feature = "CFDate")]
151    pub fn CFTimeZoneGetSecondsFromGMT(tz: &CFTimeZone, at: CFAbsoluteTime) -> CFTimeInterval;
152}
153
154#[cfg(all(feature = "CFBase", feature = "CFDate"))]
155#[inline]
156pub unsafe extern "C-unwind" fn CFTimeZoneCopyAbbreviation(
157    tz: &CFTimeZone,
158    at: CFAbsoluteTime,
159) -> Option<CFRetained<CFString>> {
160    extern "C-unwind" {
161        fn CFTimeZoneCopyAbbreviation(
162            tz: &CFTimeZone,
163            at: CFAbsoluteTime,
164        ) -> Option<NonNull<CFString>>;
165    }
166    let ret = unsafe { CFTimeZoneCopyAbbreviation(tz, at) };
167    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
168}
169
170#[cfg(feature = "CFDate")]
171#[inline]
172pub unsafe extern "C-unwind" fn CFTimeZoneIsDaylightSavingTime(
173    tz: &CFTimeZone,
174    at: CFAbsoluteTime,
175) -> bool {
176    extern "C-unwind" {
177        fn CFTimeZoneIsDaylightSavingTime(tz: &CFTimeZone, at: CFAbsoluteTime) -> Boolean;
178    }
179    let ret = unsafe { CFTimeZoneIsDaylightSavingTime(tz, at) };
180    ret != 0
181}
182
183extern "C-unwind" {
184    #[cfg(feature = "CFDate")]
185    pub fn CFTimeZoneGetDaylightSavingTimeOffset(
186        tz: &CFTimeZone,
187        at: CFAbsoluteTime,
188    ) -> CFTimeInterval;
189}
190
191extern "C-unwind" {
192    #[cfg(feature = "CFDate")]
193    pub fn CFTimeZoneGetNextDaylightSavingTimeTransition(
194        tz: &CFTimeZone,
195        at: CFAbsoluteTime,
196    ) -> CFAbsoluteTime;
197}
198
199/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cftimezonenamestyle?language=objc)
200// NS_ENUM
201#[cfg(feature = "CFBase")]
202#[repr(transparent)]
203#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
204pub struct CFTimeZoneNameStyle(pub CFIndex);
205#[cfg(feature = "CFBase")]
206impl CFTimeZoneNameStyle {
207    #[doc(alias = "kCFTimeZoneNameStyleStandard")]
208    pub const Standard: Self = Self(0);
209    #[doc(alias = "kCFTimeZoneNameStyleShortStandard")]
210    pub const ShortStandard: Self = Self(1);
211    #[doc(alias = "kCFTimeZoneNameStyleDaylightSaving")]
212    pub const DaylightSaving: Self = Self(2);
213    #[doc(alias = "kCFTimeZoneNameStyleShortDaylightSaving")]
214    pub const ShortDaylightSaving: Self = Self(3);
215    #[doc(alias = "kCFTimeZoneNameStyleGeneric")]
216    pub const Generic: Self = Self(4);
217    #[doc(alias = "kCFTimeZoneNameStyleShortGeneric")]
218    pub const ShortGeneric: Self = Self(5);
219}
220
221#[cfg(all(feature = "CFBase", feature = "objc2"))]
222unsafe impl Encode for CFTimeZoneNameStyle {
223    const ENCODING: Encoding = CFIndex::ENCODING;
224}
225
226#[cfg(all(feature = "CFBase", feature = "objc2"))]
227unsafe impl RefEncode for CFTimeZoneNameStyle {
228    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
229}
230
231#[cfg(all(feature = "CFBase", feature = "CFDate", feature = "CFLocale"))]
232#[inline]
233pub unsafe extern "C-unwind" fn CFTimeZoneCopyLocalizedName(
234    tz: &CFTimeZone,
235    style: CFTimeZoneNameStyle,
236    locale: Option<&CFLocale>,
237) -> Option<CFRetained<CFString>> {
238    extern "C-unwind" {
239        fn CFTimeZoneCopyLocalizedName(
240            tz: &CFTimeZone,
241            style: CFTimeZoneNameStyle,
242            locale: Option<&CFLocale>,
243        ) -> Option<NonNull<CFString>>;
244    }
245    let ret = unsafe { CFTimeZoneCopyLocalizedName(tz, style, locale) };
246    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
247}
248
249extern "C" {
250    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcftimezonesystemtimezonedidchangenotification?language=objc)
251    #[cfg(all(feature = "CFBase", feature = "CFNotificationCenter"))]
252    pub static kCFTimeZoneSystemTimeZoneDidChangeNotification: Option<&'static CFNotificationName>;
253}