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