Skip to main content

modo_upload/
from_multipart.rs

1/// Trait for parsing a struct from `multipart/form-data`.
2///
3/// Implement this trait (or derive it with `#[derive(FromMultipart)]`) to
4/// describe how multipart fields map to struct fields.  The
5/// [`MultipartForm`](crate::MultipartForm) extractor calls this automatically during request
6/// extraction.
7#[async_trait::async_trait]
8pub trait FromMultipart: Sized {
9    /// Parse `multipart` into `Self`, enforcing `max_file_size` on every file
10    /// field when `Some`.
11    async fn from_multipart(
12        multipart: &mut axum::extract::Multipart,
13        max_file_size: Option<usize>,
14    ) -> Result<Self, modo::Error>;
15}