1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use objc::{msg_send, sel, sel_impl};
use crate::{
foundation::{NSArray, NSPredicate, NSString},
object,
objective_c_runtime::{
macros::interface_impl,
traits::{FromId, PNSObject},
},
};
/// The container may be local on the device or associated with a server account that has contacts.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(i64)]
pub enum CNContainerType {
///
Unassigned = 0,
/// A container for contacts only stored locally on the device. There is only one local container for a device.
Local,
/// A container for contacts stored in an Exchange folder from an Exchange server.
Exchange,
/// A container for contacts stored in an CardDAV server, such as iCloud.
CardDav,
}
object! {
/// An immutable object that represents a collection of contacts.
unsafe pub struct CNContainer;
}
#[interface_impl(NSObject)]
impl CNContainer {
/* Getting the Container Information
*/
/// The name of the container.
#[property]
pub fn name(&self) -> NSString {
unsafe { NSString::from_id(msg_send![self.m_self(), name]) }
}
/// The unique identifier for a contacts container on the device.
#[property]
pub fn identifier(&self) -> NSString {
unsafe { NSString::from_id(msg_send![self.m_self(), identifier]) }
}
/// The type of the container.
#[property]
pub fn type_(&self) -> CNContainerType {
unsafe { msg_send![self.m_self(), type] }
}
/// Returns a predicate to find the container of the specified contact.
#[method]
pub fn predicate_for_container_of_contact_identifier(identifier: NSString) -> NSPredicate {
unsafe {
NSPredicate::from_id(msg_send![
Self::m_class(),
predicateForContainerOfContactWithIdentifier: identifier
])
}
}
/// Returns a predicate to find the containers with the specified identifiers.
#[method]
pub fn predicate_for_containers_with_identifiers(
identifiers: NSArray<NSString>,
) -> NSPredicate {
unsafe {
NSPredicate::from_id(msg_send![
Self::m_class(),
predicateForContainersWithIdentifiers: identifiers
])
}
}
/// Returns a predicate to find the container of the specified group.
#[method]
pub fn predicate_for_container_of_group_with_identifier(identifier: NSString) -> NSPredicate {
unsafe {
NSPredicate::from_id(msg_send![
Self::m_class(),
predicateForContainerOfGroupWithIdentifier: identifier
])
}
}
}