rust_macios/contacts/
cn_contact_property.rs

1use objc::{msg_send, sel, sel_impl};
2
3use crate::{object, 
4    foundation::NSString,
5    objective_c_runtime::{
6        macros::{interface_impl},
7        traits::{FromId, PNSObject},
8    },
9};
10
11use super::CNContact;
12
13object! {
14    /// An object that represents a property of a contact.
15    unsafe pub struct CNContactProperty;
16}
17
18#[interface_impl(NSObject)]
19impl CNContactProperty {
20    /* Getting the Contact Object
21     */
22
23    /* Getting the Contact Object */
24
25    /// The associated contact.
26    #[property]
27    pub fn contact(&self) -> CNContact {
28        unsafe { CNContact::from_id(msg_send![self.m_self(), contact]) }
29    }
30
31    /* Getting the Property Information
32     */
33
34    /// The key of the contact property.
35    #[property]
36    pub fn key(&self) -> NSString {
37        unsafe { NSString::from_id(msg_send![self.m_self(), key]) }
38    }
39
40    /// The value of the property.
41    #[property]
42    pub fn value(&self) -> NSString {
43        unsafe { NSString::from_id(msg_send![self.m_self(), value]) }
44    }
45
46    /// The label of the labeled value of the property array.
47    #[property]
48    pub fn label(&self) -> NSString {
49        unsafe { NSString::from_id(msg_send![self.m_self(), label]) }
50    }
51
52    /// The label of the labeled value of the property array.
53    #[property]
54    pub fn identifier(&self) -> NSString {
55        unsafe { NSString::from_id(msg_send![self.m_self(), identifier]) }
56    }
57}