pub struct UploadValidator { /* private fields */ }Expand description
Validates one UploadPack stream’s framing, chunk by chunk, without
buffering or hashing. After any error the stream is dead: every later
call returns that same error.
Implementations§
Source§impl UploadValidator
impl UploadValidator
Sourcepub fn new(
pack_id: Option<&[u8]>,
total_bytes: Option<u64>,
limits: UploadLimits,
) -> Result<Self, UploadError>
pub fn new( pack_id: Option<&[u8]>, total_bytes: Option<u64>, limits: UploadLimits, ) -> Result<Self, UploadError>
Start validating from the header’s pack_id and total_bytes
(None when absent).
§Errors
UploadError::BadPackId, UploadError::TotalMissing or
UploadError::TotalTooLarge.
Sourcepub fn push(
&mut self,
chunk_pack_id: Option<&[u8]>,
offset: Option<u64>,
data_len: usize,
last: bool,
) -> Result<Progress, UploadError>
pub fn push( &mut self, chunk_pack_id: Option<&[u8]>, offset: Option<u64>, data_len: usize, last: bool, ) -> Result<Progress, UploadError>
Account for one chunk carrying data_len bytes.
§Errors
UploadError::AfterLast, UploadError::TooManyChunks,
UploadError::BadPackId, UploadError::PackIdMismatch,
UploadError::OffsetMissing, UploadError::OffsetGap,
UploadError::ByteCountOverflow, UploadError::Overrun or, on the
last chunk, UploadError::LengthMismatch. After any error, this
and every later call return that same error, and nothing the failed
chunk carried is counted.
Sourcepub fn finish(self) -> Result<UploadDone, UploadError>
pub fn finish(self) -> Result<UploadDone, UploadError>
End of stream.
§Errors
The error that killed the stream, if any; otherwise
UploadError::NoLast if the last chunk never arrived.