objc2_foundation/generated/
NSPersonNameComponentsFormatter.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/nspersonnamecomponentsformatterstyle?language=objc)
10// NS_ENUM
11#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct NSPersonNameComponentsFormatterStyle(pub NSInteger);
14impl NSPersonNameComponentsFormatterStyle {
15    #[doc(alias = "NSPersonNameComponentsFormatterStyleDefault")]
16    pub const Default: Self = Self(0);
17    #[doc(alias = "NSPersonNameComponentsFormatterStyleShort")]
18    pub const Short: Self = Self(1);
19    #[doc(alias = "NSPersonNameComponentsFormatterStyleMedium")]
20    pub const Medium: Self = Self(2);
21    #[doc(alias = "NSPersonNameComponentsFormatterStyleLong")]
22    pub const Long: Self = Self(3);
23    #[doc(alias = "NSPersonNameComponentsFormatterStyleAbbreviated")]
24    pub const Abbreviated: Self = Self(4);
25}
26
27unsafe impl Encode for NSPersonNameComponentsFormatterStyle {
28    const ENCODING: Encoding = NSInteger::ENCODING;
29}
30
31unsafe impl RefEncode for NSPersonNameComponentsFormatterStyle {
32    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentsformatteroptions?language=objc)
36// NS_OPTIONS
37#[repr(transparent)]
38#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
39pub struct NSPersonNameComponentsFormatterOptions(pub NSUInteger);
40bitflags::bitflags! {
41    impl NSPersonNameComponentsFormatterOptions: NSUInteger {
42        #[doc(alias = "NSPersonNameComponentsFormatterPhonetic")]
43        const Phonetic = 1<<1;
44    }
45}
46
47unsafe impl Encode for NSPersonNameComponentsFormatterOptions {
48    const ENCODING: Encoding = NSUInteger::ENCODING;
49}
50
51unsafe impl RefEncode for NSPersonNameComponentsFormatterOptions {
52    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
53}
54
55extern_class!(
56    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentsformatter?language=objc)
57    #[unsafe(super(NSFormatter, NSObject))]
58    #[derive(Debug, PartialEq, Eq, Hash)]
59    #[cfg(feature = "NSFormatter")]
60    pub struct NSPersonNameComponentsFormatter;
61);
62
63#[cfg(feature = "NSFormatter")]
64unsafe impl Send for NSPersonNameComponentsFormatter {}
65
66#[cfg(feature = "NSFormatter")]
67unsafe impl Sync for NSPersonNameComponentsFormatter {}
68
69#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
70extern_conformance!(
71    unsafe impl NSCoding for NSPersonNameComponentsFormatter {}
72);
73
74#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
75extern_conformance!(
76    unsafe impl NSCopying for NSPersonNameComponentsFormatter {}
77);
78
79#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
80unsafe impl CopyingHelper for NSPersonNameComponentsFormatter {
81    type Result = Self;
82}
83
84#[cfg(feature = "NSFormatter")]
85extern_conformance!(
86    unsafe impl NSObjectProtocol for NSPersonNameComponentsFormatter {}
87);
88
89#[cfg(feature = "NSFormatter")]
90impl NSPersonNameComponentsFormatter {
91    extern_methods!(
92        #[unsafe(method(style))]
93        #[unsafe(method_family = none)]
94        pub fn style(&self) -> NSPersonNameComponentsFormatterStyle;
95
96        /// Setter for [`style`][Self::style].
97        #[unsafe(method(setStyle:))]
98        #[unsafe(method_family = none)]
99        pub fn setStyle(&self, style: NSPersonNameComponentsFormatterStyle);
100
101        #[unsafe(method(isPhonetic))]
102        #[unsafe(method_family = none)]
103        pub fn isPhonetic(&self) -> bool;
104
105        /// Setter for [`isPhonetic`][Self::isPhonetic].
106        #[unsafe(method(setPhonetic:))]
107        #[unsafe(method_family = none)]
108        pub fn setPhonetic(&self, phonetic: bool);
109
110        #[cfg(feature = "NSLocale")]
111        #[unsafe(method(locale))]
112        #[unsafe(method_family = none)]
113        pub fn locale(&self) -> Retained<NSLocale>;
114
115        #[cfg(feature = "NSLocale")]
116        /// Setter for [`locale`][Self::locale].
117        ///
118        /// This is [copied][crate::NSCopying::copy] when set.
119        #[unsafe(method(setLocale:))]
120        #[unsafe(method_family = none)]
121        pub fn setLocale(&self, locale: Option<&NSLocale>);
122
123        #[cfg(all(feature = "NSPersonNameComponents", feature = "NSString"))]
124        #[unsafe(method(localizedStringFromPersonNameComponents:style:options:))]
125        #[unsafe(method_family = none)]
126        pub fn localizedStringFromPersonNameComponents_style_options(
127            components: &NSPersonNameComponents,
128            name_format_style: NSPersonNameComponentsFormatterStyle,
129            name_options: NSPersonNameComponentsFormatterOptions,
130        ) -> Retained<NSString>;
131
132        #[cfg(all(feature = "NSPersonNameComponents", feature = "NSString"))]
133        #[unsafe(method(stringFromPersonNameComponents:))]
134        #[unsafe(method_family = none)]
135        pub fn stringFromPersonNameComponents(
136            &self,
137            components: &NSPersonNameComponents,
138        ) -> Retained<NSString>;
139
140        #[cfg(all(feature = "NSAttributedString", feature = "NSPersonNameComponents"))]
141        #[unsafe(method(annotatedStringFromPersonNameComponents:))]
142        #[unsafe(method_family = none)]
143        pub fn annotatedStringFromPersonNameComponents(
144            &self,
145            components: &NSPersonNameComponents,
146        ) -> Retained<NSAttributedString>;
147
148        #[cfg(all(feature = "NSPersonNameComponents", feature = "NSString"))]
149        #[unsafe(method(personNameComponentsFromString:))]
150        #[unsafe(method_family = none)]
151        pub fn personNameComponentsFromString(
152            &self,
153            string: &NSString,
154        ) -> Option<Retained<NSPersonNameComponents>>;
155
156        #[cfg(feature = "NSString")]
157        /// # Safety
158        ///
159        /// `obj` should be of the correct type.
160        #[unsafe(method(getObjectValue:forString:errorDescription:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn getObjectValue_forString_errorDescription(
163            &self,
164            obj: Option<&mut Option<Retained<AnyObject>>>,
165            string: &NSString,
166            error: Option<&mut Option<Retained<NSString>>>,
167        ) -> bool;
168    );
169}
170
171/// Methods declared on superclass `NSObject`.
172#[cfg(feature = "NSFormatter")]
173impl NSPersonNameComponentsFormatter {
174    extern_methods!(
175        #[unsafe(method(init))]
176        #[unsafe(method_family = init)]
177        pub fn init(this: Allocated<Self>) -> Retained<Self>;
178
179        #[unsafe(method(new))]
180        #[unsafe(method_family = new)]
181        pub fn new() -> Retained<Self>;
182    );
183}
184
185#[cfg(feature = "NSFormatter")]
186impl DefaultRetained for NSPersonNameComponentsFormatter {
187    #[inline]
188    fn default_retained() -> Retained<Self> {
189        Self::new()
190    }
191}
192
193extern "C" {
194    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentkey?language=objc)
195    #[cfg(feature = "NSString")]
196    pub static NSPersonNameComponentKey: &'static NSString;
197}
198
199extern "C" {
200    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentgivenname?language=objc)
201    #[cfg(feature = "NSString")]
202    pub static NSPersonNameComponentGivenName: &'static NSString;
203}
204
205extern "C" {
206    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentfamilyname?language=objc)
207    #[cfg(feature = "NSString")]
208    pub static NSPersonNameComponentFamilyName: &'static NSString;
209}
210
211extern "C" {
212    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentmiddlename?language=objc)
213    #[cfg(feature = "NSString")]
214    pub static NSPersonNameComponentMiddleName: &'static NSString;
215}
216
217extern "C" {
218    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentprefix?language=objc)
219    #[cfg(feature = "NSString")]
220    pub static NSPersonNameComponentPrefix: &'static NSString;
221}
222
223extern "C" {
224    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentsuffix?language=objc)
225    #[cfg(feature = "NSString")]
226    pub static NSPersonNameComponentSuffix: &'static NSString;
227}
228
229extern "C" {
230    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentnickname?language=objc)
231    #[cfg(feature = "NSString")]
232    pub static NSPersonNameComponentNickname: &'static NSString;
233}
234
235extern "C" {
236    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspersonnamecomponentdelimiter?language=objc)
237    #[cfg(feature = "NSString")]
238    pub static NSPersonNameComponentDelimiter: &'static NSString;
239}