rust_macios/contacts/
cn_mutable_postal_address.rs

1use objc::{msg_send, sel, sel_impl};
2
3use crate::{foundation::NSString, object, objective_c_runtime::macros::interface_impl};
4
5use super::ICNPostalAddress;
6
7object! {
8    /// A mutable representation of the postal address for a contact.
9    unsafe pub struct CNMutablePostalAddress;
10}
11
12impl ICNPostalAddress for CNMutablePostalAddress {}
13
14#[interface_impl(CNPostalAddress)]
15impl CNMutablePostalAddress {
16    /* Modifying the Parts of a Postal Address
17     */
18
19    /// The street name of the address.
20    #[property]
21    pub fn set_street(&mut self, street: NSString) {
22        unsafe { msg_send![self.m_self(), setStreet: street] }
23    }
24
25    /// The city name of the address.
26    #[property]
27    pub fn set_city(&mut self, city: NSString) {
28        unsafe { msg_send![self.m_self(), setCity: city] }
29    }
30
31    /// The state name of the address.
32    #[property]
33    pub fn set_state(&mut self, state: NSString) {
34        unsafe { msg_send![self.m_self(), setState: state] }
35    }
36
37    /// The postal code of the address.
38    #[property]
39    pub fn set_postal_code(&mut self, postal_code: NSString) {
40        unsafe { msg_send![self.m_self(), setPostalCode: postal_code] }
41    }
42
43    /// The country or region name of the address.
44    #[property]
45    pub fn set_country(&mut self, country: NSString) {
46        unsafe { msg_send![self.m_self(), setCountry: country] }
47    }
48
49    /// The ISO country code, using the ISO 3166-1 alpha-2 standard.
50    #[property]
51    pub fn set_iso_country_code(&mut self, iso_country_code: NSString) {
52        unsafe { msg_send![self.m_self(), setISOCountryCode: iso_country_code] }
53    }
54
55    /// The subadministrative area (such as a county or other region) in a postal address.
56    #[property]
57    pub fn set_sub_administrative_area(&mut self, sub_administrative_area: NSString) {
58        unsafe {
59            msg_send![
60                self.m_self(),
61                setSubAdministrativeArea: sub_administrative_area
62            ]
63        }
64    }
65
66    /// Additional information associated with the location, typically defined at the city or town level, in a postal address.
67    #[property]
68    pub fn set_sub_locality(&mut self, sub_locality: NSString) {
69        unsafe { msg_send![self.m_self(), setSubLocality: sub_locality] }
70    }
71}