Trait zircon_object::object::KernelObject
source · [−]pub trait KernelObject: DowncastSync + Debug {
Show 13 methods
fn id(&self) -> KoID;
fn type_name(&self) -> &str;
fn name(&self) -> String;
fn set_name(&self, name: &str);
fn signal(&self) -> Signal;
fn signal_set(&self, signal: Signal);
fn signal_clear(&self, signal: Signal);
fn signal_change(&self, clear: Signal, set: Signal);
fn add_signal_callback(&self, callback: SignalHandler);
fn get_child(&self, _id: KoID) -> ZxResult<Arc<dyn KernelObject>> { ... }
fn peer(&self) -> ZxResult<Arc<dyn KernelObject>> { ... }
fn related_koid(&self) -> KoID { ... }
fn allowed_signals(&self) -> Signal { ... }
}
Expand description
Common interface of a kernel object.
Implemented by impl_kobject
macro.
Required Methods
fn signal_set(&self, signal: Signal)
fn signal_set(&self, signal: Signal)
Assert signal
.
fn signal_clear(&self, signal: Signal)
fn signal_clear(&self, signal: Signal)
Deassert signal
.
fn signal_change(&self, clear: Signal, set: Signal)
fn signal_change(&self, clear: Signal, set: Signal)
Change signal status: first clear
then set
indicated bits.
All signal callbacks will be called.
fn add_signal_callback(&self, callback: SignalHandler)
fn add_signal_callback(&self, callback: SignalHandler)
Add callback
for signal status changes.
The callback
is a function of Fn(Signal) -> bool
.
It returns a bool indicating whether the handle process is over.
If true, the function will never be called again.
Provided Methods
Attempt to find a child of the object with given KoID.
If the object is a Process, the Threads it contains may be obtained.
If the object is a Job, its (immediate) child Jobs and the Processes it contains may be obtained.
If the object is a Resource, its (immediate) child Resources may be obtained.
fn peer(&self) -> ZxResult<Arc<dyn KernelObject>>
fn peer(&self) -> ZxResult<Arc<dyn KernelObject>>
Attempt to get the object’s peer.
An object peer is the opposite endpoint of a Channel
, Socket
, Fifo
, or EventPair
.
If the object is related to another (such as the other end of a channel, or the parent of a job), returns the KoID of that object, otherwise returns zero.
fn allowed_signals(&self) -> Signal
fn allowed_signals(&self) -> Signal
Get object’s allowed signals.
Implementations
sourceimpl dyn KernelObject
impl dyn KernelObject
sourcepub fn is<__T: KernelObject>(&self) -> bool
pub fn is<__T: KernelObject>(&self) -> bool
Returns true if the trait object wraps an object of type __T
.
sourcepub fn downcast<__T: KernelObject>(
self: Box<Self>
) -> Result<Box<__T>, Box<Self>>
pub fn downcast<__T: KernelObject>(
self: Box<Self>
) -> Result<Box<__T>, Box<Self>>
Returns a boxed object from a boxed trait object if the underlying object is of type
__T
. Returns the original boxed trait if it isn’t.
sourcepub fn downcast_rc<__T: KernelObject>(
self: Rc<Self>
) -> Result<Rc<__T>, Rc<Self>>
pub fn downcast_rc<__T: KernelObject>(
self: Rc<Self>
) -> Result<Rc<__T>, Rc<Self>>
Returns an Rc
-ed object from an Rc
-ed trait object if the underlying object is of
type __T
. Returns the original Rc
-ed trait if it isn’t.
sourcepub fn downcast_ref<__T: KernelObject>(&self) -> Option<&__T>
pub fn downcast_ref<__T: KernelObject>(&self) -> Option<&__T>
Returns a reference to the object within the trait object if it is of type __T
, or
None
if it isn’t.
sourcepub fn downcast_mut<__T: KernelObject>(&mut self) -> Option<&mut __T>
pub fn downcast_mut<__T: KernelObject>(&mut self) -> Option<&mut __T>
Returns a mutable reference to the object within the trait object if it is of type
__T
, or None
if it isn’t.
sourcepub fn downcast_arc<__T: KernelObject>(
self: Arc<Self>
) -> Result<Arc<__T>, Arc<Self>> where
__T: Any + Send + Sync,
pub fn downcast_arc<__T: KernelObject>(
self: Arc<Self>
) -> Result<Arc<__T>, Arc<Self>> where
__T: Any + Send + Sync,
Returns an Arc
-ed object from an Arc
-ed trait object if the underlying object is of
type __T
. Returns the original Arc
-ed trait if it isn’t.