pub struct Record { /* private fields */ }Expand description
A validated record: verified canonical bytes from one retained source.
Its metadata (fields, links, By/Mark, lengths, containment) is always in
memory. The complete bytes are available as one slice only where the
source is contiguous; Record::read_at reads any source in bounded
pieces. Clones share the source. Equality and hashing use the record hash.
Implementations§
Source§impl Record
impl Record
Sourcepub fn from_bytes(bytes: impl Into<Vec<u8>>) -> Result<Record, RecordError>
pub fn from_bytes(bytes: impl Into<Vec<u8>>) -> Result<Record, RecordError>
Validate complete canonical record bytes (Lace-010) and own them.
pub fn hash(&self) -> RecordHash
pub fn kind(&self) -> RecordKind
Sourcepub fn canonical_len(&self) -> usize
pub fn canonical_len(&self) -> usize
The complete canonical length in bytes.
Sourcepub fn metadata(&self) -> RecordMetadata<'_>
pub fn metadata(&self) -> RecordMetadata<'_>
The canonical non-payload prefix and everything derived from it.
Sourcepub fn contiguous_bytes(&self) -> Option<&[u8]>
pub fn contiguous_bytes(&self) -> Option<&[u8]>
The complete canonical bytes, when the source holds them contiguously: memory and native mmap records, not file ranges.
Sourcepub fn contiguous_data(&self) -> Option<&[u8]>
pub fn contiguous_data(&self) -> Option<&[u8]>
The Blob data, when the source holds it contiguously.
Sourcepub fn read_at(&self, offset: usize, buffer: &mut [u8]) -> Result<usize, Error>
pub fn read_at(&self, offset: usize, buffer: &mut [u8]) -> Result<usize, Error>
Copy canonical bytes starting at offset into buffer and return how
many were copied: fewer than buffer.len() only at the record’s end.
A file-range record reads its file at the matching position.
Sourcepub fn to_vec(&self, limit: usize) -> Result<Vec<u8>, RecordReadError>
pub fn to_vec(&self, limit: usize) -> Result<Vec<u8>, RecordReadError>
The complete canonical bytes, if at most limit bytes long.
Sourcepub fn data_to_vec(&self, limit: usize) -> Result<Vec<u8>, RecordReadError>
pub fn data_to_vec(&self, limit: usize) -> Result<Vec<u8>, RecordReadError>
The Blob data, if at most limit bytes long.