qubit_fs/metadata/checksum.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2026 Haixing Hu.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0.
8 *
9 ******************************************************************************/
10//! Content checksum metadata.
11
12use crate::ChecksumAlgorithm;
13
14/// Content checksum.
15#[derive(Clone, Debug, Eq, PartialEq)]
16pub struct Checksum {
17 /// Algorithm used to compute the checksum.
18 pub algorithm: ChecksumAlgorithm,
19 /// Encoded checksum value.
20 pub value: String,
21}
22
23impl Checksum {
24 /// Creates a checksum.
25 ///
26 /// # Parameters
27 /// - `algorithm`: Checksum algorithm.
28 /// - `value`: Encoded checksum value.
29 ///
30 /// # Returns
31 /// New checksum.
32 #[inline]
33 #[must_use]
34 pub fn new(algorithm: ChecksumAlgorithm, value: &str) -> Self {
35 Self {
36 algorithm,
37 value: value.to_owned(),
38 }
39 }
40}