Expand description
Experimental new types and traits to replace the Raw
family of types and
traits.
This API has much conceptual similarity with the Raw
API, but introduces
explicit concepts of ownership and borrowing:
Raw API | This experimental API |
---|---|
Raw* | Borrowed* and Owned* |
AsRaw* | As* |
IntoRaw* | Into* |
FromRaw* | From* |
This gives it several advantages:
-
Less
unsafe
in user code! -
Easier to understand ownership.
-
It avoids the inconsistency where
AsRawFd
andIntoRawFd
returnRawFd
values that users ought to be able to trust, but aren’t unsafe, so it’s possible to fail to uphold this trust in purely safe Rust. -
It enables a number of safe and portable convenience features, such as safe typed views and from+into conversions.
Modules§
- example_
ffi close
- This is just a sample of what FFI using this crate can look like.
- raw
- Portability abstractions over
Raw*
. - views
- Typed views using temporary objects.
Structs§
- Borrowed
Handle - A borrowed handle.
- Borrowed
Socket - A borrowed socket.
- Handle
OrInvalid - FFI type for handles in return values or out parameters, where
INVALID_HANDLE_VALUE
is used as a sentry value to indicate errors, such as in the return value ofCreateFileW
. This usesrepr(transparent)
and has the representation of a host handle, so that it can be used in such FFI declarations. - Invalid
Handle Error - This is the error type used by
HandleOrInvalid
when attempting to convert into a handle, to indicate that the value isINVALID_HANDLE_VALUE
. - Null
Handle Error - This is the error type used by
HandleOrNull
when attempting to convert into a handle, to indicate that the value is null. - Owned
Handle - An owned handle.
- Owned
Socket - An owned socket.
Traits§
- AsFilelike
- A portable trait to borrow a reference from an underlying filelike object.
- AsHandle
- A trait to borrow the handle from an underlying object.
- AsSocket
- A trait to borrow the socket from an underlying object.
- AsSocketlike
- A portable trait to borrow a reference from an underlying socketlike object.
- From
Filelike - A portable trait to express the ability to construct an object from a filelike object.
- From
Handle - A trait to express the ability to construct an object from a handle.
- From
Socket - A trait to express the ability to construct an object from a socket.
- From
Socketlike - A portable trait to express the ability to construct an object from a socketlike object.
- Into
Filelike - A portable trait to express the ability to consume an object and acquire ownership of its filelike object.
- Into
Handle Deprecated - A trait to express the ability to consume an object and acquire ownership of its handle.
- Into
Socket Deprecated - A trait to express the ability to consume an object and acquire ownership of its socket.
- Into
Socketlike - A portable trait to express the ability to consume an object and acquire ownership of its socketlike object.
Type Aliases§
- Borrowed
Filelike - A reference to a filelike object.
- Borrowed
Socketlike - A reference to a socketlike object.
- Owned
Filelike - An owned filelike object.
- Owned
Socketlike - An owned socketlike object.