objc2_foundation/generated/
NSFormatter.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5
6use crate::*;
7
8/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsformattingcontext?language=objc)
9// NS_ENUM
10#[repr(transparent)]
11#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
12pub struct NSFormattingContext(pub NSInteger);
13impl NSFormattingContext {
14    #[doc(alias = "NSFormattingContextUnknown")]
15    pub const Unknown: Self = Self(0);
16    #[doc(alias = "NSFormattingContextDynamic")]
17    pub const Dynamic: Self = Self(1);
18    #[doc(alias = "NSFormattingContextStandalone")]
19    pub const Standalone: Self = Self(2);
20    #[doc(alias = "NSFormattingContextListItem")]
21    pub const ListItem: Self = Self(3);
22    #[doc(alias = "NSFormattingContextBeginningOfSentence")]
23    pub const BeginningOfSentence: Self = Self(4);
24    #[doc(alias = "NSFormattingContextMiddleOfSentence")]
25    pub const MiddleOfSentence: Self = Self(5);
26}
27
28unsafe impl Encode for NSFormattingContext {
29    const ENCODING: Encoding = NSInteger::ENCODING;
30}
31
32unsafe impl RefEncode for NSFormattingContext {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsformattingunitstyle?language=objc)
37// NS_ENUM
38#[repr(transparent)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
40pub struct NSFormattingUnitStyle(pub NSInteger);
41impl NSFormattingUnitStyle {
42    #[doc(alias = "NSFormattingUnitStyleShort")]
43    pub const Short: Self = Self(1);
44    #[doc(alias = "NSFormattingUnitStyleMedium")]
45    pub const Medium: Self = Self(2);
46    #[doc(alias = "NSFormattingUnitStyleLong")]
47    pub const Long: Self = Self(3);
48}
49
50unsafe impl Encode for NSFormattingUnitStyle {
51    const ENCODING: Encoding = NSInteger::ENCODING;
52}
53
54unsafe impl RefEncode for NSFormattingUnitStyle {
55    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
56}
57
58extern_class!(
59    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsformatter?language=objc)
60    #[unsafe(super(NSObject))]
61    #[derive(Debug, PartialEq, Eq, Hash)]
62    pub struct NSFormatter;
63);
64
65#[cfg(feature = "NSObject")]
66extern_conformance!(
67    unsafe impl NSCoding for NSFormatter {}
68);
69
70#[cfg(feature = "NSObject")]
71extern_conformance!(
72    unsafe impl NSCopying for NSFormatter {}
73);
74
75#[cfg(feature = "NSObject")]
76unsafe impl CopyingHelper for NSFormatter {
77    type Result = Self;
78}
79
80extern_conformance!(
81    unsafe impl NSObjectProtocol for NSFormatter {}
82);
83
84impl NSFormatter {
85    extern_methods!(
86        #[cfg(feature = "NSString")]
87        /// # Safety
88        ///
89        /// `obj` should be of the correct type.
90        #[unsafe(method(stringForObjectValue:))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn stringForObjectValue(
93            &self,
94            obj: Option<&AnyObject>,
95        ) -> Option<Retained<NSString>>;
96
97        #[cfg(all(
98            feature = "NSAttributedString",
99            feature = "NSDictionary",
100            feature = "NSString"
101        ))]
102        /// # Safety
103        ///
104        /// - `obj` should be of the correct type.
105        /// - `attrs` generic should be of the correct type.
106        #[unsafe(method(attributedStringForObjectValue:withDefaultAttributes:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn attributedStringForObjectValue_withDefaultAttributes(
109            &self,
110            obj: &AnyObject,
111            attrs: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
112        ) -> Option<Retained<NSAttributedString>>;
113
114        #[cfg(feature = "NSString")]
115        /// # Safety
116        ///
117        /// `obj` should be of the correct type.
118        #[unsafe(method(editingStringForObjectValue:))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn editingStringForObjectValue(
121            &self,
122            obj: &AnyObject,
123        ) -> Option<Retained<NSString>>;
124
125        #[cfg(feature = "NSString")]
126        /// # Safety
127        ///
128        /// `obj` should be of the correct type.
129        #[unsafe(method(getObjectValue:forString:errorDescription:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn getObjectValue_forString_errorDescription(
132            &self,
133            obj: Option<&mut Option<Retained<AnyObject>>>,
134            string: &NSString,
135            error: Option<&mut Option<Retained<NSString>>>,
136        ) -> bool;
137
138        #[cfg(feature = "NSString")]
139        #[unsafe(method(isPartialStringValid:newEditingString:errorDescription:))]
140        #[unsafe(method_family = none)]
141        pub fn isPartialStringValid_newEditingString_errorDescription(
142            &self,
143            partial_string: &NSString,
144            new_string: Option<&mut Option<Retained<NSString>>>,
145            error: Option<&mut Option<Retained<NSString>>>,
146        ) -> bool;
147
148        #[cfg(all(feature = "NSRange", feature = "NSString"))]
149        /// # Safety
150        ///
151        /// `proposed_sel_range_ptr` must be a valid pointer or null.
152        #[unsafe(method(isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn isPartialStringValid_proposedSelectedRange_originalString_originalSelectedRange_errorDescription(
155            &self,
156            partial_string_ptr: &mut Retained<NSString>,
157            proposed_sel_range_ptr: NSRangePointer,
158            orig_string: &NSString,
159            orig_sel_range: NSRange,
160            error: Option<&mut Option<Retained<NSString>>>,
161        ) -> bool;
162    );
163}
164
165/// Methods declared on superclass `NSObject`.
166impl NSFormatter {
167    extern_methods!(
168        #[unsafe(method(init))]
169        #[unsafe(method_family = init)]
170        pub fn init(this: Allocated<Self>) -> Retained<Self>;
171
172        #[unsafe(method(new))]
173        #[unsafe(method_family = new)]
174        pub fn new() -> Retained<Self>;
175    );
176}
177
178impl DefaultRetained for NSFormatter {
179    #[inline]
180    fn default_retained() -> Retained<Self> {
181        Self::new()
182    }
183}