Skip to main content

shadow_crypt_shell/encryption/
file.rs

1use std::path::PathBuf;
2
3use shadow_crypt_core::profile::SecurityProfile;
4
5use crate::memory::SecureString;
6
7/// What an encryption work item refers to on disk.
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum InputKind {
10    /// A single file; its content becomes the encrypted content.
11    File,
12    /// A directory; its tree is archived into one encrypted file.
13    Directory,
14}
15
16#[derive(Debug, Clone, PartialEq, Eq)]
17pub struct EncryptionInputFile {
18    pub path: PathBuf,
19    /// Stored name: the file's name, or the directory's name for archives.
20    pub filename: String,
21    pub size: u64,
22    pub kind: InputKind,
23}
24
25pub struct EncryptionInput {
26    pub files: Vec<EncryptionInputFile>,
27    pub password: SecureString,
28    pub security_profile: SecurityProfile,
29    pub output_dir: PathBuf,
30    /// Suppress progress and per-file success output (errors still shown).
31    pub quiet: bool,
32    /// Delete originals after their encryption succeeds.
33    pub delete: bool,
34}
35impl EncryptionInput {
36    pub fn new(
37        files: Vec<EncryptionInputFile>,
38        password: SecureString,
39        security_profile: SecurityProfile,
40        output_dir: PathBuf,
41        quiet: bool,
42        delete: bool,
43    ) -> Self {
44        Self {
45            files,
46            password,
47            security_profile,
48            output_dir,
49            quiet,
50            delete,
51        }
52    }
53}
54
55pub struct EncryptionOutputFile {
56    pub path: PathBuf,
57    pub filename: String,
58}