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§
Sourceasync fn write_chunk(
&mut self,
offset: u64,
reader: &mut (dyn AsyncRead + Unpin + Send),
) -> Result<u64, TusError>
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.
Sourceasync fn get_info(&self) -> Result<UploadInfo, TusError>
async fn get_info(&self) -> Result<UploadInfo, TusError>
Retrieve current metadata and offset.
Sourceasync fn finalize(&mut self) -> Result<(), TusError>
async fn finalize(&mut self) -> Result<(), TusError>
Called once all bytes have been received (offset == size).
Sourceasync fn delete(self) -> Result<(), TusError>
async fn delete(self) -> Result<(), TusError>
Delete this upload and free all associated resources.
Called by the termination extension (DELETE). Return Err if unsupported.
Sourceasync fn declare_length(&mut self, length: u64) -> Result<(), TusError>
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.
Sourceasync fn concatenate(&mut self, partials: &[UploadInfo]) -> Result<(), TusError>
async fn concatenate(&mut self, partials: &[UploadInfo]) -> Result<(), TusError>
Assemble fully-uploaded partials (in order) into this final upload. Called by the concatenation extension.
Sourceasync fn read_content(
&self,
) -> Result<Box<dyn AsyncRead + Send + Unpin>, TusError>
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.