Struct win32console::structs::handle::Handle [−][src]
pub struct Handle(_);
Expand description
Wraps a windows HANDLE.
Implementations
Creates a new shared Handle
from the specified.
Examples
Basic usages:
use winapi::um::winbase::STD_INPUT_HANDLE;
use winapi::um::processenv::GetStdHandle;
use win32console::structs::handle::Handle;
let handle = Handle::new(unsafe { GetStdHandle(STD_INPUT_HANDLE) });
assert!(handle.is_valid());
Creates a new Handle
from the specified which will be close
when goes out of scope by calling CloseHandle.
Examples
Basic usages:
use win32console::structs::handle::Handle;
use winapi::um::fileapi::{CreateFileW, OPEN_EXISTING};
use winapi::um::handleapi::INVALID_HANDLE_VALUE;
use winapi::um::winnt::{GENERIC_READ, FILE_SHARE_READ, FILE_SHARE_WRITE, GENERIC_WRITE};
use std::ptr::null_mut;
let file_name: Vec<u16> = "CONIN$\0".encode_utf16().collect();
let handle = Handle::new_owned(unsafe { CreateFileW(
file_name.as_ptr(),
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
null_mut(),
OPEN_EXISTING,
0,
null_mut(),
) });
assert_ne!(*handle, INVALID_HANDLE_VALUE);
Gets a reference to the underlying HANDLE
.
Examples
Basic usages:
use win32console::structs::handle::Handle;
use winapi::um::processenv::GetStdHandle;
use winapi::um::winbase::STD_INPUT_HANDLE;
use winapi::um::winnt::HANDLE;
use winapi::um::handleapi::INVALID_HANDLE_VALUE;
let handle = Handle::new(unsafe { GetStdHandle(STD_INPUT_HANDLE) });
let raw_handle = handle.get_raw();
assert_ne!(raw_handle, INVALID_HANDLE_VALUE);
Compare this handle to INVALID_HANDLE_VALUE to determines if the handle is valid.
Examples:
Basic usages:
use win32console::structs::handle::Handle;
use winapi::um::processenv::GetStdHandle;
use winapi::um::winbase::STD_INPUT_HANDLE;
use winapi::um::handleapi::INVALID_HANDLE_VALUE;
let handle = Handle::new(unsafe { GetStdHandle(STD_INPUT_HANDLE) });
assert!(handle.is_valid());
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Handle
impl UnwindSafe for Handle
Blanket Implementations
Mutably borrows from an owned value. Read more