rust_macios/contacts/
cn_fetch_result.rs1use std::marker::PhantomData;
2
3use objc::{msg_send, sel, sel_impl};
4
5use crate::{
6 foundation::NSData,
7 object,
8 objective_c_runtime::traits::{FromId, PNSObject},
9};
10
11object! {
12 unsafe pub struct CNFetchResult<ValueType> {
14 marker: PhantomData<ValueType>,
15 }
16}
17
18pub trait ICNFetchResult<ValueType>: PNSObject
20where
21 ValueType: PNSObject + FromId,
22{
23 fn p_current_history_token(&self) -> NSData {
25 unsafe { NSData::from_id(msg_send![self.m_self(), currentHistoryToken]) }
26 }
27
28 fn p_value(&self) -> ValueType {
30 unsafe { ValueType::from_id(msg_send![self.m_self(), value]) }
31 }
32}
33
34impl<ValueType> ICNFetchResult<ValueType> for CNFetchResult<ValueType> where
35 ValueType: PNSObject + FromId
36{
37}
38
39impl<ValueType> CNFetchResult<ValueType>
40where
41 ValueType: PNSObject + FromId,
42{
43 pub fn current_history_token(&self) -> NSData {
45 self.p_current_history_token()
46 }
47
48 pub fn value(&self) -> ValueType {
50 self.p_value()
51 }
52}