Skip to main content

UploadStore

Trait UploadStore 

Source
pub trait UploadStore: Send {
    type Handle: Send;
    type Upload: Send;
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn create(
        &mut self,
        head: &UploadHead,
        cancellation: &Cancellation,
    ) -> impl Future<Output = Result<Self::Upload, Self::Error>> + Send;
    fn write(
        &mut self,
        upload: &mut Self::Upload,
        content: &[u8],
        cancellation: &Cancellation,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn finish(
        &mut self,
        upload: &mut Self::Upload,
        cancellation: &Cancellation,
    ) -> impl Future<Output = Result<Self::Handle, Self::Error>> + Send;
    fn abort(
        &mut self,
        upload: Self::Upload,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn remove(
        &mut self,
        handle: Self::Handle,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
Expand description

Storage for uploads, which read_content streams each upload into as it arrives.

Each upload is created, written in pieces, and then finished, which gives the handle the declared struct holds in its Upload. An upload that fails, or whose content stops arriving, is aborted, and a finished upload whose content is refused is removed. FileStore stores uploads in files.

Uploads are stored before the whole body has been validated, so a store must not make an upload visible to anything else until the application accepts it.

Required Associated Types§

Source

type Handle: Send

What the declared struct holds for a stored upload, such as a path.

Source

type Upload: Send

An upload being stored.

Source

type Error: Error + Send + Sync + 'static

Why a store operation failed.

Required Methods§

Source

fn create( &mut self, head: &UploadHead, cancellation: &Cancellation, ) -> impl Future<Output = Result<Self::Upload, Self::Error>> + Send

Begin storing an upload. When this fails, nothing of the upload is stored.

The head’s filename and media type are what the client declared, and must not choose where the upload is stored.

Source

fn write( &mut self, upload: &mut Self::Upload, content: &[u8], cancellation: &Cancellation, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Store some of an upload’s content, after what was stored before. When this fails, the caller must abort the upload, as read_content does.

Source

fn finish( &mut self, upload: &mut Self::Upload, cancellation: &Cancellation, ) -> impl Future<Output = Result<Self::Handle, Self::Error>> + Send

Complete an upload whose content has all been written, returning its handle. When this fails, the caller must abort the upload, as read_content does.

Source

fn abort( &mut self, upload: Self::Upload, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Remove whatever was stored of an upload that was not finished, or whose finish failed. It is not cancellable, since it cleans up after a failure.

Source

fn remove( &mut self, handle: Self::Handle, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Remove a finished upload. It is not cancellable, since it cleans up after a failure.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§