pub struct RecordValidator { /* private fields */ }Expand description
Validates exactly one canonical record supplied in arbitrary fragments.
feed returns how many bytes it consumed. Once the record is complete it
consumes nothing more, so bytes that follow the record stay with the caller.
Errors are terminal: later input cannot turn the validator into a record.
Implementations§
Source§impl RecordValidator
impl RecordValidator
pub fn new() -> Self
Sourcepub fn feed(&mut self, input: &[u8]) -> Result<usize, RecordError>
pub fn feed(&mut self, input: &[u8]) -> Result<usize, RecordError>
Consume a prefix of input and return its length. Stops at the
record’s end; the remaining input is not part of this record.
Sourcepub fn canonical_len(&self) -> Option<usize>
pub fn canonical_len(&self) -> Option<usize>
The exact canonical length once the complete prefix has been read. It is not evidence that the data, hashes or Mark are valid.
Sourcepub fn prefix(&self) -> &[u8] ⓘ
pub fn prefix(&self) -> &[u8] ⓘ
The canonical bytes before the Blob data received so far: the complete
prefix once canonical_len is known.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether the record has been completely received and verified.
Sourcepub fn finish(self) -> Result<ValidatedHeader, RecordError>
pub fn finish(self) -> Result<ValidatedHeader, RecordError>
The verified header of a complete record.