Struct texlang_common::InMemoryFileSystem
source · pub struct InMemoryFileSystem { /* private fields */ }
Expand description
In-memory filesystem for use in unit tests.
This type mocks out the file system operations in the VM. It provides an in-memory system to which “files” can be added before the test runs. It is designed to help test primitives that interact with the filesystem.
Given a VM, the file system can be set as follows:
#[derive(Default)]
struct State {
file_system: Rc<RefCell<InMemoryFileSystem>>,
}
let mut vm = vm::VM::<State>::new_with_built_in_commands(
HashMap::new(), // empty set of built-in commands
);
let mut mock_file_system = InMemoryFileSystem::new(&vm.working_directory.as_ref().unwrap());
mock_file_system.add("file/path.tex", "file content");
vm.state.file_system = Rc::new(RefCell::new(mock_file_system));
Implementations§
Trait Implementations§
source§impl Default for InMemoryFileSystem
impl Default for InMemoryFileSystem
source§fn default() -> InMemoryFileSystem
fn default() -> InMemoryFileSystem
Returns the “default value” for a type. Read more
source§impl FileSystem for InMemoryFileSystem
impl FileSystem for InMemoryFileSystem
Auto Trait Implementations§
impl RefUnwindSafe for InMemoryFileSystem
impl Send for InMemoryFileSystem
impl Sync for InMemoryFileSystem
impl Unpin for InMemoryFileSystem
impl UnwindSafe for InMemoryFileSystem
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