Skip to main content

UploadSession

Struct UploadSession 

Source
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

Source

pub const MIN_CHUNK_SIZE: u64 = MIN_CHUNK_SIZE

Minimum chunk size recommended by Nextcloud (5 MiB).

Source

pub const MAX_CHUNK_SIZE: u64 = MAX_CHUNK_SIZE

Maximum chunk size recommended by Nextcloud (5 GiB).

Source

pub const DEFAULT_CHUNK_SIZE: u64 = DEFAULT_CHUNK_SIZE

Default chunk size used for uploads (10 MiB).

Source

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.

Source

pub fn user_id(&self) -> &str

User ID of the upload owner.

Source

pub fn upload_id(&self) -> &str

Unique identifier for this upload session.

Source

pub fn destination_path(&self) -> &str

Destination WebDAV path or URI where the assembled file will be placed.

Source

pub const fn total_size(&self) -> u64

Total size in bytes of the complete file being uploaded.

Source

pub fn mark_chunk_uploaded(&self, chunk_index: u32)

Records that a chunk index has been uploaded successfully.

Source

pub fn is_chunk_uploaded(&self, chunk_index: u32) -> bool

Checks whether a specific chunk index has been uploaded.

Source

pub fn uploaded_chunks(&self) -> BTreeSet<u32>

Returns a set of all chunk indices uploaded so far.

Source

pub fn uploaded_chunk_count(&self) -> usize

Number of chunks marked as successfully uploaded.

Source

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.

Source

pub fn is_complete(&self, chunk_size: u64) -> bool

Whether all expected chunks for the given chunk size have been uploaded.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for UploadSession

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UploadSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more