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§
Required Methods§
Sourcefn create(
&mut self,
head: &UploadHead,
cancellation: &Cancellation,
) -> impl Future<Output = Result<Self::Upload, Self::Error>> + Send
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.
Sourcefn write(
&mut self,
upload: &mut Self::Upload,
content: &[u8],
cancellation: &Cancellation,
) -> impl Future<Output = Result<(), Self::Error>> + Send
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.
Sourcefn finish(
&mut self,
upload: &mut Self::Upload,
cancellation: &Cancellation,
) -> impl Future<Output = Result<Self::Handle, Self::Error>> + Send
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".