Debian Codegraph @

third_party/rust/core-foundation/src/mach_port.rs

raw
1 use crate::base::TCFType;
2 use crate::runloop::CFRunLoopSource;
3 use core_foundation_sys::base::kCFAllocatorDefault;
4 pub use core_foundation_sys::mach_port::*;
5
6 declare_TCFType! {
7 /// An immutable numeric value.
8 CFMachPort, CFMachPortRef
9 }
10 impl_TCFType!(CFMachPort, CFMachPortRef, CFMachPortGetTypeID);
11 impl_CFTypeDescription!(CFMachPort);
12
13 impl CFMachPort {
14 pub fn create_runloop_source(&self, order: CFIndex) -> Result<CFRunLoopSource, ()> {
15 unsafe {
16 let runloop_source_ref =
17 CFMachPortCreateRunLoopSource(kCFAllocatorDefault, self.0, order);
18 if runloop_source_ref.is_null() {
19 Err(())
20 } else {
21 Ok(CFRunLoopSource::wrap_under_create_rule(runloop_source_ref))
22 }
23 }
24 }
25 }