pub struct PartMetadata {
pub generation: u64,
pub url_hash: [u8; 32],
pub content_len: u64,
pub chunk_size: u64,
pub chunk_count: u64,
pub bitmap: ChunkBitmap,
pub etag: Option<String>,
pub last_modified: Option<String>,
pub hash: HashConfig,
}Expand description
Persisted state for a resumable part file.
Fields§
§generation: u64Monotonic generation used to choose the newest metadata slot.
url_hash: [u8; 32]SHA-256 hash of the source URL.
content_len: u64Total content length in bytes.
chunk_size: u64Normalized chunk size in bytes.
chunk_count: u64Number of chunks in the resource.
bitmap: ChunkBitmapCompletion bitmap for all chunks.
etag: Option<String>Stored ETag validator, when available.
last_modified: Option<String>Stored Last-Modified validator, when available.
hash: HashConfigOptional final-file hash verification configuration.
Implementations§
Source§impl PartMetadata
impl PartMetadata
Sourcepub fn new(
url_hash: [u8; 32],
remote: &RemoteInfo,
chunk_size: u64,
hash: HashConfig,
) -> Result<Self>
pub fn new( url_hash: [u8; 32], remote: &RemoteInfo, chunk_size: u64, hash: HashConfig, ) -> Result<Self>
Creates metadata for a new part file.
Passing 0 for chunk_size selects the default chunk size.
§Errors
Returns an error if the chunk size is invalid, validator headers are too large for the metadata slot, or the completion bitmap cannot be sized.
Sourcepub fn completed_chunks(&self) -> u64
pub fn completed_chunks(&self) -> u64
Returns the number of completed chunks.
Sourcepub fn completed_bytes(&self) -> u64
pub fn completed_bytes(&self) -> u64
Returns the number of bytes represented by completed chunks.
Sourcepub fn all_complete(&self) -> bool
pub fn all_complete(&self) -> bool
Returns whether every chunk is complete.
Sourcepub fn ensure_compatible(
&self,
url_hash: [u8; 32],
remote: &RemoteInfo,
chunk_size: u64,
hash: HashConfig,
) -> Result<()>
pub fn ensure_compatible( &self, url_hash: [u8; 32], remote: &RemoteInfo, chunk_size: u64, hash: HashConfig, ) -> Result<()>
Verifies that existing metadata still matches a remote resource and caller configuration.
§Errors
Returns an error if the URL hash, content length, available validators, chunk size, or hash configuration differ from the stored metadata.
Sourcepub fn decode_slot(slot: &[u8]) -> Result<Self>
pub fn decode_slot(slot: &[u8]) -> Result<Self>
Decodes metadata from a fixed-size metadata slot.
§Errors
Returns an error if the slot is too short, has an unsupported version, fails CRC validation, has inconsistent lengths, or contains invalid UTF-8/header/hash data.
Trait Implementations§
Source§impl Clone for PartMetadata
impl Clone for PartMetadata
Source§fn clone(&self) -> PartMetadata
fn clone(&self) -> PartMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PartMetadata
impl Debug for PartMetadata
impl Eq for PartMetadata
Source§impl PartialEq for PartMetadata
impl PartialEq for PartMetadata
Source§fn eq(&self, other: &PartMetadata) -> bool
fn eq(&self, other: &PartMetadata) -> bool
self and other values to be equal, and is used by ==.