Skip to main content

shadow_crypt_shell/listing/
file.rs

1use std::path::PathBuf;
2
3use shadow_crypt_core::version::Version;
4
5use crate::memory::SecureString;
6
7pub struct ListingInput {
8    /// Password for decrypting original filenames; `None` lists only the
9    /// plaintext header metadata without any key derivation.
10    pub password: Option<SecureString>,
11    pub work_dir: PathBuf,
12    /// Print the listing as JSON instead of a table.
13    pub json: bool,
14}
15impl ListingInput {
16    pub fn new(password: Option<SecureString>, work_dir: PathBuf, json: bool) -> Self {
17        Self {
18            password,
19            work_dir,
20            json,
21        }
22    }
23}
24
25#[derive(Debug)]
26pub struct ShadowFile {
27    pub path: PathBuf,
28    pub filename: String,
29    pub version: Version,
30    /// Size of the file in bytes
31    pub size: u64,
32}
33impl ShadowFile {
34    pub fn new(path: PathBuf, filename: String, version: Version, size: u64) -> Self {
35        Self {
36            path,
37            filename,
38            version,
39            size,
40        }
41    }
42}
43
44#[derive(Debug, Clone)]
45pub struct ShadowFileInfo {
46    pub original_filename: Option<SecureString>,
47    pub obfuscated_filename: String,
48    pub version: Version,
49    pub size: u64,
50}
51impl ShadowFileInfo {
52    pub fn new(
53        original_filename: Option<SecureString>,
54        obfuscated_filename: String,
55        version: Version,
56        size: u64,
57    ) -> Self {
58        Self {
59            original_filename,
60            obfuscated_filename,
61            version,
62            size,
63        }
64    }
65}
66
67pub struct FileInfoList {
68    pub items: Vec<ShadowFileInfo>,
69}
70impl FileInfoList {
71    pub fn new(items: Vec<ShadowFileInfo>) -> Self {
72        Self { items }
73    }
74}