]>
git.proxmox.com Git - rustc.git/blob - src/vendor/miow/src/overlapped.rs
5 /// A wrapper around `OVERLAPPED` to provide "rustic" accessors and
8 pub struct Overlapped(OVERLAPPED
);
10 unsafe impl Send
for Overlapped {}
11 unsafe impl Sync
for Overlapped {}
14 /// Creates a new zeroed out instance of an overlapped I/O tracking state.
16 /// This is suitable for passing to methods which will then later get
17 /// notified via an I/O Completion Port.
18 pub fn zero() -> Overlapped
{
19 Overlapped(unsafe { mem::zeroed() }
)
22 /// Creates a new `Overlapped` function pointer from the underlying
23 /// `OVERLAPPED`, wrapping in the "rusty" wrapper for working with
28 /// This function doesn't validate `ptr` nor the lifetime of the returned
29 /// pointer at all, it's recommended to use this method with extreme
31 pub unsafe fn from_raw
<'a
>(ptr
: *mut OVERLAPPED
) -> &'a
mut Overlapped
{
32 &mut *(ptr
as *mut Overlapped
)
35 /// Gain access to the raw underlying data
36 pub fn raw(&self) -> *mut OVERLAPPED
{
37 &self.0 as *const _
as *mut _
40 /// Sets the offset inside this overlapped structure.
42 /// Note that for I/O operations in general this only has meaning for I/O
43 /// handles that are on a seeking device that supports the concept of an
45 pub fn set_offset(&mut self, offset
: u64) {
46 self.0.Offset
= offset
as u32;
47 self.0.OffsetHigh
= (offset
>> 32) as u32;
50 /// Reads the offset inside this overlapped structure.
51 pub fn offset(&self) -> u64 {
52 (self.0.Offset
as u64) | ((self.0.OffsetHigh
as u64) << 32)
55 /// Sets the `hEvent` field of this structure.
57 /// The event specified can be null.
58 pub fn set_event(&mut self, event
: HANDLE
) {
59 self.0.hEvent
= event
;
62 /// Reads the `hEvent` field of this structure, may return null.
63 pub fn event(&self) -> HANDLE
{