pub struct Multipart { /* private fields */ }Expand description
Multipart form data extractor
Parses multipart/form-data requests, commonly used for file uploads.
§Example
ⓘ
use rustapi_core::multipart::Multipart;
async fn upload(mut multipart: Multipart) -> Result<String, ApiError> {
while let Some(field) = multipart.next_field().await? {
let name = field.name().unwrap_or("unknown").to_string();
let data = field.bytes().await?;
println!("Received field '{}' with {} bytes", name, data.len());
}
Ok("Upload complete".to_string())
}Implementations§
Source§impl Multipart
impl Multipart
Sourcepub async fn next_field(&mut self) -> Result<Option<MultipartField>, ApiError>
pub async fn next_field(&mut self) -> Result<Option<MultipartField>, ApiError>
Get the next field from the multipart form
Sourcepub fn into_fields(self) -> Vec<MultipartField>
pub fn into_fields(self) -> Vec<MultipartField>
Collect all fields into a vector
Sourcepub fn field_count(&self) -> usize
pub fn field_count(&self) -> usize
Get the number of fields
Trait Implementations§
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