pub struct MockDevice {
suspendable_switch: bool,
}Expand description
A mock device, for unit-tests.
Fields§
§suspendable_switch: boolImplementations§
Source§impl MockDevice
impl MockDevice
Sourcepub fn toggle_suspendable_switch(&mut self)
pub fn toggle_suspendable_switch(&mut self)
Changes the state of the device in a way that affects its snapshots.
Trait Implementations§
Source§impl BusDevice for MockDevice
impl BusDevice for MockDevice
Source§fn device_id(&self) -> DeviceId
fn device_id(&self) -> DeviceId
Returns a unique id per device type suitable for metrics gathering.
Source§fn debug_label(&self) -> String
fn debug_label(&self) -> String
Returns a label suitable for debug output.
Source§fn read(&mut self, info: BusAccessInfo, data: &mut [u8])
fn read(&mut self, info: BusAccessInfo, data: &mut [u8])
Performs a read access to this device, based on
info.Source§fn write(&mut self, info: BusAccessInfo, data: &[u8])
fn write(&mut self, info: BusAccessInfo, data: &[u8])
Performs a write access to this device, based on
info.Source§fn config_register_write(
&mut self,
reg_idx: usize,
offset: u64,
data: &[u8],
) -> ConfigWriteResult
fn config_register_write( &mut self, reg_idx: usize, offset: u64, data: &[u8], ) -> ConfigWriteResult
Sets a register in the configuration space. Only used by PCI. Read more
Source§fn config_register_read(&self, reg_idx: usize) -> u32
fn config_register_read(&self, reg_idx: usize) -> u32
Gets a register from the configuration space. Only used by PCI. Read more
Source§fn init_pci_config_mapping(
&mut self,
shmem: &SharedMemory,
base: usize,
len: usize,
) -> bool
fn init_pci_config_mapping( &mut self, shmem: &SharedMemory, base: usize, len: usize, ) -> bool
Provides a memory region to back MMIO access to the configuration
space. If the device can keep the memory region up to date, then it
should return true, after which no more calls to config_register_read
will be made. Otherwise the device should return false. Read more
Source§fn virtual_config_register_write(&mut self, reg_idx: usize, value: u32)
fn virtual_config_register_write(&mut self, reg_idx: usize, value: u32)
Sets a register in the virtual config space. Only used by PCI. Read more
Source§fn virtual_config_register_read(&self, reg_idx: usize) -> u32
fn virtual_config_register_read(&self, reg_idx: usize) -> u32
Gets a register from the virtual config space. Only used by PCI. Read more
Source§fn on_sandboxed(&mut self)
fn on_sandboxed(&mut self)
Invoked when the device is sandboxed.
Source§fn get_ranges(&self) -> Vec<(BusRange, BusType)>
fn get_ranges(&self) -> Vec<(BusRange, BusType)>
Gets a list of all ranges registered by this BusDevice.
Source§fn destroy_device(&mut self)
fn destroy_device(&mut self)
Invoked when the device is destroyed
Source§impl Clone for MockDevice
impl Clone for MockDevice
Source§fn clone(&self) -> MockDevice
fn clone(&self) -> MockDevice
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MockDevice
impl Debug for MockDevice
Source§impl Default for MockDevice
impl Default for MockDevice
Source§impl<'de> Deserialize<'de> for MockDevice
impl<'de> Deserialize<'de> for MockDevice
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for MockDevice
impl PartialEq for MockDevice
Source§impl Serialize for MockDevice
impl Serialize for MockDevice
Source§impl Suspendable for MockDevice
impl Suspendable for MockDevice
impl Copy for MockDevice
impl Eq for MockDevice
impl StructuralPartialEq for MockDevice
Auto Trait Implementations§
impl Freeze for MockDevice
impl RefUnwindSafe for MockDevice
impl Send for MockDevice
impl Sync for MockDevice
impl Unpin for MockDevice
impl UnwindSafe for MockDevice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.