-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathevent.rs
More file actions
43 lines (37 loc) · 1006 Bytes
/
event.rs
File metadata and controls
43 lines (37 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use mio::{event::Event as MioEvent, Token};
use std::fmt;
/// Unified event struct that abstracts away platform differences by wrapping mio::event::Event as MioEvent
pub struct Event {
token: Token,
is_readable: bool,
is_writable: bool,
}
impl fmt::Debug for Event {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Event")
.field("token", &self.token)
.field("is_readable", &self.is_readable)
.field("is_writable", &self.is_writable)
.finish()
}
}
impl Event {
pub fn token(&self) -> Token {
self.token
}
pub fn is_readable(&self) -> bool {
self.is_readable
}
pub fn is_writable(&self) -> bool {
self.is_writable
}
}
impl From<&MioEvent> for Event {
fn from(event: &MioEvent) -> Self {
Self {
token: event.token(),
is_readable: event.is_readable(),
is_writable: event.is_writable(),
}
}
}