Skip to main content

HandleBased

Trait HandleBased 

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) -> u32 { ... }
}
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§

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

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

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.

fn into_handle(self) -> NullableHandle

Converts the value into its inner handle.

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

fn into_raw(self) -> u32

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.

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§

§

impl HandleBased for Bti

§

impl HandleBased for Channel

§

impl HandleBased for Counter

§

impl HandleBased for DebugLog

§

impl HandleBased for Event

§

impl HandleBased for EventPair

§

impl HandleBased for Exception

§

impl HandleBased for Guest

§

impl HandleBased for Iob

§

impl HandleBased for Iommu

§

impl HandleBased for Job

§

impl HandleBased for NullableHandle

§

impl HandleBased for Pager

§

impl HandleBased for Pmt

§

impl HandleBased for Port

§

impl HandleBased for Process

§

impl HandleBased for Profile

§

impl HandleBased for Resource

§

impl HandleBased for Socket

§

impl HandleBased for Stream

§

impl HandleBased for Thread

§

impl HandleBased for Vcpu

§

impl HandleBased for Vmar

§

impl HandleBased for Vmo

§

impl HandleBased for IobSharedRegion

§

impl<K, T> HandleBased for Interrupt<K, T>
where K: InterruptKind, T: Timeline,

§

impl<R, W> HandleBased for Fifo<R, W>

§

impl<Reference, Output> HandleBased for Clock<Reference, Output>
where Reference: Timeline, Output: Timeline,

§

impl<T> HandleBased for Timer<T>
where T: Timeline,