1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
/// The formatting styles for postal addresses.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/contacts/cnpostaladdressformatterstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CNPostalAddressFormatterStyle(pub NSInteger);
impl CNPostalAddressFormatterStyle {
/// Combine the postal address components into a multi-line mailing address.
#[doc(alias = "CNPostalAddressFormatterStyleMailingAddress")]
pub const MailingAddress: Self = Self(0);
}
unsafe impl Encode for CNPostalAddressFormatterStyle {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for CNPostalAddressFormatterStyle {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// Formats a postal address.
///
///
/// This formatter handles international formatting of a postal address.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/contacts/cnpostaladdressformatter?language=objc)
#[unsafe(super(NSFormatter, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct CNPostalAddressFormatter;
);
extern_conformance!(
unsafe impl NSCoding for CNPostalAddressFormatter {}
);
extern_conformance!(
unsafe impl NSCopying for CNPostalAddressFormatter {}
);
unsafe impl CopyingHelper for CNPostalAddressFormatter {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for CNPostalAddressFormatter {}
);
impl CNPostalAddressFormatter {
extern_methods!(
#[cfg(feature = "CNPostalAddress")]
/// Formats the postal address.
///
///
/// Parameter `postalAddress`: The postal address to be formatted.
///
/// Parameter `style`: The formatting style to be used for the postal address.
///
/// Returns: The formatted postal address.
#[unsafe(method(stringFromPostalAddress:style:))]
#[unsafe(method_family = none)]
pub unsafe fn stringFromPostalAddress_style(
postal_address: &CNPostalAddress,
style: CNPostalAddressFormatterStyle,
) -> Retained<NSString>;
#[cfg(feature = "CNPostalAddress")]
/// Formats the postal address returning an attributed string.
///
///
/// This behaves like +stringFromPostalAddress: except it returns an attributed string. Includes attribute keys CNPostalAddressPropertyAttribute and CNPostalAddressLocalizedPropertyNameAttribute.
///
///
/// Parameter `postalAddress`: The postal address to be formatted.
///
/// Parameter `style`: The formatting style to be used for the postal address.
///
/// Parameter `attributes`: The default attributes to use. See NSFormatter for details.
///
/// Returns: The formatted postal address as an attributed string.
///
/// # Safety
///
/// `attributes` generic should be of the correct type.
#[unsafe(method(attributedStringFromPostalAddress:style:withDefaultAttributes:))]
#[unsafe(method_family = none)]
pub unsafe fn attributedStringFromPostalAddress_style_withDefaultAttributes(
postal_address: &CNPostalAddress,
style: CNPostalAddressFormatterStyle,
attributes: &NSDictionary,
) -> Retained<NSAttributedString>;
/// The style for a postal address formatter instance.
///
///
/// The default value is CNPostalAddressFormatterStyleMailingAddress.
#[unsafe(method(style))]
#[unsafe(method_family = none)]
pub unsafe fn style(&self) -> CNPostalAddressFormatterStyle;
/// Setter for [`style`][Self::style].
#[unsafe(method(setStyle:))]
#[unsafe(method_family = none)]
pub unsafe fn setStyle(&self, style: CNPostalAddressFormatterStyle);
#[cfg(feature = "CNPostalAddress")]
/// Formats the postal address.
///
///
/// Parameter `postalAddress`: The postal address to be formatted.
///
/// Returns: The formatted postal address.
#[unsafe(method(stringFromPostalAddress:))]
#[unsafe(method_family = none)]
pub unsafe fn stringFromPostalAddress(
&self,
postal_address: &CNPostalAddress,
) -> Retained<NSString>;
#[cfg(feature = "CNPostalAddress")]
/// Formats the postal address returning an attributed string.
///
///
/// This behaves like +stringFromPostalAddress: except it returns an attributed string. Includes attribute keys CNPostalAddressPropertyAttribute and CNPostalAddressLocalizedPropertyNameAttribute.
///
///
/// Parameter `postalAddress`: The postal address to be formatted.
///
/// Parameter `attributes`: The default attributes to use. See NSFormatter for details.
///
/// Returns: The formatted postal address as an attributed string.
///
/// # Safety
///
/// `attributes` generic should be of the correct type.
#[unsafe(method(attributedStringFromPostalAddress:withDefaultAttributes:))]
#[unsafe(method_family = none)]
pub unsafe fn attributedStringFromPostalAddress_withDefaultAttributes(
&self,
postal_address: &CNPostalAddress,
attributes: &NSDictionary,
) -> Retained<NSAttributedString>;
);
}
/// Methods declared on superclass `NSObject`.
impl CNPostalAddressFormatter {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnpostaladdresspropertyattribute?language=objc)
pub static CNPostalAddressPropertyAttribute: &'static NSString;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnpostaladdresslocalizedpropertynameattribute?language=objc)
pub static CNPostalAddressLocalizedPropertyNameAttribute: &'static NSString;
}