pub struct Handle(/* private fields */);Expand description
An owned and valid Zircon handle to a kernel object.
This type 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 what operations are available.
§Lifecycle
This type closes the handle it owns when dropped.
§Layout
Option<Handle> is guaranteed to have the same layout and bit patterns as zx_handle_t.
Unlike many types in this crate it does not implement zerocopy traits because those are not
appropriate for types with real Drop implementations.
Implementations§
Source§impl Handle
impl Handle
Sourcepub unsafe fn from_raw(raw: zx_handle_t) -> Self
pub unsafe fn from_raw(raw: zx_handle_t) -> Self
Sourcepub fn check_raw_valid(raw: zx_handle_t) -> Result<(), Status>
pub fn check_raw_valid(raw: zx_handle_t) -> Result<(), Status>
Wraps the zx_handle_check_valid syscall.
Note that this does not guarantee that the handle is safe to pass to Handle::from_raw
in cases where another function may close the handle.
Sourcepub const fn raw_handle(&self) -> zx_handle_t
pub const fn raw_handle(&self) -> zx_handle_t
Returns the raw handle’s integer value.
Sourcepub fn into_raw(self) -> zx_handle_t
pub fn into_raw(self) -> zx_handle_t
Return the raw handle’s integer value without closing it when self is dropped.
Sourcepub fn duplicate(&self, rights: Rights) -> Result<Self, Status>
pub fn duplicate(&self, rights: Rights) -> Result<Self, Status>
Wraps the
zx_handle_duplicate
syscall.
Sourcepub fn replace(self, rights: Rights) -> Result<Self, Status>
pub fn replace(self, rights: Rights) -> Result<Self, Status>
Wraps the
zx_handle_replace
syscall.
Sourcepub fn signal(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
pub fn signal( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
Wraps the zx_object_signal syscall.
Sourcepub fn wait_one(
&self,
signals: Signals,
deadline: MonotonicInstant,
) -> WaitResult
pub fn wait_one( &self, signals: Signals, deadline: MonotonicInstant, ) -> WaitResult
Wraps the zx_object_wait_one
syscall.
Sourcepub fn wait_async(
&self,
port: &Port,
key: u64,
signals: Signals,
options: WaitAsyncOpts,
) -> Result<(), Status>
pub fn wait_async( &self, port: &Port, key: u64, signals: Signals, options: WaitAsyncOpts, ) -> Result<(), Status>
Wraps the zx_object_wait_async syscall.
Sourcepub fn get_name(&self) -> Result<Name, Status>
pub fn get_name(&self) -> Result<Name, Status>
Get the Property::NAME property for this object.
Wraps a call to the
zx_object_get_property
syscall for the ZX_PROP_NAME property.
Sourcepub fn set_name(&self, name: &Name) -> Result<(), Status>
pub fn set_name(&self, name: &Name) -> Result<(), Status>
Set the Property::NAME property for this object.
The name’s length must be less than sys::ZX_MAX_NAME_LEN, i.e. name.to_bytes_with_nul().len() <= sys::ZX_MAX_NAME_LEN, or Err(Status::INVALID_ARGS) will be returned.
Wraps a call to the
zx_object_get_property
syscall for the ZX_PROP_NAME property.
Sourcepub fn basic_info(&self) -> Result<HandleBasicInfo, Status>
pub fn basic_info(&self) -> Result<HandleBasicInfo, Status>
Wraps the zx_object_get_info syscall for the ZX_INFO_HANDLE_BASIC topic.
Sourcepub fn count_info(&self) -> Result<HandleCountInfo, Status>
pub fn count_info(&self) -> Result<HandleCountInfo, Status>
Wraps the zx_object_get_info syscall for the ZX_INFO_HANDLE_COUNT topic.