pub trait KernelObject: DowncastSync {
// Required methods
fn id(&self) -> KernelObjectId;
fn typ(&self) -> KernelObjectType;
}
Expand description
This trait should be implemented by all types that implement kernel objects, and allows common code to
be generic over all kernel objects. Kernel objects are generally handled as Arc<T>
where T
is the type
implementing KernelObject
, and so interior mutability should be used for data that needs to be mutable within
the kernel object.
Required Methods§
fn id(&self) -> KernelObjectId
fn typ(&self) -> KernelObjectType
Implementations§
Source§impl 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 $crate::alloc_reexport::rc::Rc
-ed object from an $crate::alloc_reexport::rc::Rc
-ed trait object if the underlying object is of
type __T
. Returns the original $crate::alloc_reexport::rc::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.