Struct winapi_util::Handle

source ·
pub struct Handle(/* private fields */);
Expand description

A handle represents an owned and valid Windows handle to a file-like object.

When an owned handle is dropped, then the underlying raw handle is closed. To get a borrowed handle, use HandleRef.

Implementations§

source§

impl Handle

source

pub fn from_file(file: File) -> Handle

Create an owned handle to the given file.

When the returned handle is dropped, the file is closed.

Note that if the given file represents a handle to a directory, then it is generally required that it have been opened with the FILE_FLAG_BACKUP_SEMANTICS flag in order to use it in various calls such as information or typ. To have this done automatically for you, use the from_path_any constructor.

source

pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Handle>

Open a file to the given file path, and return an owned handle to that file.

When the returned handle is dropped, the file is closed.

If there was a problem opening the file, then the corresponding error is returned.

source

pub fn from_path_any<P: AsRef<Path>>(path: P) -> Result<Handle>

Like from_path, but supports opening directory handles as well.

If you use from_path on a directory, then subsequent queries using that handle will fail.

source

pub fn as_file(&self) -> &File

Return this handle as a standard File reference.

source

pub fn as_file_mut(&mut self) -> &mut File

Return this handle as a standard File mutable reference.

Trait Implementations§

source§

impl AsHandleRef for Handle

source§

fn as_handle_ref(&self) -> HandleRef

A borrowed handle that wraps the raw handle of the Self object.
source§

fn as_raw(&self) -> RawHandle

A convenience routine for extracting a HandleRef from Self, and then extracting a raw handle from the HandleRef.
source§

impl AsRawHandle for Handle

source§

fn as_raw_handle(&self) -> RawHandle

Extracts the raw handle. Read more
source§

impl Debug for Handle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromRawHandle for Handle

source§

unsafe fn from_raw_handle(handle: RawHandle) -> Handle

Constructs a new I/O object from the specified raw handle. Read more
source§

impl IntoRawHandle for Handle

source§

fn into_raw_handle(self) -> RawHandle

Consumes this object, returning the raw underlying handle. Read more

Auto Trait Implementations§

§

impl Freeze for Handle

§

impl RefUnwindSafe for Handle

§

impl Send for Handle

§

impl Sync for Handle

§

impl Unpin for Handle

§

impl UnwindSafe for Handle

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.