Struct unsafe_io::UnsafeHandle[][src]

#[repr(transparent)]
pub struct UnsafeHandle(_);
Expand description

A non-owning unsafe I/O handle.

On Posix-ish platforms this is just a RawFd. On Windows it is a minimal abstraction over RawHandle, RawSocket, and stdio device identifiers. Similar to Rust raw pointers, it is considered safe to construct these, but unsafe to do any I/O with them (effectively dereferencing them).

Implementations

Obtain self with a type that implements Read.

Safety

The resulting UnsafeReadable value must not outlive the underlying resource.

Also, callers should avoid mixing uses of UnsafeReadable with the type’s Read or Write implementations if the type uses buffering, as for example async_std::fs::File does.

Obtain self with a type that implements Write.

Safety

The resulting UnsafeWriteable value must not outlive the underlying resource.

Also, callers should avoid mixing uses of UnsafeWriteable with the type’s Read or Write implementation if the type uses buffering, as for example async_std::fs::File does.

UnsafeHandle doesn’t implement Eq or PartialEq because comparison is undefined for dangling handles.

Safety

Both self and other must outlive their underlying resources.

Like FromRawFd::from_raw_fd, but isn’t unsafe because it doesn’t imply a dereference.

Trait Implementations

UnsafeHandle doesn’t own its handle, but AsRawFd doesn’t require any guarantees about lifetimes, so it’s safe to implement. This is similar to how RawFd implements AsRawFd (see the raw_fd_reflexive_traits trait implementations in std).

Extracts the raw file descriptor. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

UnsafeHandle doesn’t own its handle; see the comments for impl AsRawFd for UnsafeHandle.

Constructs a new instance of Self from the given raw file descriptor. Read more

UnsafeHandle doesn’t own its handle; see the comments for impl AsRawFd for UnsafeHandle.

Constructs a new instance of Self from the given unsafe handle. Read more

UnsafeHandle doesn’t own its handle; see the comments for impl AsRawFd for UnsafeHandle.

Consumes this object, returning the raw underlying file descriptor. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.