Skip to documentation
SLOP

tiny.content.Identifier

Reference tiny.content Identifier

Defined in tiny.content.

Carries the identity of content, and nothing else about it, so a caller compares identifiers to decide whether two byte strings are the same.

API (5)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callstiny.contentIdentifier
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/content/src/model.zig:19

zig
/// Carries the identity of content, and nothing else about it, so a caller/// compares identifiers to decide whether two byte strings are the same. The/// struct holds two fields: the algorithm and its 32-byte digest, so it names/// no location, no provider, and no type.pub const Identifier = struct {    algorithm: Algorithm,    digest: [digest_bytes]u8,    /// Derives an identifier from the complete bytes by running the chosen hash    /// over every byte and pairing the digest with the algorithm tag.    pub fn fromBytes(algorithm: Algorithm, bytes: []const u8) Identifier {        var digest: [digest_bytes]u8 = undefined;        switch (algorithm) {            .blake3 => std.crypto.hash.Blake3.hash(bytes, &digest, .{}),            .sha256 => std.crypto.hash.sha2.Sha256.hash(bytes, &digest, .{}),        }        return .{ .algorithm = algorithm, .digest = digest };    }    /// Reports whether two identifiers carry the same algorithm and the same    /// digest, which is how a provider looks for an identifier among the ones    /// it holds. The check compares the digests in constant time, so the answer    /// leaks nothing about where they first differ.    pub fn eql(left: Identifier, right: Identifier) bool {        const algorithm_matches = left.algorithm == right.algorithm;        const digest_matches = std.crypto.timing_safe.eql(            [digest_bytes]u8,            left.digest,            right.digest,        );        return algorithm_matches and digest_matches;    }    /// Checks bytes a provider staged or read by rehashing them with this    /// identifier's algorithm and reporting whether the digests agree.    pub fn matches(self: Identifier, bytes: []const u8) bool {        return self.eql(fromBytes(self.algorithm, bytes));    }};

Source: lib/content/src/root.zig:30

zig
pub const Identifier = model.Identifier;
Called byCallsNo direct callsIdentifiermatchesIdentifiereql
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsReferencefromBytestest sourcelib.content.src.modeltest: raw content identifiers pin exa...IdentifierfromBytes
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsReferenceverifyIdentifiereqlIdentifiermatches
Static calls · unresolved targets: 1 · external targets: 0.

Audit

Definitions4
Public names4
Members2
Version26.7.0
Revisiondaab053ee433