Skip to main content

DbWithTestSystem

Trait DbWithTestSystem 

Source
pub trait DbWithTestSystem: Db + Sized {
    // Required methods
    fn test_system(&self) -> &TestSystem;
    fn test_system_mut(&mut self) -> &mut TestSystem;

    // Provided methods
    fn write_virtual_file(
        &mut self,
        path: impl AsRef<SystemVirtualPath>,
        content: impl AsRef<[u8]>,
    ) { ... }
    fn use_system<S>(&mut self, os: S)
       where S: WritableSystem + Send + Sync + RefUnwindSafe + 'static { ... }
    fn memory_file_system(&self) -> &MemoryFileSystem { ... }
}
Expand description

Extension trait for databases that use TestSystem.

Provides various helper function that ease testing.

Required Methods§

Provided Methods§

Source

fn write_virtual_file( &mut self, path: impl AsRef<SystemVirtualPath>, content: impl AsRef<[u8]>, )

Writes the content of the given virtual file.

§Panics

If the db isn’t using the InMemorySystem.

Source

fn use_system<S>(&mut self, os: S)
where S: WritableSystem + Send + Sync + RefUnwindSafe + 'static,

Uses the given system instead of the testing system.

This useful for testing advanced file system features like permissions, symlinks, etc.

Note that any files written to the memory file system won’t be copied over.

Source

fn memory_file_system(&self) -> &MemoryFileSystem

Returns the memory file system.

§Panics

If the underlying test system isn’t the InMemorySystem.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§