Struct Handle
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§
§impl Handle
impl Handle
pub const fn invalid() -> Handle
pub const fn invalid() -> Handle
Initialize a handle backed by ZX_HANDLE_INVALID, the only safe non-handle.
pub 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§
§impl AsHandleRef for Handle
impl AsHandleRef for Handle
§fn as_handle_ref(&self) -> Unowned<'_, Handle>
fn as_handle_ref(&self) -> Unowned<'_, Handle>
object_wait_many
.§fn raw_handle(&self) -> u32
fn raw_handle(&self) -> u32
§fn signal_handle(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
fn signal_handle( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
§fn wait_handle(
&self,
signals: Signals,
deadline: Instant<MonotonicTimeline>,
) -> WaitResult
fn wait_handle( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> WaitResult
§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>
§fn get_name(&self) -> Result<Name, Status>
fn get_name(&self) -> Result<Name, Status>
§fn set_name(&self, name: &Name) -> Result<(), Status>
fn set_name(&self, name: &Name) -> Result<(), Status>
§fn basic_info(&self) -> Result<HandleBasicInfo, Status>
fn basic_info(&self) -> Result<HandleBasicInfo, Status>
§fn count_info(&self) -> Result<HandleCountInfo, Status>
fn count_info(&self) -> Result<HandleCountInfo, Status>
Source§impl CompatFrom<Handle> for Handle
impl CompatFrom<Handle> for Handle
Source§fn compat_from(value: Handle) -> Handle
fn compat_from(value: Handle) -> Handle
value
into a value of this type.Source§impl Encodable for Handle
impl Encodable for Handle
Source§type Encoded = WireHandle
type Encoded = WireHandle
Source§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 moreSource§impl EncodableOption for Handle
impl EncodableOption for Handle
Source§type EncodedOption = WireOptionalHandle
type EncodedOption = WireOptionalHandle
Source§impl<E> EncodeOption<E> for Handlewhere
E: HandleEncoder + ?Sized,
impl<E> EncodeOption<E> for Handlewhere
E: HandleEncoder + ?Sized,
Source§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>
§fn from(handle: Handle) -> IobSharedRegion
fn from(handle: Handle) -> IobSharedRegion
§fn from(x: IobSharedRegion) -> Handle
fn from(x: IobSharedRegion) -> Handle
Source§impl FromWire<WireHandle> for Handle
impl FromWire<WireHandle> for Handle
Source§fn from_wire(wire: WireHandle) -> Handle
fn from_wire(wire: WireHandle) -> Handle
wire
to this type.Source§const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
Source§impl FromWireOption<WireOptionalHandle> for Handle
impl FromWireOption<WireOptionalHandle> for Handle
Source§fn from_wire_option(wire: WireOptionalHandle) -> Option<Handle>
fn from_wire_option(wire: WireOptionalHandle) -> Option<Handle>
wire
to an option of this type.§impl HandleBased for Handle
impl HandleBased for Handle
§fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
§fn replace_handle(self, rights: Rights) -> Result<Self, Status>
fn replace_handle(self, rights: Rights) -> Result<Self, Status>
§fn into_handle(self) -> Handle
fn into_handle(self) -> Handle
§fn from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
§fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
§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
§impl HandleFor<DefaultFuchsiaResourceDialect> for Handle
impl HandleFor<DefaultFuchsiaResourceDialect> for Handle
§type HandleInfo = HandleInfo
type HandleInfo = HandleInfo
§fn invalid() -> Handle
fn invalid() -> Handle
Handle
used as a place filler when
we remove handles from an array.§fn is_invalid(&self) -> bool
fn is_invalid(&self) -> bool
§impl Ord for Handle
impl Ord for Handle
§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
§impl<T> EncodableAsHandle for Twhere
T: HandleBased,
impl<T> EncodableAsHandle for Twhere
T: HandleBased,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
impl<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
Source§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.