imdl/
files.rs

1use crate::common::*;
2
3#[derive(Debug)]
4pub(crate) struct Files {
5  root: PathBuf,
6  total_size: Bytes,
7  contents: Option<Vec<FilePath>>,
8}
9
10impl Files {
11  pub(crate) fn file(root: PathBuf, total_size: Bytes) -> Files {
12    Files {
13      contents: None,
14      root,
15      total_size,
16    }
17  }
18
19  pub(crate) fn dir(root: PathBuf, total_size: Bytes, contents: Vec<FilePath>) -> Files {
20    Files {
21      contents: Some(contents),
22      root,
23      total_size,
24    }
25  }
26
27  pub(crate) fn root(&self) -> &Path {
28    &self.root
29  }
30
31  pub(crate) fn contents(&self) -> Option<&[FilePath]> {
32    self.contents.as_deref()
33  }
34
35  pub(crate) fn total_size(&self) -> Bytes {
36    self.total_size
37  }
38}