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"))]
62unsafe impl NSCoding for NSRelativeDateTimeFormatter {}
63
64#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
65unsafe impl NSCopying for NSRelativeDateTimeFormatter {}
66
67#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
68unsafe impl CopyingHelper for NSRelativeDateTimeFormatter {
69    type Result = Self;
70}
71
72#[cfg(feature = "NSFormatter")]
73unsafe impl NSObjectProtocol for NSRelativeDateTimeFormatter {}
74
75#[cfg(feature = "NSFormatter")]
76impl NSRelativeDateTimeFormatter {
77    extern_methods!(
78        #[unsafe(method(dateTimeStyle))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn dateTimeStyle(&self) -> NSRelativeDateTimeFormatterStyle;
81
82        /// Setter for [`dateTimeStyle`][Self::dateTimeStyle].
83        #[unsafe(method(setDateTimeStyle:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn setDateTimeStyle(&self, date_time_style: NSRelativeDateTimeFormatterStyle);
86
87        #[unsafe(method(unitsStyle))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn unitsStyle(&self) -> NSRelativeDateTimeFormatterUnitsStyle;
90
91        /// Setter for [`unitsStyle`][Self::unitsStyle].
92        #[unsafe(method(setUnitsStyle:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn setUnitsStyle(&self, units_style: NSRelativeDateTimeFormatterUnitsStyle);
95
96        #[unsafe(method(formattingContext))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn formattingContext(&self) -> NSFormattingContext;
99
100        /// Setter for [`formattingContext`][Self::formattingContext].
101        #[unsafe(method(setFormattingContext:))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn setFormattingContext(&self, formatting_context: NSFormattingContext);
104
105        #[cfg(feature = "NSCalendar")]
106        #[unsafe(method(calendar))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn calendar(&self) -> Retained<NSCalendar>;
109
110        #[cfg(feature = "NSCalendar")]
111        /// Setter for [`calendar`][Self::calendar].
112        #[unsafe(method(setCalendar:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn setCalendar(&self, calendar: Option<&NSCalendar>);
115
116        #[cfg(feature = "NSLocale")]
117        #[unsafe(method(locale))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn locale(&self) -> Retained<NSLocale>;
120
121        #[cfg(feature = "NSLocale")]
122        /// Setter for [`locale`][Self::locale].
123        #[unsafe(method(setLocale:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setLocale(&self, locale: Option<&NSLocale>);
126
127        #[cfg(all(feature = "NSCalendar", feature = "NSString"))]
128        #[unsafe(method(localizedStringFromDateComponents:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn localizedStringFromDateComponents(
131            &self,
132            date_components: &NSDateComponents,
133        ) -> Retained<NSString>;
134
135        #[cfg(all(feature = "NSDate", feature = "NSString"))]
136        #[unsafe(method(localizedStringFromTimeInterval:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn localizedStringFromTimeInterval(
139            &self,
140            time_interval: NSTimeInterval,
141        ) -> Retained<NSString>;
142
143        #[cfg(all(feature = "NSDate", feature = "NSString"))]
144        #[unsafe(method(localizedStringForDate:relativeToDate:))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn localizedStringForDate_relativeToDate(
147            &self,
148            date: &NSDate,
149            reference_date: &NSDate,
150        ) -> Retained<NSString>;
151
152        #[cfg(feature = "NSString")]
153        #[unsafe(method(stringForObjectValue:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn stringForObjectValue(
156            &self,
157            obj: Option<&AnyObject>,
158        ) -> Option<Retained<NSString>>;
159    );
160}
161
162/// Methods declared on superclass `NSObject`.
163#[cfg(feature = "NSFormatter")]
164impl NSRelativeDateTimeFormatter {
165    extern_methods!(
166        #[unsafe(method(init))]
167        #[unsafe(method_family = init)]
168        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
169
170        #[unsafe(method(new))]
171        #[unsafe(method_family = new)]
172        pub unsafe fn new() -> Retained<Self>;
173    );
174}