summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJoakim Hulthe <joakim.hulthe@mullvad.net>2025-02-11 15:39:22 +0100
committerJoakim Hulthe <joakim.hulthe@mullvad.net>2025-02-25 13:37:38 +0100
commit403391fbb3665654a898a08aa6db5ef02714532d (patch)
treeb745fae6a0091d6198e3846a618aaa309689d54e
parenta0a2e1f935a16540332f431d9bd98d55fc181609 (diff)
downloadmullvadvpn-403391fbb3665654a898a08aa6db5ef02714532d.tar.xz
mullvadvpn-403391fbb3665654a898a08aa6db5ef02714532d.zip
Add safety comments in talpid_windows::io
-rw-r--r--talpid-windows/src/io.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/talpid-windows/src/io.rs b/talpid-windows/src/io.rs
index 1bcffb30d3..cd7b0ae98a 100644
--- a/talpid-windows/src/io.rs
+++ b/talpid-windows/src/io.rs
@@ -4,18 +4,24 @@ use windows_sys::Win32::System::IO::OVERLAPPED;
use crate::sync::Event;
/// Abstraction over `OVERLAPPED`.
+///
+/// - https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-overlapped
+/// - https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createeventw
pub struct Overlapped {
overlapped: OVERLAPPED,
event: Option<Event>,
}
+// SAFETY: Both OVERLAPPED and Event is used for async I/O, so this *should* be safe.
unsafe impl Send for Overlapped {}
+// SAFETY: See above.
unsafe impl Sync for Overlapped {}
impl Overlapped {
/// Creates an `OVERLAPPED` object with `hEvent` set.
pub fn new(event: Option<Event>) -> io::Result<Self> {
let mut overlapped = Overlapped {
+ // SAFETY: OVERLAPPED is a C struct and can safely be zeroed.
overlapped: unsafe { mem::zeroed() },
event: None,
};