rust_macios/contacts/
cn_contact_fetch_request.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4 foundation::{NSArray, NSPredicate},
5 object,
6 objective_c_runtime::{id, macros::interface_impl, traits::FromId},
7 utils::to_bool,
8};
9
10use super::{CNContactSortOrder, ICNFetchRequest};
11
12object! {
13 unsafe pub struct CNContactFetchRequest;
15}
16
17impl ICNFetchRequest for CNContactFetchRequest {}
18
19#[interface_impl(CNFetchRequest)]
20impl CNContactFetchRequest {
21 #[method]
26 pub fn init_with_keys_to_fetch(&self, keys: NSArray<id>) -> Self
27 where
28 Self: Sized + FromId,
29 {
30 unsafe { Self::from_id(msg_send![self.m_self(), initWithKeysToFetch: keys]) }
31 }
32
33 #[property]
38 pub fn predicate(&self) -> NSPredicate {
39 unsafe { NSPredicate::from_id(msg_send![self.m_self(), predicate]) }
40 }
41
42 #[property]
44 pub fn set_predicate(&mut self, predicate: NSPredicate) {
45 unsafe { msg_send![self.m_self(), setPredicate: predicate] }
46 }
47
48 #[property]
50 pub fn mutable_objects(&self) -> bool {
51 unsafe { to_bool(msg_send![self.m_self(), mutableObjects]) }
52 }
53
54 #[property]
56 pub fn set_mutable_objects(&mut self, mutable_objects: bool) {
57 unsafe { msg_send![self.m_self(), setMutableObjects: mutable_objects] }
58 }
59
60 #[property]
62 pub fn unify_results(&self) -> bool {
63 unsafe { to_bool(msg_send![self.m_self(), unifyResults]) }
64 }
65
66 #[property]
68 pub fn set_unify_results(&mut self, unify_results: bool) {
69 unsafe { msg_send![self.m_self(), setUnifyResults: unify_results] }
70 }
71
72 #[property]
74 pub fn sort_order(&self) -> CNContactSortOrder {
75 unsafe { msg_send![self.m_self(), sortOrder] }
76 }
77
78 #[property]
83 pub fn keys_to_fetch(&self) -> NSArray<id> {
84 unsafe { NSArray::from_id(msg_send![self.m_self(), keysToFetch]) }
85 }
86
87 #[property]
89 pub fn set_keys_to_fetch(&mut self, keys_to_fetch: NSArray<id>) {
90 unsafe { msg_send![self.m_self(), setKeysToFetch: keys_to_fetch] }
91 }
92}