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