remove treehouse-format crate and collapse everything into src
This commit is contained in:
parent
ca127a9411
commit
b792688776
66 changed files with 145 additions and 112 deletions
40
src/vfs/overlay.rs
Normal file
40
src/vfs/overlay.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use std::fmt;
|
||||
|
||||
use tracing::instrument;
|
||||
|
||||
use super::{entries, Dir, DynDir, Entries, Query, VPath, VPathBuf};
|
||||
|
||||
pub struct Overlay {
|
||||
base: DynDir,
|
||||
overlay: DynDir,
|
||||
}
|
||||
|
||||
impl Overlay {
|
||||
pub fn new(base: DynDir, overlay: DynDir) -> Self {
|
||||
Self { base, overlay }
|
||||
}
|
||||
|
||||
#[instrument("Overlay::dir", skip(self))]
|
||||
fn dir(&self, path: &VPath) -> Vec<VPathBuf> {
|
||||
let mut dir = entries(&self.base, path);
|
||||
dir.append(&mut entries(&self.overlay, path));
|
||||
dir.sort();
|
||||
dir.dedup();
|
||||
dir
|
||||
}
|
||||
}
|
||||
|
||||
impl Dir for Overlay {
|
||||
fn query(&self, path: &VPath, query: &mut Query) {
|
||||
query.provide(|| Entries(self.dir(path)));
|
||||
|
||||
self.overlay.query(path, query);
|
||||
self.base.query(path, query);
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Overlay {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "Overlay({:?}, {:?})", self.base, self.overlay)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue