Debian Codegraph @

third_party/rust/mio/src/sys/windows/overlapped.rs

raw
1 use crate::sys::windows::Event;
2
3 use std::cell::UnsafeCell;
4 use std::fmt;
5
6 use windows_sys::Win32::System::IO::{OVERLAPPED, OVERLAPPED_ENTRY};
7
8 #[repr(C)]
9 pub(crate) struct Overlapped {
10 inner: UnsafeCell<OVERLAPPED>,
11 pub(crate) callback: fn(&OVERLAPPED_ENTRY, Option<&mut Vec<Event>>),
12 }
13
14 #[cfg(feature = "os-ext")]
15 impl Overlapped {
16 pub(crate) fn new(cb: fn(&OVERLAPPED_ENTRY, Option<&mut Vec<Event>>)) -> Overlapped {
17 Overlapped {
18 inner: UnsafeCell::new(unsafe { std::mem::zeroed() }),
19 callback: cb,
20 }
21 }
22
23 pub(crate) fn as_ptr(&self) -> *const OVERLAPPED {
24 self.inner.get()
25 }
26 }
27
28 impl fmt::Debug for Overlapped {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 f.debug_struct("Overlapped").finish()
31 }
32 }
33
34 unsafe impl Send for Overlapped {}
35 unsafe impl Sync for Overlapped {}