rust_macios/contacts/
cn_instant_message_address.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4 foundation::NSString,
5 object,
6 objective_c_runtime::{
7 macros::interface_impl,
8 traits::{FromId, PNSObject},
9 },
10};
11
12object! {
13 unsafe pub struct CNInstantMessageAddress;
15}
16
17#[interface_impl(NSObject)]
18impl CNInstantMessageAddress {
19 #[method]
21 pub fn init_with_username_service(&mut self, username: NSString, service: NSString) -> Self
22 where
23 Self: Sized + FromId,
24 {
25 unsafe {
26 Self::from_id(msg_send![self.m_self(), initWithUsername: username service: service])
27 }
28 }
29
30 #[property]
35 pub fn service(&self) -> NSString {
36 unsafe { NSString::from_id(msg_send![self.m_self(), service]) }
37 }
38 #[property]
40 pub fn username(&self) -> NSString {
41 unsafe { NSString::from_id(msg_send![self.m_self(), username]) }
42 }
43
44 #[method]
49 pub fn localized_string_for_key(key: NSString) -> NSString {
50 unsafe { NSString::from_id(msg_send![Self::m_class(), localizedStringForKey: key]) }
51 }
52
53 #[method]
55 pub fn localized_string_for_service(service: NSString) -> NSString {
56 unsafe {
57 NSString::from_id(msg_send![
58 Self::m_class(),
59 localizedStringForService: service
60 ])
61 }
62 }
63}