Skip to main content

shadow_crypt_core/
report.rs

1use std::time::Duration;
2
3use crate::algorithm::Algorithm;
4
5pub struct EncryptionReport {
6    pub input_filename: String,
7    pub output_filename: String,
8    pub duration: Duration,
9    pub algorithm: Algorithm,
10    /// Whether the original was deleted after successful encryption.
11    pub original_deleted: bool,
12}
13impl EncryptionReport {
14    pub fn new(
15        input_filename: String,
16        output_filename: String,
17        duration: Duration,
18        algorithm: Algorithm,
19        original_deleted: bool,
20    ) -> Self {
21        Self {
22            input_filename,
23            output_filename,
24            duration,
25            algorithm,
26            original_deleted,
27        }
28    }
29}
30
31pub struct DecryptionReport {
32    pub input_filename: String,
33    pub output_filename: String,
34    pub duration: Duration,
35    pub algorithm: Algorithm,
36}
37impl DecryptionReport {
38    pub fn new(
39        input_filename: String,
40        output_filename: String,
41        duration: Duration,
42        algorithm: Algorithm,
43    ) -> Self {
44        Self {
45            input_filename,
46            output_filename,
47            duration,
48            algorithm,
49        }
50    }
51}
52
53#[derive(Debug)]
54pub struct KeyDerivationReport {
55    pub algorithm: String,
56    pub algorithm_version: String,
57    pub memory_cost_kib: u32,
58    pub time_cost_iterations: u32,
59    pub parallelism: u32,
60    pub key_size_bytes: u8,
61    pub duration: std::time::Duration,
62}
63impl KeyDerivationReport {
64    /// Takes raw parameter values so the report stays independent of any
65    /// version-specific `KeyDerivationParams` type.
66    pub fn new(
67        algorithm: String,
68        algorithm_version: String,
69        memory_cost_kib: u32,
70        time_cost_iterations: u32,
71        parallelism: u32,
72        key_size_bytes: u8,
73        duration: std::time::Duration,
74    ) -> Self {
75        Self {
76            algorithm,
77            algorithm_version,
78            memory_cost_kib,
79            time_cost_iterations,
80            parallelism,
81            key_size_bytes,
82            duration,
83        }
84    }
85}