Skip to main content

entrouter_universal/
verify.rs

1/// The result of a verification operation.
2///
3/// Contains the decoded bytes, their fingerprint, and whether the data
4/// passed integrity checks.
5#[derive(Debug, Clone, PartialEq)]
6pub struct VerifyResult {
7    /// `true` if the fingerprint matched the original.
8    pub intact: bool,
9    /// The decoded raw bytes.
10    pub decoded: Vec<u8>,
11    /// SHA-256 fingerprint of the decoded data.
12    pub fingerprint: String,
13}
14
15impl std::fmt::Display for VerifyResult {
16    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17        if self.intact {
18            write!(f, "Intact (fp: {}...)", &self.fingerprint[..16])
19        } else {
20            write!(f, "Violated")
21        }
22    }
23}