Sha256: f75276733a6f930f755a1bc5651cba8be52320a45709eec0b4ce5efe8779c5b6

Contents?: true

Size: 670 Bytes

Versions: 38

Compression:

Stored size: 670 Bytes

Contents

use std::os::windows::io::RawHandle;
use windows_sys::Win32::Foundation::{CloseHandle, HANDLE};

/// Wrapper around a Windows HANDLE so that we close it upon drop in all scenarios
#[derive(Debug)]
pub struct Handle(HANDLE);

impl Handle {
    #[inline]
    pub fn new(handle: HANDLE) -> Self {
        Self(handle)
    }

    pub fn raw(&self) -> HANDLE {
        self.0
    }

    pub fn into_raw(self) -> RawHandle {
        let ret = self.0;
        // This is super important so that drop is not called!
        std::mem::forget(self);
        ret as RawHandle
    }
}

impl Drop for Handle {
    fn drop(&mut self) {
        unsafe { CloseHandle(self.0) };
    }
}

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/mio-1.0.3/src/sys/windows/handle.rs
wasmtime-28.0.0 ./ext/cargo-vendor/mio-1.0.3/src/sys/windows/handle.rs
wasmtime-27.0.0 ./ext/cargo-vendor/mio-1.0.2/src/sys/windows/handle.rs
wasmtime-26.0.0 ./ext/cargo-vendor/mio-1.0.2/src/sys/windows/handle.rs
wasmtime-25.0.2 ./ext/cargo-vendor/mio-1.0.2/src/sys/windows/handle.rs
wasmtime-25.0.1 ./ext/cargo-vendor/mio-1.0.2/src/sys/windows/handle.rs
wasmtime-25.0.0 ./ext/cargo-vendor/mio-1.0.2/src/sys/windows/handle.rs
wasmtime-24.0.0 ./ext/cargo-vendor/mio-1.0.2/src/sys/windows/handle.rs
wasmtime-23.0.2 ./ext/cargo-vendor/mio-0.8.10/src/sys/windows/handle.rs
wasmtime-22.0.0 ./ext/cargo-vendor/mio-0.8.10/src/sys/windows/handle.rs
wasmtime-21.0.1 ./ext/cargo-vendor/mio-0.8.10/src/sys/windows/handle.rs
wasmtime-20.0.2 ./ext/cargo-vendor/mio-0.8.10/src/sys/windows/handle.rs
wasmtime-20.0.0 ./ext/cargo-vendor/mio-0.8.10/src/sys/windows/handle.rs
wasmtime-18.0.3 ./ext/cargo-vendor/mio-0.8.10/src/sys/windows/handle.rs
wasmtime-17.0.1 ./ext/cargo-vendor/mio-0.8.10/src/sys/windows/handle.rs
wasmtime-17.0.0 ./ext/cargo-vendor/mio-0.8.10/src/sys/windows/handle.rs
wasmtime-16.0.0 ./ext/cargo-vendor/mio-0.8.10/src/sys/windows/handle.rs
wasmtime-15.0.1 ./ext/cargo-vendor/mio-0.8.10/src/sys/windows/handle.rs
wasmtime-15.0.0 ./ext/cargo-vendor/mio-0.8.10/src/sys/windows/handle.rs
wasmtime-14.0.4 ./ext/cargo-vendor/mio-0.8.9/src/sys/windows/handle.rs