Struct winapi_util::HandleRef
source · pub struct HandleRef(/* private fields */);
Expand description
Represents a borrowed and valid Windows handle to a file-like object, such as stdin/stdout/stderr or an actual file.
When a borrowed handle is dropped, then the underlying raw handle is
not closed. To get an owned handle, use Handle
.
Implementations§
source§impl HandleRef
impl HandleRef
sourcepub fn stdin() -> HandleRef
pub fn stdin() -> HandleRef
Create a borrowed handle to stdin.
When the returned handle is dropped, stdin is not closed.
sourcepub fn stdout() -> HandleRef
pub fn stdout() -> HandleRef
Create a handle to stdout.
When the returned handle is dropped, stdout is not closed.
sourcepub fn stderr() -> HandleRef
pub fn stderr() -> HandleRef
Create a handle to stderr.
When the returned handle is dropped, stderr is not closed.
sourcepub fn from_file(file: &File) -> HandleRef
pub fn from_file(file: &File) -> HandleRef
Create a borrowed handle to the given file.
When the returned handle is dropped, the file is not closed.
sourcepub unsafe fn from_raw_handle(handle: RawHandle) -> HandleRef
pub unsafe fn from_raw_handle(handle: RawHandle) -> HandleRef
Create a borrowed handle from the given raw handle.
Note that unlike the FromRawHandle
trait, this constructor does
not consume ownership of the given handle. That is, when the
borrowed handle created by this constructor is dropped, the underlying
handle will not be closed.
§Safety
This is unsafe because there is no guarantee that the given raw handle is a valid handle. The caller must ensure this is true before invoking this constructor.
sourcepub fn as_file_mut(&mut self) -> &mut File
pub fn as_file_mut(&mut self) -> &mut File
Return this handle as a standard File
mutable reference.
Trait Implementations§
source§impl AsHandleRef for HandleRef
impl AsHandleRef for HandleRef
source§impl AsRawHandle for HandleRef
impl AsRawHandle for HandleRef
source§fn as_raw_handle(&self) -> RawHandle
fn as_raw_handle(&self) -> RawHandle
Auto Trait Implementations§
impl Freeze for HandleRef
impl RefUnwindSafe for HandleRef
impl Send for HandleRef
impl Sync for HandleRef
impl Unpin for HandleRef
impl UnwindSafe for HandleRef
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)