pub struct VirtualDisk { /* private fields */ }Expand description
A crashable virtual disk with two-stage durability and fault knobs.
Implementations§
Source§impl VirtualDisk
impl VirtualDisk
Sourcepub fn set_write_failures(&mut self, enabled: bool)
pub fn set_write_failures(&mut self, enabled: bool)
Fails every write while enabled is true.
Sourcepub fn set_fsync_failures(&mut self, enabled: bool)
pub fn set_fsync_failures(&mut self, enabled: bool)
Fails every fsync while enabled is true.
Sourcepub fn fail_next_write(&mut self)
pub fn fail_next_write(&mut self)
Fails only the next write.
Sourcepub fn fail_next_fsync(&mut self)
pub fn fail_next_fsync(&mut self)
Fails only the next fsync.
Sourcepub fn set_torn_write_limit(&mut self, limit: Option<usize>)
pub fn set_torn_write_limit(&mut self, limit: Option<usize>)
Truncates every write to at most limit bytes (a torn write).
None disables truncation.
Sourcepub fn append(&mut self, path: &str, bytes: &[u8]) -> Result<usize, DiskError>
pub fn append(&mut self, path: &str, bytes: &[u8]) -> Result<usize, DiskError>
Appends bytes to the pending stage. Returns the number of bytes
accepted, which a torn write may shorten. The bytes are not
durable until VirtualDisk::fsync.
Sourcepub fn fsync(&mut self, path: &str) -> Result<(), DiskError>
pub fn fsync(&mut self, path: &str) -> Result<(), DiskError>
Moves all pending bytes of path to the durable stage.
Sourcepub fn read(&self, path: &str) -> Vec<u8> ⓘ
pub fn read(&self, path: &str) -> Vec<u8> ⓘ
Live view: durable bytes followed by not-yet-fsynced bytes.
Sourcepub fn read_durable(&self, path: &str) -> Vec<u8> ⓘ
pub fn read_durable(&self, path: &str) -> Vec<u8> ⓘ
Crash-recovery view: exactly the fsynced prefix.
Sourcepub fn durable_len(&self, path: &str) -> usize
pub fn durable_len(&self, path: &str) -> usize
Number of fsynced bytes for path.
Sourcepub fn pending_len(&self, path: &str) -> usize
pub fn pending_len(&self, path: &str) -> usize
Number of written-but-not-fsynced bytes for path.
Trait Implementations§
Source§impl Debug for VirtualDisk
impl Debug for VirtualDisk
Source§impl Default for VirtualDisk
impl Default for VirtualDisk
Source§fn default() -> VirtualDisk
fn default() -> VirtualDisk
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for VirtualDisk
impl RefUnwindSafe for VirtualDisk
impl Send for VirtualDisk
impl Sync for VirtualDisk
impl Unpin for VirtualDisk
impl UnsafeUnpin for VirtualDisk
impl UnwindSafe for VirtualDisk
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