core_foundation_sys/
messageport.rs1use std::os::raw::c_void;
11
12use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID, SInt32};
13use crate::data::CFDataRef;
14use crate::date::CFTimeInterval;
15use crate::runloop::CFRunLoopSourceRef;
16use crate::string::CFStringRef;
17
18#[repr(C)]
19#[derive(Copy, Clone, Debug)]
20pub struct CFMessagePortContext {
21 pub version: CFIndex,
22 pub info: *mut c_void,
23 pub retain: Option<unsafe extern "C" fn(info: *const c_void) -> *const c_void>,
24 pub release: Option<unsafe extern "C" fn(info: *const c_void)>,
25 pub copyDescription: Option<unsafe extern "C" fn(info: *const c_void) -> CFStringRef>,
26}
27
28pub type CFMessagePortCallBack = Option<
29 unsafe extern "C" fn(
30 local: CFMessagePortRef,
31 msgid: i32,
32 data: CFDataRef,
33 info: *mut c_void,
34 ) -> CFDataRef,
35>;
36
37pub type CFMessagePortInvalidationCallBack =
38 Option<unsafe extern "C" fn(ms: CFMessagePortRef, info: *mut c_void)>;
39
40pub const kCFMessagePortSuccess: SInt32 = 0;
42pub const kCFMessagePortSendTimeout: SInt32 = -1;
43pub const kCFMessagePortReceiveTimeout: SInt32 = -2;
44pub const kCFMessagePortIsInvalid: SInt32 = -3;
45pub const kCFMessagePortTransportError: SInt32 = -4;
46pub const kCFMessagePortBecameInvalidError: SInt32 = -5;
47
48#[repr(C)]
49pub struct __CFMessagePort(c_void);
50pub type CFMessagePortRef = *mut __CFMessagePort;
51
52extern "C" {
53 pub fn CFMessagePortCreateLocal(
59 allocator: CFAllocatorRef,
60 name: CFStringRef,
61 callout: CFMessagePortCallBack,
62 context: *const CFMessagePortContext,
63 shouldFreeInfo: *mut Boolean,
64 ) -> CFMessagePortRef;
65 pub fn CFMessagePortCreateRemote(
66 allocator: CFAllocatorRef,
67 name: CFStringRef,
68 ) -> CFMessagePortRef;
69
70 pub fn CFMessagePortCreateRunLoopSource(
72 allocator: CFAllocatorRef,
73 local: CFMessagePortRef,
74 order: CFIndex,
75 ) -> CFRunLoopSourceRef;
76 pub fn CFMessagePortSetInvalidationCallBack(
77 ms: CFMessagePortRef,
78 callout: CFMessagePortInvalidationCallBack,
79 );
80 pub fn CFMessagePortSetName(ms: CFMessagePortRef, newName: CFStringRef) -> Boolean;
81
82 pub fn CFMessagePortInvalidate(ms: CFMessagePortRef);
84 pub fn CFMessagePortSendRequest(
85 remote: CFMessagePortRef,
86 msgid: i32,
87 data: CFDataRef,
88 sendTimeout: CFTimeInterval,
89 rcvTimeout: CFTimeInterval,
90 replyMode: CFStringRef,
91 returnData: *mut CFDataRef,
92 ) -> i32;
93 pub fn CFMessagePortGetContext(ms: CFMessagePortRef, context: *mut CFMessagePortContext);
97 pub fn CFMessagePortGetInvalidationCallBack(
98 ms: CFMessagePortRef,
99 ) -> CFMessagePortInvalidationCallBack;
100 pub fn CFMessagePortGetName(ms: CFMessagePortRef) -> CFStringRef;
101 pub fn CFMessagePortIsRemote(ms: CFMessagePortRef) -> Boolean;
102 pub fn CFMessagePortIsValid(ms: CFMessagePortRef) -> Boolean;
103
104 pub fn CFMessagePortGetTypeID() -> CFTypeID;
106}