pub struct Checksum {
pub algorithm: ChecksumAlgorithm,
pub value: String,
}Expand description
A checksum algorithm and its canonical lowercase hexadecimal value.
Fields§
§algorithm: ChecksumAlgorithmAlgorithm that produced value.
value: StringThe canonical lowercase hexadecimal checksum without a prefix.
Implementations§
Source§impl Checksum
impl Checksum
Sourcepub fn compute(algorithm: ChecksumAlgorithm, bytes: &[u8]) -> Self
pub fn compute(algorithm: ChecksumAlgorithm, bytes: &[u8]) -> Self
Builds the algorithm checksum for these complete bytes.
The one-shot forms below are this with the algorithm spelled out, so a payload held whole and one delivered in pieces cannot drift: both close the same digest.
Sourcepub fn matches(&self, bytes: &[u8]) -> bool
pub fn matches(&self, bytes: &[u8]) -> bool
Reports whether these bytes produce this exact checksum.
Sourcepub fn validate(&self) -> Result<(), ChecksumValidationError>
pub fn validate(&self) -> Result<(), ChecksumValidationError>
Validates the exact width and lowercase-hex alphabet for algorithm.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Checksum
impl<'de> Deserialize<'de> for Checksum
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Checksum
impl StructuralPartialEq for Checksum
Auto Trait Implementations§
impl Freeze for Checksum
impl RefUnwindSafe for Checksum
impl Send for Checksum
impl Sync for Checksum
impl Unpin for Checksum
impl UnsafeUnpin for Checksum
impl UnwindSafe for Checksum
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more