3 use crate::extension::Extension;
5 #[derive(Debug, Clone, PartialEq, Eq)]
7 /// File's (relative) path
9 /// The bytes that compose the file.
10 /// Only used when the whole file is kept in-memory
11 pub contents_in_memory: Option<Vec<u8>>,
12 /// Note: extension here might be a misleading name since
13 /// we don't really care about any extension other than supported compression ones.
15 /// So, for example, if a file has pathname "image.jpeg", it does have a JPEG extension but will
16 /// be represented as a None over here since that's not an extension we're particularly interested in
17 pub extension: Option<Extension>,
21 pub fn from(path: &'a Path) -> crate::Result<Self> {
22 let extension = Extension::from(path.as_ref()).ok();
24 Ok(File { path, contents_in_memory: None, extension })