rust_macios/contacts/
cn_container.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4 foundation::{NSArray, NSPredicate, NSString},
5 object,
6 objective_c_runtime::{
7 macros::interface_impl,
8 traits::{FromId, PNSObject},
9 },
10};
11
12#[derive(Debug, Copy, Clone, PartialEq, Eq)]
14#[repr(i64)]
15pub enum CNContainerType {
16 Unassigned = 0,
18 Local,
20 Exchange,
22 CardDav,
24}
25
26object! {
27 unsafe pub struct CNContainer;
29}
30
31#[interface_impl(NSObject)]
32impl CNContainer {
33 #[property]
38 pub fn name(&self) -> NSString {
39 unsafe { NSString::from_id(msg_send![self.m_self(), name]) }
40 }
41
42 #[property]
44 pub fn identifier(&self) -> NSString {
45 unsafe { NSString::from_id(msg_send![self.m_self(), identifier]) }
46 }
47
48 #[property]
50 pub fn type_(&self) -> CNContainerType {
51 unsafe { msg_send![self.m_self(), type] }
52 }
53
54 #[method]
56 pub fn predicate_for_container_of_contact_identifier(identifier: NSString) -> NSPredicate {
57 unsafe {
58 NSPredicate::from_id(msg_send![
59 Self::m_class(),
60 predicateForContainerOfContactWithIdentifier: identifier
61 ])
62 }
63 }
64
65 #[method]
67 pub fn predicate_for_containers_with_identifiers(
68 identifiers: NSArray<NSString>,
69 ) -> NSPredicate {
70 unsafe {
71 NSPredicate::from_id(msg_send![
72 Self::m_class(),
73 predicateForContainersWithIdentifiers: identifiers
74 ])
75 }
76 }
77
78 #[method]
80 pub fn predicate_for_container_of_group_with_identifier(identifier: NSString) -> NSPredicate {
81 unsafe {
82 NSPredicate::from_id(msg_send![
83 Self::m_class(),
84 predicateForContainerOfGroupWithIdentifier: identifier
85 ])
86 }
87 }
88}