pub struct Multipart { /* private fields */ }Expand description
Multipart form data extractor.
Extracts a complete multipart form including all fields and files.
§Example
ⓘ
use fastapi_core::{Multipart, FromRequest};
async fn upload(form: Multipart) -> String {
let description = form.get_field("description").unwrap_or("No description");
let file = form.get_file("document");
format!("Description: {}, File: {:?}", description, file.map(|f| f.filename()))
}Implementations§
Source§impl Multipart
impl Multipart
Sourcepub fn from_parts(parts: Vec<MultipartPart>) -> Self
pub fn from_parts(parts: Vec<MultipartPart>) -> Self
Create from parsed parts.
Sourcepub fn parts(&self) -> &[MultipartPart]
pub fn parts(&self) -> &[MultipartPart]
Get all parts.
Sourcepub fn get_file(&self, name: &str) -> Option<UploadedFile>
pub fn get_file(&self, name: &str) -> Option<UploadedFile>
Get an uploaded file by field name.
Sourcepub fn files(&self) -> Vec<UploadedFile>
pub fn files(&self) -> Vec<UploadedFile>
Get all files.
Sourcepub fn get_files(&self, name: &str) -> Vec<UploadedFile>
pub fn get_files(&self, name: &str) -> Vec<UploadedFile>
Get all files with a specific field name.
Trait Implementations§
Source§impl FromRequest for Multipart
impl FromRequest for Multipart
Source§type Error = MultipartExtractError
type Error = MultipartExtractError
Error type when extraction fails.
Source§async fn from_request(
ctx: &RequestContext,
req: &mut Request,
) -> Result<Self, Self::Error>
async fn from_request( ctx: &RequestContext, req: &mut Request, ) -> Result<Self, Self::Error>
Extract a value from the request. Read more
Auto Trait Implementations§
impl Freeze for Multipart
impl RefUnwindSafe for Multipart
impl Send for Multipart
impl Sync for Multipart
impl Unpin for Multipart
impl UnwindSafe for Multipart
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).