pub struct Checksum(/* private fields */);Expand description
A 32-byte SHA-256 object id.
Byte-wise ordering matches lexicographic ordering of the lowercase hex
form, so sorting Checksum values reproduces the ASCII-checksum sort order
the on-disk format uses (for example ostree.sizes entry order).
Implementations§
Source§impl Checksum
impl Checksum
Sourcepub fn from_bytes(b: [u8; 32]) -> Checksum
pub fn from_bytes(b: [u8; 32]) -> Checksum
Wrap raw digest bytes.
Sourcepub fn sha256(data: &[u8]) -> Checksum
pub fn sha256(data: &[u8]) -> Checksum
The SHA-256 digest of data. This is the object identity of a
metadata object, whose hashed bytes are its serialized GVariant form.
Sourcepub fn from_hex_lower(s: &str) -> Result<Checksum>
pub fn from_hex_lower(s: &str) -> Result<Checksum>
Parse 64 hex chars in the lowercase rendering to_hex
emits, refusing an uppercase character.
This is the rule a revision is read by: a 64-character name is a
checksum in lowercase hex alone, and an uppercase or mixed-case name of
that length is a ref name (docs/format-reference.md, “Revision
syntax”). The lenient from_hex stays where a
checksum arrives as stored bytes rather than as a name.
Sourcepub fn from_hex(s: &str) -> Result<Checksum>
pub fn from_hex(s: &str) -> Result<Checksum>
Parse 64 hex chars. Accepts either case; emits lowercase.
Sourcepub fn from_ay(b: &[u8]) -> Result<Checksum>
pub fn from_ay(b: &[u8]) -> Result<Checksum>
Interpret a GVariant ay payload as a checksum; the array must be
exactly 32 bytes.
Sourcepub fn from_base64(s: &str) -> Result<Checksum>
pub fn from_base64(s: &str) -> Result<Checksum>
Parse standard, padded base64 (exactly 44 chars ending in =).
Sourcepub fn to_base64_modified(&self) -> String
pub fn to_base64_modified(&self) -> String
Render as modified base64 (standard base64 with / replaced by _ and
trailing = dropped, 43 chars), used for static-delta directory names.
Sourcepub fn from_base64_modified(s: &str) -> Result<Checksum>
pub fn from_base64_modified(s: &str) -> Result<Checksum>
Parse modified base64 (exactly 43 unpadded chars).
Trait Implementations§
impl Copy for Checksum
impl Eq for Checksum
Source§impl GvEncode for Checksum
A checksum encodes as its raw 32-byte ay. Decoding is done through
Checksum::from_ay, which reports Error::InvalidChecksum on a wrong
width, so no GvDecode impl is provided.
impl GvEncode for Checksum
A checksum encodes as its raw 32-byte ay. Decoding is done through
Checksum::from_ay, which reports Error::InvalidChecksum on a wrong
width, so no GvDecode impl is provided.
Source§impl GvType for Checksum
impl GvType for Checksum
Source§const SIGNATURE: &'static str = "ay"
const SIGNATURE: &'static str = "ay"
Source§const FIXED_SIZE: Option<usize> = None
const FIXED_SIZE: Option<usize> = None
None.