pub trait Device: Send + Sync {
// Required methods
fn device_type(&self) -> DeviceType;
fn name(&self) -> &'static str;
fn id(&self) -> usize;
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
// Provided methods
fn as_char_device(&mut self) -> Option<&mut dyn CharDevice> { ... }
fn as_block_device(&mut self) -> Option<&mut dyn BlockDevice> { ... }
}
Expand description
Device trait.
This trait defines the interface for devices in the kernel.
Required Methods§
fn device_type(&self) -> DeviceType
fn name(&self) -> &'static str
fn id(&self) -> usize
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Provided Methods§
Sourcefn as_char_device(&mut self) -> Option<&mut dyn CharDevice>
fn as_char_device(&mut self) -> Option<&mut dyn CharDevice>
Cast to CharDevice if this device is a character device
Sourcefn as_block_device(&mut self) -> Option<&mut dyn BlockDevice>
fn as_block_device(&mut self) -> Option<&mut dyn BlockDevice>
Cast to BlockDevice if this device is a block device