summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2014-11-28 20:55:14 -0800
committerCarl Lerche <me@carllerche.com>2014-11-28 20:55:14 -0800
commitaf8048d7a10d482aedff161fbf37216972daa615 (patch)
tree1b4d6c58ad3427db6516f2311b5f6aa5411a590b
parent299fe7fcd922bf1682e30ec39c602afd679421f2 (diff)
downloadnix-af8048d7a10d482aedff161fbf37216972daa615.zip
Implement Show for event::EventFlag
-rw-r--r--src/sys/event.rs40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/sys/event.rs b/src/sys/event.rs
index bd56c9f1..b8370ef0 100644
--- a/src/sys/event.rs
+++ b/src/sys/event.rs
@@ -1,6 +1,10 @@
-use libc::{timespec, time_t, c_int, c_long};
+/* TOOD: Implement for other kqueue based systems
+ */
+
+use libc::{timespec, time_t, c_int, c_long, c_short};
use errno::{SysResult, SysError};
use fcntl::Fd;
+use std::fmt;
pub use self::ffi::kevent as KEvent;
@@ -69,6 +73,40 @@ bitflags!(
}
)
+impl fmt::Show for EventFlag {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ let mut one = false;
+ let flags = [
+ (EV_ADD, "EV_ADD"),
+ (EV_DELETE, "EV_DELETE"),
+ (EV_ENABLE, "EV_ENABLE"),
+ (EV_DISABLE, "EV_DISABLE"),
+ (EV_RECEIPT, "EV_RECEIPT"),
+ (EV_ONESHOT, "EV_ONESHOT"),
+ (EV_CLEAR, "EV_CLEAR"),
+ (EV_DISPATCH, "EV_DISPATCH"),
+ (EV_SYSFLAGS, "EV_SYSFLAGS"),
+ (EV_FLAG0, "EV_FLAG0"),
+ (EV_FLAG1, "EV_FLAG1"),
+ (EV_EOF, "EV_EOF")];
+
+ for &(flag, msg) in flags.iter() {
+ if self.contains(flag) {
+ if one { try!(write!(fmt, " | ")) }
+ try!(write!(fmt, "{}", msg));
+
+ one = true
+ }
+ }
+
+ if !one {
+ try!(write!(fmt, "<None>"));
+ }
+
+ Ok(())
+ }
+}
+
bitflags!(
flags FilterFlag: u32 {
const NOTE_TRIGGER = 0x01000000,