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
43extern_conformance!(
44 unsafe impl NSCoding for CNPostalAddressFormatter {}
45);
46
47extern_conformance!(
48 unsafe impl NSCopying for CNPostalAddressFormatter {}
49);
50
51unsafe impl CopyingHelper for CNPostalAddressFormatter {
52 type Result = Self;
53}
54
55extern_conformance!(
56 unsafe impl NSObjectProtocol for CNPostalAddressFormatter {}
57);
58
59impl CNPostalAddressFormatter {
60 extern_methods!(
61 #[cfg(feature = "CNPostalAddress")]
62 /// Formats the postal address.
63 ///
64 ///
65 /// Parameter `postalAddress`: The postal address to be formatted.
66 ///
67 /// Parameter `style`: The formatting style to be used for the postal address.
68 ///
69 /// Returns: The formatted postal address.
70 #[unsafe(method(stringFromPostalAddress:style:))]
71 #[unsafe(method_family = none)]
72 pub unsafe fn stringFromPostalAddress_style(
73 postal_address: &CNPostalAddress,
74 style: CNPostalAddressFormatterStyle,
75 ) -> Retained<NSString>;
76
77 #[cfg(feature = "CNPostalAddress")]
78 /// Formats the postal address returning an attributed string.
79 ///
80 ///
81 /// This behaves like +stringFromPostalAddress: except it returns an attributed string. Includes attribute keys CNPostalAddressPropertyAttribute and CNPostalAddressLocalizedPropertyNameAttribute.
82 ///
83 ///
84 /// Parameter `postalAddress`: The postal address to be formatted.
85 ///
86 /// Parameter `style`: The formatting style to be used for the postal address.
87 ///
88 /// Parameter `attributes`: The default attributes to use. See NSFormatter for details.
89 ///
90 /// Returns: The formatted postal address as an attributed string.
91 #[unsafe(method(attributedStringFromPostalAddress:style:withDefaultAttributes:))]
92 #[unsafe(method_family = none)]
93 pub unsafe fn attributedStringFromPostalAddress_style_withDefaultAttributes(
94 postal_address: &CNPostalAddress,
95 style: CNPostalAddressFormatterStyle,
96 attributes: &NSDictionary,
97 ) -> Retained<NSAttributedString>;
98
99 /// The style for a postal address formatter instance.
100 ///
101 ///
102 /// The default value is CNPostalAddressFormatterStyleMailingAddress.
103 #[unsafe(method(style))]
104 #[unsafe(method_family = none)]
105 pub unsafe fn style(&self) -> CNPostalAddressFormatterStyle;
106
107 /// Setter for [`style`][Self::style].
108 #[unsafe(method(setStyle:))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn setStyle(&self, style: CNPostalAddressFormatterStyle);
111
112 #[cfg(feature = "CNPostalAddress")]
113 /// Formats the postal address.
114 ///
115 ///
116 /// Parameter `postalAddress`: The postal address to be formatted.
117 ///
118 /// Returns: The formatted postal address.
119 #[unsafe(method(stringFromPostalAddress:))]
120 #[unsafe(method_family = none)]
121 pub unsafe fn stringFromPostalAddress(
122 &self,
123 postal_address: &CNPostalAddress,
124 ) -> Retained<NSString>;
125
126 #[cfg(feature = "CNPostalAddress")]
127 /// Formats the postal address returning an attributed string.
128 ///
129 ///
130 /// This behaves like +stringFromPostalAddress: except it returns an attributed string. Includes attribute keys CNPostalAddressPropertyAttribute and CNPostalAddressLocalizedPropertyNameAttribute.
131 ///
132 ///
133 /// Parameter `postalAddress`: The postal address to be formatted.
134 ///
135 /// Parameter `attributes`: The default attributes to use. See NSFormatter for details.
136 ///
137 /// Returns: The formatted postal address as an attributed string.
138 #[unsafe(method(attributedStringFromPostalAddress:withDefaultAttributes:))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn attributedStringFromPostalAddress_withDefaultAttributes(
141 &self,
142 postal_address: &CNPostalAddress,
143 attributes: &NSDictionary,
144 ) -> Retained<NSAttributedString>;
145 );
146}
147
148/// Methods declared on superclass `NSObject`.
149impl CNPostalAddressFormatter {
150 extern_methods!(
151 #[unsafe(method(init))]
152 #[unsafe(method_family = init)]
153 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
154
155 #[unsafe(method(new))]
156 #[unsafe(method_family = new)]
157 pub unsafe fn new() -> Retained<Self>;
158 );
159}
160
161extern "C" {
162 /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnpostaladdresspropertyattribute?language=objc)
163 pub static CNPostalAddressPropertyAttribute: &'static NSString;
164}
165
166extern "C" {
167 /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnpostaladdresslocalizedpropertynameattribute?language=objc)
168 pub static CNPostalAddressLocalizedPropertyNameAttribute: &'static NSString;
169}