Add a sad Python script for Ouch testing
[ouch.git] / src / file.rs
blobfb4e634b6bbf840a073356152d7055cf08b358cd
1 use std::path::PathBuf;
3 use crate::extension::Extension;
6 #[derive(Debug, Clone, PartialEq, Eq)]
7 pub struct File {
8     /// File's (relative) path
9     pub path: PathBuf,
10     /// The bytes that compose the file.
11     /// Only used when the whole file is kept in-memory
12     pub contents_in_memory: Option<Vec<u8>>,
13     /// Note: extension here might be a misleading name since
14     /// we don't really care about any extension other than supported compression ones.
15     ///
16     /// So, for example, if a file has pathname "image.jpeg", it does have a JPEG extension but will
17     /// be represented as a None over here since that's not an extension we're particularly interested in
18     pub extension: Option<Extension>
21 impl From<(PathBuf, Extension)> for File {
22     fn from((path, format): (PathBuf, Extension)) -> Self {
23         Self {
24             path,
25             contents_in_memory: None,
26             extension: Some(format),
27         }
28     }