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
44
45
46
47
48
49
50
51
52
53
use std::mem;
use winapi::*;
#[derive(Debug)]
pub struct Overlapped(OVERLAPPED);
unsafe impl Send for Overlapped {}
unsafe impl Sync for Overlapped {}
impl Overlapped {
pub fn zero() -> Overlapped {
Overlapped(unsafe { mem::zeroed() })
}
pub fn raw(&self) -> *mut OVERLAPPED {
&self.0 as *const _ as *mut _
}
pub fn set_offset(&mut self, offset: u64) {
self.0.Offset = offset as u32;
self.0.OffsetHigh = (offset >> 32) as u32;
}
pub fn offset(&self) -> u64 {
(self.0.Offset as u64) | ((self.0.OffsetHigh as u64) << 32)
}
pub fn set_event(&mut self, event: HANDLE) {
self.0.hEvent = event;
}
pub fn event(&self) -> HANDLE {
self.0.hEvent
}
}