pub struct Handle(/* private fields */);
Expand description
An object representing a Zircon handle.
Internally, it is represented as a 32-bit integer, but this wrapper enforces
strict ownership semantics. The Drop
implementation closes the handle.
This type represents the most general reference to a kernel object, and can be interconverted to and from more specific types. Those conversions are not enforced in the type system; attempting to use them will result in errors returned by the kernel. These conversions don’t change the underlying representation, but do change the type and thus what operations are available.
Implementations§
Source§impl Handle
impl Handle
Sourcepub const fn invalid() -> Handle
pub const fn invalid() -> Handle
Initialize a handle backed by ZX_HANDLE_INVALID, the only safe non-handle.
Sourcepub const unsafe fn from_raw(raw: u32) -> Handle
pub const unsafe fn from_raw(raw: u32) -> Handle
If a raw handle is obtained from some other source, this method converts it into a type-safe owned handle.
§Safety
raw
must either be a valid handle (i.e. not dangling), or
ZX_HANDLE_INVALID
. If raw
is a valid handle, then either:
raw
may be closed manually and the returnedHandle
must not be dropped.- Or
raw
must not be closed until the returnedHandle
is dropped, at which time it will closeraw
.
pub fn is_invalid(&self) -> bool
pub fn replace(self, rights: Rights) -> Result<Handle, Status>
Trait Implementations§
Source§impl AsHandleRef for Handle
impl AsHandleRef for Handle
Source§fn as_handle_ref(&self) -> Unowned<'_, Handle>
fn as_handle_ref(&self) -> Unowned<'_, Handle>
object_wait_many
.Source§fn raw_handle(&self) -> u32
fn raw_handle(&self) -> u32
Source§fn signal_handle(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
fn signal_handle( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
Source§fn wait_handle(
&self,
signals: Signals,
deadline: Instant<MonotonicTimeline>,
) -> WaitResult
fn wait_handle( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> WaitResult
Source§fn wait_async_handle(
&self,
port: &Port,
key: u64,
signals: Signals,
options: WaitAsyncOpts,
) -> Result<(), Status>
fn wait_async_handle( &self, port: &Port, key: u64, signals: Signals, options: WaitAsyncOpts, ) -> Result<(), Status>
Source§fn get_name(&self) -> Result<Name, Status>
fn get_name(&self) -> Result<Name, Status>
Source§fn set_name(&self, name: &Name) -> Result<(), Status>
fn set_name(&self, name: &Name) -> Result<(), Status>
Source§fn basic_info(&self) -> Result<HandleBasicInfo, Status>
fn basic_info(&self) -> Result<HandleBasicInfo, Status>
Source§fn count_info(&self) -> Result<HandleCountInfo, Status>
fn count_info(&self) -> Result<HandleCountInfo, Status>
§impl Encodable for Handle
impl Encodable for Handle
§type Encoded = WireHandle
type Encoded = WireHandle
§const COPY_OPTIMIZATION: CopyOptimization<Self, Self::Encoded> = _
const COPY_OPTIMIZATION: CopyOptimization<Self, Self::Encoded> = _
Self
to Self::Encoded
is equivalent to copying the raw bytes
of Self
. Read more§impl EncodableOption for Handle
impl EncodableOption for Handle
§type EncodedOption = WireOptionalHandle
type EncodedOption = WireOptionalHandle
§impl<E> Encode<E> for Handlewhere
E: HandleEncoder + ?Sized,
impl<E> Encode<E> for Handlewhere
E: HandleEncoder + ?Sized,
§fn encode(
self,
encoder: &mut E,
out: &mut MaybeUninit<<Handle as Encodable>::Encoded>,
) -> Result<(), EncodeError>
fn encode( self, encoder: &mut E, out: &mut MaybeUninit<<Handle as Encodable>::Encoded>, ) -> Result<(), EncodeError>
§impl<E> EncodeOption<E> for Handlewhere
E: HandleEncoder + ?Sized,
impl<E> EncodeOption<E> for Handlewhere
E: HandleEncoder + ?Sized,
§fn encode_option(
this: Option<Handle>,
encoder: &mut E,
out: &mut MaybeUninit<<Handle as EncodableOption>::EncodedOption>,
) -> Result<(), EncodeError>
fn encode_option( this: Option<Handle>, encoder: &mut E, out: &mut MaybeUninit<<Handle as EncodableOption>::EncodedOption>, ) -> Result<(), EncodeError>
Source§fn from(handle: Handle) -> IobSharedRegion
fn from(handle: Handle) -> IobSharedRegion
Source§fn from(x: IobSharedRegion) -> Handle
fn from(x: IobSharedRegion) -> Handle
Source§impl From<SuspendToken> for Handle
impl From<SuspendToken> for Handle
Source§fn from(x: SuspendToken) -> Handle
fn from(x: SuspendToken) -> Handle
§impl FromWire<WireHandle> for Handle
impl FromWire<WireHandle> for Handle
§fn from_wire(wire: WireHandle) -> Handle
fn from_wire(wire: WireHandle) -> Handle
wire
to this type.§const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
§impl FromWireOption<WireOptionalHandle> for Handle
impl FromWireOption<WireOptionalHandle> for Handle
§fn from_wire_option(wire: WireOptionalHandle) -> Option<Handle>
fn from_wire_option(wire: WireOptionalHandle) -> Option<Handle>
wire
to an option of this type.Source§impl HandleBased for Handle
impl HandleBased for Handle
Source§fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
Source§fn replace_handle(self, rights: Rights) -> Result<Self, Status>
fn replace_handle(self, rights: Rights) -> Result<Self, Status>
Source§fn into_handle(self) -> Handle
fn into_handle(self) -> Handle
Source§fn from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
Source§fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
Source§fn from_handle_based<H>(h: H) -> Selfwhere
H: HandleBased,
fn from_handle_based<H>(h: H) -> Selfwhere
H: HandleBased,
fn is_invalid_handle(&self) -> bool
Source§impl HandleFor<DefaultFuchsiaResourceDialect> for Handle
impl HandleFor<DefaultFuchsiaResourceDialect> for Handle
Source§type HandleInfo = HandleInfo
type HandleInfo = HandleInfo
Source§fn invalid() -> Handle
fn invalid() -> Handle
Handle
used as a place filler when
we remove handles from an array.Source§fn is_invalid(&self) -> bool
fn is_invalid(&self) -> bool
Source§impl Ord for Handle
impl Ord for Handle
Source§impl PartialOrd for Handle
impl PartialOrd for Handle
impl Eq for Handle
impl StructuralPartialEq for Handle
Auto Trait Implementations§
impl Freeze for Handle
impl RefUnwindSafe for Handle
impl Send for Handle
impl Sync for Handle
impl Unpin for Handle
impl UnwindSafe for Handle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> EncodableAsHandle for Twhere
T: HandleBased,
impl<T> EncodableAsHandle for Twhere
T: HandleBased,
Source§type Dialect = DefaultFuchsiaResourceDialect
type Dialect = DefaultFuchsiaResourceDialect
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
impl<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
§fn from_wire_option(wire: WireBox<'_, W>) -> Option<T>
fn from_wire_option(wire: WireBox<'_, W>) -> Option<T>
wire
to an option of this type.