Skip to main content

SendUpload

Trait SendUpload 

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

Operations on a single upload resource.

Required Methods§

Source

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

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

Source

fn get_info(&self) -> impl Future<Output = Result<UploadInfo, TusError>> + Send

Retrieve current metadata and offset.

Source

fn finalize(&mut self) -> impl Future<Output = Result<(), TusError>> + Send

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

Source

fn delete(self) -> impl Future<Output = Result<(), TusError>> + Send

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

Source

fn declare_length( &mut self, length: u64, ) -> impl Future<Output = Result<(), TusError>> + Send

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

Source

fn concatenate( &mut self, partials: &[UploadInfo], ) -> impl Future<Output = Result<(), TusError>> + Send

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

Source

fn read_content( &self, ) -> impl Future<Output = Result<Box<dyn AsyncRead + Send + Unpin>, TusError>> + Send

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§