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 APIThis 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 and IntoRawFd return RawFd 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

This is just a sample of what FFI using this crate can look like.

Portability abstractions over Raw*.

Typed views using temporary objects.

Structs

A borrowed handle.

A borrowed socket.

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 of CreateFileW. This uses repr(transparent) and has the representation of a host handle, so that it can be used in such FFI declarations.

An owned handle.

An owned socket.

Traits

A portable trait to borrow a reference from an underlying filelike object.

A trait to borrow the handle from an underlying object.

A trait to borrow the socket from an underlying object.

A portable trait to borrow a reference from an underlying socketlike object.

A portable trait to express the ability to construct an object from a filelike object.

A trait to express the ability to construct an object from a handle.

A trait to express the ability to construct an object from a socket.

A portable trait to express the ability to construct an object from a socketlike object.

A portable trait to express the ability to consume an object and acquire ownership of its filelike object.

A trait to express the ability to consume an object and acquire ownership of its handle.

A trait to express the ability to consume an object and acquire ownership of its socket.

A portable trait to express the ability to consume an object and acquire ownership of its socketlike object.

Type Definitions

A reference to a filelike object.

A reference to a socketlike object.

An owned filelike object.

An owned socketlike object.