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        ///
92        /// # Safety
93        ///
94        /// `attributes` generic should be of the correct type.
95        #[unsafe(method(attributedStringFromPostalAddress:style:withDefaultAttributes:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn attributedStringFromPostalAddress_style_withDefaultAttributes(
98            postal_address: &CNPostalAddress,
99            style: CNPostalAddressFormatterStyle,
100            attributes: &NSDictionary,
101        ) -> Retained<NSAttributedString>;
102
103        /// The style for a postal address formatter instance.
104        ///
105        ///
106        /// The default value is CNPostalAddressFormatterStyleMailingAddress.
107        #[unsafe(method(style))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn style(&self) -> CNPostalAddressFormatterStyle;
110
111        /// Setter for [`style`][Self::style].
112        #[unsafe(method(setStyle:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn setStyle(&self, style: CNPostalAddressFormatterStyle);
115
116        #[cfg(feature = "CNPostalAddress")]
117        /// Formats the postal address.
118        ///
119        ///
120        /// Parameter `postalAddress`: The postal address to be formatted.
121        ///
122        /// Returns: The formatted postal address.
123        #[unsafe(method(stringFromPostalAddress:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn stringFromPostalAddress(
126            &self,
127            postal_address: &CNPostalAddress,
128        ) -> Retained<NSString>;
129
130        #[cfg(feature = "CNPostalAddress")]
131        /// Formats the postal address returning an attributed string.
132        ///
133        ///
134        /// This behaves like +stringFromPostalAddress: except it returns an attributed string. Includes attribute keys CNPostalAddressPropertyAttribute and CNPostalAddressLocalizedPropertyNameAttribute.
135        ///
136        ///
137        /// Parameter `postalAddress`: The postal address to be formatted.
138        ///
139        /// Parameter `attributes`: The default attributes to use. See NSFormatter for details.
140        ///
141        /// Returns: The formatted postal address as an attributed string.
142        ///
143        /// # Safety
144        ///
145        /// `attributes` generic should be of the correct type.
146        #[unsafe(method(attributedStringFromPostalAddress:withDefaultAttributes:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn attributedStringFromPostalAddress_withDefaultAttributes(
149            &self,
150            postal_address: &CNPostalAddress,
151            attributes: &NSDictionary,
152        ) -> Retained<NSAttributedString>;
153    );
154}
155
156/// Methods declared on superclass `NSObject`.
157impl CNPostalAddressFormatter {
158    extern_methods!(
159        #[unsafe(method(init))]
160        #[unsafe(method_family = init)]
161        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
162
163        #[unsafe(method(new))]
164        #[unsafe(method_family = new)]
165        pub unsafe fn new() -> Retained<Self>;
166    );
167}
168
169extern "C" {
170    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnpostaladdresspropertyattribute?language=objc)
171    pub static CNPostalAddressPropertyAttribute: &'static NSString;
172}
173
174extern "C" {
175    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnpostaladdresslocalizedpropertynameattribute?language=objc)
176    pub static CNPostalAddressLocalizedPropertyNameAttribute: &'static NSString;
177}