File tree Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -29,3 +29,4 @@ pub mod string;
29
29
pub mod timezone;
30
30
pub mod url;
31
31
pub mod uuid;
32
+ pub mod mach_port;
Original file line number Diff line number Diff line change
1
+ pub use base:: { CFAllocatorRef , CFIndex , CFTypeID } ;
2
+ use runloop:: CFRunLoopSourceRef ;
3
+ use std:: os:: raw:: c_void;
4
+
5
+ #[ repr( C ) ]
6
+ pub struct __CFMachPort ( c_void ) ;
7
+ pub type CFMachPortRef = * const __CFMachPort ;
8
+
9
+ extern "C" {
10
+ /*
11
+ * CFMachPort.h
12
+ */
13
+ pub fn CFMachPortCreateRunLoopSource (
14
+ allocator : CFAllocatorRef ,
15
+ port : CFMachPortRef ,
16
+ order : CFIndex ,
17
+ ) -> CFRunLoopSourceRef ;
18
+
19
+ pub fn CFMachPortGetTypeID ( ) -> CFTypeID ;
20
+ }
Original file line number Diff line number Diff line change @@ -233,3 +233,4 @@ pub mod propertylist;
233
233
pub mod runloop;
234
234
pub mod timezone;
235
235
pub mod uuid;
236
+ pub mod mach_port;
Original file line number Diff line number Diff line change
1
+ use base:: TCFType ;
2
+ use core_foundation_sys:: base:: kCFAllocatorDefault;
3
+ use runloop:: CFRunLoopSource ;
4
+ pub use core_foundation_sys:: mach_port:: * ;
5
+
6
+
7
+ declare_TCFType ! {
8
+ /// An immutable numeric value.
9
+ CFMachPort , CFMachPortRef
10
+ }
11
+ impl_TCFType ! ( CFMachPort , CFMachPortRef , CFMachPortGetTypeID ) ;
12
+ impl_CFTypeDescription ! ( CFMachPort ) ;
13
+
14
+ impl CFMachPort {
15
+ pub fn create_runloop_source (
16
+ & self ,
17
+ order : CFIndex ,
18
+ ) -> Result < CFRunLoopSource , ( ) > {
19
+ unsafe {
20
+ let runloop_source_ref = CFMachPortCreateRunLoopSource ( kCFAllocatorDefault, self . 0 , order) ;
21
+ if runloop_source_ref. is_null ( ) {
22
+ Err ( ( ) )
23
+ } else {
24
+ Ok ( CFRunLoopSource :: wrap_under_create_rule ( runloop_source_ref) )
25
+ }
26
+ }
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments