pub struct UploadSession { /* private fields */ }Expand description
Active chunked upload session state.
Keeps track of user ID, upload ID, destination path, total file size, and which chunks have been uploaded successfully.
Implementations§
Source§impl UploadSession
impl UploadSession
Sourcepub const MIN_CHUNK_SIZE: u64 = MIN_CHUNK_SIZE
pub const MIN_CHUNK_SIZE: u64 = MIN_CHUNK_SIZE
Minimum chunk size recommended by Nextcloud (5 MiB).
Sourcepub const MAX_CHUNK_SIZE: u64 = MAX_CHUNK_SIZE
pub const MAX_CHUNK_SIZE: u64 = MAX_CHUNK_SIZE
Maximum chunk size recommended by Nextcloud (5 GiB).
Sourcepub const DEFAULT_CHUNK_SIZE: u64 = DEFAULT_CHUNK_SIZE
pub const DEFAULT_CHUNK_SIZE: u64 = DEFAULT_CHUNK_SIZE
Default chunk size used for uploads (10 MiB).
Sourcepub fn new(
user_id: impl Into<String>,
upload_id: impl Into<String>,
destination_path: impl Into<String>,
total_size: u64,
) -> Self
pub fn new( user_id: impl Into<String>, upload_id: impl Into<String>, destination_path: impl Into<String>, total_size: u64, ) -> Self
Creates a new upload session without any recorded chunks.
Sourcepub fn destination_path(&self) -> &str
pub fn destination_path(&self) -> &str
Destination WebDAV path or URI where the assembled file will be placed.
Sourcepub const fn total_size(&self) -> u64
pub const fn total_size(&self) -> u64
Total size in bytes of the complete file being uploaded.
Sourcepub fn mark_chunk_uploaded(&self, chunk_index: u32)
pub fn mark_chunk_uploaded(&self, chunk_index: u32)
Records that a chunk index has been uploaded successfully.
Sourcepub fn is_chunk_uploaded(&self, chunk_index: u32) -> bool
pub fn is_chunk_uploaded(&self, chunk_index: u32) -> bool
Checks whether a specific chunk index has been uploaded.
Sourcepub fn uploaded_chunks(&self) -> BTreeSet<u32>
pub fn uploaded_chunks(&self) -> BTreeSet<u32>
Returns a set of all chunk indices uploaded so far.
Sourcepub fn uploaded_chunk_count(&self) -> usize
pub fn uploaded_chunk_count(&self) -> usize
Number of chunks marked as successfully uploaded.
Sourcepub fn expected_chunk_count(&self, chunk_size: u64) -> Option<u32>
pub fn expected_chunk_count(&self, chunk_size: u64) -> Option<u32>
Calculates the expected total chunk count for the given chunk size.
Returns None if chunk_size is zero or if total chunk count overflows u32.
Sourcepub fn is_complete(&self, chunk_size: u64) -> bool
pub fn is_complete(&self, chunk_size: u64) -> bool
Whether all expected chunks for the given chunk size have been uploaded.
Sourcepub fn chunk_boundary(
&self,
chunk_index: u32,
chunk_size: u64,
) -> Option<ChunkBoundary>
pub fn chunk_boundary( &self, chunk_index: u32, chunk_size: u64, ) -> Option<ChunkBoundary>
Calculates the byte boundary for a single 1-based chunk index.
Returns None if chunk_size is zero, chunk_index is zero, or exceeds total chunk count.
Sourcepub fn chunk_boundaries(&self, chunk_size: u64) -> Option<Vec<ChunkBoundary>>
pub fn chunk_boundaries(&self, chunk_size: u64) -> Option<Vec<ChunkBoundary>>
Calculates all chunk boundaries for this upload given a chunk size.
Returns None if chunk_size is zero or if total chunk count overflows u32.