Skip to main content

HandleBased

Trait HandleBased 

Source
pub trait HandleBased:
    AsHandleRef
    + From<NullableHandle>
    + Into<NullableHandle> {
    // Provided methods
    fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status> { ... }
    fn replace_handle(self, rights: Rights) -> Result<Self, Status> { ... }
    fn into_handle(self) -> NullableHandle { ... }
    fn into_raw(self) -> zx_handle_t { ... }
    fn from_handle(handle: NullableHandle) -> Self { ... }
}
Expand description

A trait implemented by all handle-based types.

Note: it is reasonable for user-defined objects wrapping a handle to implement this trait. For example, a specific interface in some protocol might be represented as a newtype of Channel, and implement the as_handle_ref method and the From<Handle> trait to facilitate conversion from and to the interface.

Provided Methods§

Source

fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>

Duplicate a handle, possibly reducing the rights available. Wraps the zx_handle_duplicate syscall.

Source

fn replace_handle(self, rights: Rights) -> Result<Self, Status>

Create a replacement for a handle, possibly reducing the rights available. This invalidates the original handle. Wraps the zx_handle_replace syscall.

Source

fn into_handle(self) -> NullableHandle

Converts the value into its inner handle.

This is a convenience function which simply forwards to the Into trait.

Source

fn into_raw(self) -> zx_handle_t

Converts the handle into it’s raw representation.

The caller takes ownership over the raw handle, and must close or transfer it to avoid a handle leak.

Source

fn from_handle(handle: NullableHandle) -> Self

Creates an instance of this type from a handle.

This is a convenience function which simply forwards to the From trait.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§