objc2_foundation/generated/
NSRelativeDateTimeFormatter.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrelativedatetimeformatterstyle?language=objc)
10// NS_ENUM
11#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct NSRelativeDateTimeFormatterStyle(pub NSInteger);
14impl NSRelativeDateTimeFormatterStyle {
15    #[doc(alias = "NSRelativeDateTimeFormatterStyleNumeric")]
16    pub const Numeric: Self = Self(0);
17    #[doc(alias = "NSRelativeDateTimeFormatterStyleNamed")]
18    pub const Named: Self = Self(1);
19}
20
21unsafe impl Encode for NSRelativeDateTimeFormatterStyle {
22    const ENCODING: Encoding = NSInteger::ENCODING;
23}
24
25unsafe impl RefEncode for NSRelativeDateTimeFormatterStyle {
26    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
27}
28
29/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrelativedatetimeformatterunitsstyle?language=objc)
30// NS_ENUM
31#[repr(transparent)]
32#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
33pub struct NSRelativeDateTimeFormatterUnitsStyle(pub NSInteger);
34impl NSRelativeDateTimeFormatterUnitsStyle {
35    #[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleFull")]
36    pub const Full: Self = Self(0);
37    #[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleSpellOut")]
38    pub const SpellOut: Self = Self(1);
39    #[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleShort")]
40    pub const Short: Self = Self(2);
41    #[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleAbbreviated")]
42    pub const Abbreviated: Self = Self(3);
43}
44
45unsafe impl Encode for NSRelativeDateTimeFormatterUnitsStyle {
46    const ENCODING: Encoding = NSInteger::ENCODING;
47}
48
49unsafe impl RefEncode for NSRelativeDateTimeFormatterUnitsStyle {
50    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
51}
52
53extern_class!(
54    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrelativedatetimeformatter?language=objc)
55    #[unsafe(super(NSFormatter, NSObject))]
56    #[derive(Debug, PartialEq, Eq, Hash)]
57    #[cfg(feature = "NSFormatter")]
58    pub struct NSRelativeDateTimeFormatter;
59);
60
61#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
62extern_conformance!(
63    unsafe impl NSCoding for NSRelativeDateTimeFormatter {}
64);
65
66#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
67extern_conformance!(
68    unsafe impl NSCopying for NSRelativeDateTimeFormatter {}
69);
70
71#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
72unsafe impl CopyingHelper for NSRelativeDateTimeFormatter {
73    type Result = Self;
74}
75
76#[cfg(feature = "NSFormatter")]
77extern_conformance!(
78    unsafe impl NSObjectProtocol for NSRelativeDateTimeFormatter {}
79);
80
81#[cfg(feature = "NSFormatter")]
82impl NSRelativeDateTimeFormatter {
83    extern_methods!(
84        #[unsafe(method(dateTimeStyle))]
85        #[unsafe(method_family = none)]
86        pub fn dateTimeStyle(&self) -> NSRelativeDateTimeFormatterStyle;
87
88        /// Setter for [`dateTimeStyle`][Self::dateTimeStyle].
89        #[unsafe(method(setDateTimeStyle:))]
90        #[unsafe(method_family = none)]
91        pub fn setDateTimeStyle(&self, date_time_style: NSRelativeDateTimeFormatterStyle);
92
93        #[unsafe(method(unitsStyle))]
94        #[unsafe(method_family = none)]
95        pub fn unitsStyle(&self) -> NSRelativeDateTimeFormatterUnitsStyle;
96
97        /// Setter for [`unitsStyle`][Self::unitsStyle].
98        #[unsafe(method(setUnitsStyle:))]
99        #[unsafe(method_family = none)]
100        pub fn setUnitsStyle(&self, units_style: NSRelativeDateTimeFormatterUnitsStyle);
101
102        #[unsafe(method(formattingContext))]
103        #[unsafe(method_family = none)]
104        pub fn formattingContext(&self) -> NSFormattingContext;
105
106        /// Setter for [`formattingContext`][Self::formattingContext].
107        #[unsafe(method(setFormattingContext:))]
108        #[unsafe(method_family = none)]
109        pub fn setFormattingContext(&self, formatting_context: NSFormattingContext);
110
111        #[cfg(feature = "NSCalendar")]
112        #[unsafe(method(calendar))]
113        #[unsafe(method_family = none)]
114        pub fn calendar(&self) -> Retained<NSCalendar>;
115
116        #[cfg(feature = "NSCalendar")]
117        /// Setter for [`calendar`][Self::calendar].
118        ///
119        /// This is [copied][crate::NSCopying::copy] when set.
120        #[unsafe(method(setCalendar:))]
121        #[unsafe(method_family = none)]
122        pub fn setCalendar(&self, calendar: Option<&NSCalendar>);
123
124        #[cfg(feature = "NSLocale")]
125        #[unsafe(method(locale))]
126        #[unsafe(method_family = none)]
127        pub fn locale(&self) -> Retained<NSLocale>;
128
129        #[cfg(feature = "NSLocale")]
130        /// Setter for [`locale`][Self::locale].
131        ///
132        /// This is [copied][crate::NSCopying::copy] when set.
133        #[unsafe(method(setLocale:))]
134        #[unsafe(method_family = none)]
135        pub fn setLocale(&self, locale: Option<&NSLocale>);
136
137        #[cfg(all(feature = "NSCalendar", feature = "NSString"))]
138        #[unsafe(method(localizedStringFromDateComponents:))]
139        #[unsafe(method_family = none)]
140        pub fn localizedStringFromDateComponents(
141            &self,
142            date_components: &NSDateComponents,
143        ) -> Retained<NSString>;
144
145        #[cfg(all(feature = "NSDate", feature = "NSString"))]
146        #[unsafe(method(localizedStringFromTimeInterval:))]
147        #[unsafe(method_family = none)]
148        pub fn localizedStringFromTimeInterval(
149            &self,
150            time_interval: NSTimeInterval,
151        ) -> Retained<NSString>;
152
153        #[cfg(all(feature = "NSDate", feature = "NSString"))]
154        #[unsafe(method(localizedStringForDate:relativeToDate:))]
155        #[unsafe(method_family = none)]
156        pub fn localizedStringForDate_relativeToDate(
157            &self,
158            date: &NSDate,
159            reference_date: &NSDate,
160        ) -> Retained<NSString>;
161
162        #[cfg(feature = "NSString")]
163        /// # Safety
164        ///
165        /// `obj` should be of the correct type.
166        #[unsafe(method(stringForObjectValue:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn stringForObjectValue(
169            &self,
170            obj: Option<&AnyObject>,
171        ) -> Option<Retained<NSString>>;
172    );
173}
174
175/// Methods declared on superclass `NSObject`.
176#[cfg(feature = "NSFormatter")]
177impl NSRelativeDateTimeFormatter {
178    extern_methods!(
179        #[unsafe(method(init))]
180        #[unsafe(method_family = init)]
181        pub fn init(this: Allocated<Self>) -> Retained<Self>;
182
183        #[unsafe(method(new))]
184        #[unsafe(method_family = new)]
185        pub fn new() -> Retained<Self>;
186    );
187}
188
189#[cfg(feature = "NSFormatter")]
190impl DefaultRetained for NSRelativeDateTimeFormatter {
191    #[inline]
192    fn default_retained() -> Retained<Self> {
193        Self::new()
194    }
195}