tiny.content.Reference
Defined in tiny.content.
The name of one piece of content passed by a caller to every read and every publication: what it hashes to and how long it is.
API (4)
Actions
Public operations.
fromBytes: Derives both halves of a reference from the complete bytes, as a caller does before publishing them, and returnsContentExtentExceededwhen the byte length does not fit an extent.verify: Checks borrowed bytes against this reference before a sink hands them to a provider, or when a caller receives bytes elsewhere.
Fields and members
Public fields and members.
Source
Source: lib/content/src/model.zig:87
zig
/// The name of one piece of content passed by a caller to every read and every/// publication: what it hashes to and how long it is. The struct holds an/// identifier and an extent as plain values that copy freely.pub const Reference = struct { identifier: Identifier, extent: Extent, /// Derives both halves of a reference from the complete bytes, as a caller /// does before publishing them, and returns `ContentExtentExceeded` when /// the byte length does not fit an extent. pub fn fromBytes( algorithm: Algorithm, bytes: []const u8, ) ReferenceError!Reference { return .{ .identifier = Identifier.fromBytes(algorithm, bytes), .extent = try Extent.fromUsize(bytes.len), }; } /// Checks borrowed bytes against this reference before a sink hands them to /// a provider, or when a caller receives bytes elsewhere. The function /// returns `ContentExtentMismatch` when the byte length differs from the /// extent, and `ContentIdentifierMismatch` when the digest of the bytes /// differs from the identifier. pub fn verify(self: Reference, bytes: []const u8) ReferenceError!void { if (bytes.len != self.extent.toUsize()) { return error.ContentExtentMismatch; } if (!self.identifier.matches(bytes)) { return error.ContentIdentifierMismatch; } }};Source: lib/content/src/root.zig:32
zig
pub const Reference = model.Reference;Audit
| Definitions | 3 |
|---|---|
| Public names | 3 |
| Members | 2 |
| Version | 26.7.0 |
| Revision | daab053ee433 |