change vfs API to something akin to the deleted std provider API
this gives us a _much_ easier time with composing file systems, since you can call `query` on the inner file system and all the magic will be done for you the overhead is technically slightly higher, but seems to be drowned out by other more expensive stuff; i couldn't measure a difference in my traces
This commit is contained in:
parent
5b6d637f44
commit
600651ec16
29 changed files with 418 additions and 611 deletions
|
@ -1,4 +1,4 @@
|
|||
use treehouse::vfs::{BufferedFile, Dir, VPath};
|
||||
use treehouse::vfs::{entries, query, BufferedFile, Content, VPath};
|
||||
|
||||
fn vfs() -> BufferedFile {
|
||||
BufferedFile::new(b"hewwo :3".to_vec())
|
||||
|
@ -7,23 +7,16 @@ fn vfs() -> BufferedFile {
|
|||
#[test]
|
||||
fn dir() {
|
||||
let vfs = vfs();
|
||||
assert!(vfs.dir(VPath::ROOT).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn content_version() {
|
||||
let vfs = vfs();
|
||||
assert!(
|
||||
vfs.content_version(VPath::ROOT).is_none(),
|
||||
"content_version is not implemented for BufferedFile for now"
|
||||
);
|
||||
assert!(entries(&vfs, VPath::ROOT).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn content() {
|
||||
let vfs = vfs();
|
||||
assert_eq!(
|
||||
vfs.content(VPath::ROOT).as_deref(),
|
||||
query::<Content>(&vfs, VPath::ROOT)
|
||||
.map(|c| c.bytes())
|
||||
.as_deref(),
|
||||
Some(b"hewwo :3".as_slice()),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue