Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alshdavid/ifilesystem-rs
Filesystem Abstraction for Rust
https://github.com/alshdavid/ifilesystem-rs
Last synced: 26 days ago
JSON representation
Filesystem Abstraction for Rust
- Host: GitHub
- URL: https://github.com/alshdavid/ifilesystem-rs
- Owner: alshdavid
- Created: 2024-11-07T04:29:20.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-07T04:36:25.000Z (about 2 months ago)
- Last Synced: 2024-11-24T19:19:12.736Z (about 1 month ago)
- Language: Rust
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# IFileSystem Rust
## File System Trait
This crate offers a trait that looks exactly like the `std::fs` interface and supplies implementations for the os filesystem and an in-memory filesystem.
Useful for substituting the FileSystem in tests and benchmarks
```rust
use ifilesystem::sync::FileSystem;
use ifilesystem::sync::os::OsFileSystem;
use ifilesystem::sync::mem::MemoryFileSystem;fn read_file(fs: &dyn FileSystem) {
let contents = fs.read(PathBuf::from("/path/to/file"))?;
println!("{}", contents.len())
}fn main() {
let os_fs = OsFileSystem::default();
let mem_fs = MemoryFileSystem::default();read_file(&os_fs);
read_file(&mem_fs);
}
```