Skip to main content

Upload

Trait Upload 

Source
pub trait Upload {
    // Required methods
    async fn write_chunk(
        &mut self,
        offset: u64,
        reader: &mut (dyn AsyncRead + Unpin + Send),
    ) -> Result<u64, TusError>;
    async fn get_info(&self) -> Result<UploadInfo, TusError>;
    async fn finalize(&mut self) -> Result<(), TusError>;
    async fn delete(self) -> Result<(), TusError>;
    async fn declare_length(&mut self, length: u64) -> Result<(), TusError>;
    async fn concatenate(
        &mut self,
        partials: &[UploadInfo],
    ) -> Result<(), TusError>;
    async fn read_content(
        &self,
    ) -> Result<Box<dyn AsyncRead + Send + Unpin>, TusError>;
}
Expand description

Operations on a single upload resource.

Required Methods§

Source

async fn write_chunk( &mut self, offset: u64, reader: &mut (dyn AsyncRead + Unpin + Send), ) -> Result<u64, TusError>

Write chunk data starting at offset, streaming from reader. Returns the number of bytes written.

Source

async fn get_info(&self) -> Result<UploadInfo, TusError>

Retrieve current metadata and offset.

Source

async fn finalize(&mut self) -> Result<(), TusError>

Called once all bytes have been received (offset == size).

Source

async fn delete(self) -> Result<(), TusError>

Delete this upload and free all associated resources. Called by the termination extension (DELETE). Return Err if unsupported.

Source

async fn declare_length(&mut self, length: u64) -> Result<(), TusError>

Set the definitive Upload-Length on a deferred-length upload. Called when the client provides Upload-Length on a PATCH request.

Source

async fn concatenate(&mut self, partials: &[UploadInfo]) -> Result<(), TusError>

Assemble fully-uploaded partials (in order) into this final upload. Called by the concatenation extension.

Source

async fn read_content( &self, ) -> Result<Box<dyn AsyncRead + Send + Unpin>, TusError>

Stream the completed upload bytes for HTTP GET (download) requests. Return TusError::UploadNotReadyForDownload when the upload is incomplete or not readable.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<TraitVariantBlanketType: SendUpload> Upload for TraitVariantBlanketType