pub struct UploadState {
pub name: String,
pub uuid: String,
pub buffer: BytesMut,
pub last_activity: Instant,
}Expand description
State of an in-flight blob upload.
Stored per upload UUID. Chunk bytes are accumulated in buffer
until the final PUT arrives and the client-declared digest is
compared against a recompute over the buffer.
Fields§
§name: StringRepository name the upload belongs to.
uuid: StringUpload UUID generated by crate::registry::RegistryMeta::start_upload.
buffer: BytesMutAccumulated bytes.
last_activity: InstantWall-clock instant of the last activity on this session (creation or the most recent appended chunk). Used by the registry to evict idle sessions after a TTL (R2-7).
Implementations§
Source§impl UploadState
impl UploadState
Sourcepub fn new(name: impl Into<String>, uuid: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, uuid: impl Into<String>) -> Self
Build a new empty upload state.
Sourcepub fn append(&mut self, chunk: &Bytes) -> u64
pub fn append(&mut self, chunk: &Bytes) -> u64
Append a chunk, returning the new offset. Refreshes the last-activity timestamp so an actively-progressing upload is not swept by the idle-session TTL.
Sourcepub fn is_idle_for(&self, now: Instant, ttl: Duration) -> bool
pub fn is_idle_for(&self, now: Instant, ttl: Duration) -> bool
True when this session has been idle (no creation/append activity)
for at least ttl measured against now.
Sourcepub fn take_bytes(&mut self) -> Bytes
pub fn take_bytes(&mut self) -> Bytes
Take the accumulated bytes, leaving the buffer empty.
Trait Implementations§
Source§impl Clone for UploadState
impl Clone for UploadState
Source§fn clone(&self) -> UploadState
fn clone(&self) -> UploadState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more