kernel::object

Trait KernelObject

Source
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§

Implementations§

Source§

impl dyn KernelObject

Source

pub fn is<__T: KernelObject>(&self) -> bool

Returns true if the trait object wraps an object of type __T.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn downcast_arc<__T>(self: Arc<Self>) -> Result<Arc<__T>, Arc<Self>>
where __T: Any + Send + Sync + KernelObject,

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.

Implementors§