pub struct ContentRef {
pub kind: ContentRefKind,
pub owner_namespace_id: NamespaceId,
pub content_id: ContentId,
pub size_bytes: u64,
pub checksum: Checksum,
}Expand description
A reference to one immutable content object.
The object must be durable before the reference is published.
Fields§
§kind: ContentRefKindContent strategy used by the referenced object.
owner_namespace_id: NamespaceIdNamespace that originally wrote the bytes.
content_id: ContentIdImmutable identity of the referenced object.
size_bytes: u64Complete byte length of the referenced content.
checksum: ChecksumMandatory checksum over the complete object.
Implementations§
Source§impl ContentRef
impl ContentRef
Sourcepub fn blob_v1(
owner_namespace_id: NamespaceId,
content_id: ContentId,
bytes: &[u8],
) -> Self
pub fn blob_v1( owner_namespace_id: NamespaceId, content_id: ContentId, bytes: &[u8], ) -> Self
Builds a reference to a freshly minted content object holding these bytes.
Every caller of this constructor moves the bytes through the LoonFS write path, so the checksum is trusted by construction.
Sourcepub fn blob_v1_streamed(
owner_namespace_id: NamespaceId,
content_id: ContentId,
size_bytes: u64,
digest: Sha256,
) -> Self
pub fn blob_v1_streamed( owner_namespace_id: NamespaceId, content_id: ContentId, size_bytes: u64, digest: Sha256, ) -> Self
Builds a content reference from a SHA-256 computed while streaming the payload.
Accepting the digest object, rather than an arbitrary checksum string, ensures that the checksum came from the LoonFS write path.
Sourcepub fn validate(&self) -> Result<(), ContentRefValidationError>
pub fn validate(&self) -> Result<(), ContentRefValidationError>
Reports whether the reference is well formed enough to publish.
This is a shape check on the reference itself; proving that the object exists and matches is the storage layer’s job.