pub struct MultipartReader<R: Read> { /* private fields */ }Available on crate feature
std only.Expand description
Reads a multipart body from a blocking reader, one part at a time.
It has no hooks: the caller sees each part itself. Dropping a
PartReader before its end skips the rest of the part at the next
next_part.
§Examples
use std::io::Read;
let body = b"--X\r\nContent-Disposition: form-data; name=note\r\n\r\nhi\r\n--X\r\nContent-Disposition: form-data; name=f; filename=a.bin\r\n\r\n0123\r\n--X--";
let mut reader = form_net::MultipartReader::new(b"multipart/form-data; boundary=X", &body[..])?;
let mut seen = Vec::new();
while let Some(mut part) = reader.next_part()? {
if part.head().view().is_file() {
let mut bytes = Vec::new();
part.read_to_end(&mut bytes).unwrap();
seen.push(bytes.len());
} else {
seen.push(part.text()?.len());
}
}
assert_eq!(seen, [2, 4]);Implementations§
Source§impl<R: Read> MultipartReader<R>
impl<R: Read> MultipartReader<R>
Trait Implementations§
Source§impl<R: Read> Debug for MultipartReader<R>
impl<R: Read> Debug for MultipartReader<R>
Source§impl<R: Read> Drop for MultipartReader<R>
impl<R: Read> Drop for MultipartReader<R>
Auto Trait Implementations§
impl<R> Freeze for MultipartReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for MultipartReader<R>where
R: RefUnwindSafe,
impl<R> Send for MultipartReader<R>where
R: Send,
impl<R> Sync for MultipartReader<R>where
R: Sync,
impl<R> Unpin for MultipartReader<R>where
R: Unpin,
impl<R> UnsafeUnpin for MultipartReader<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for MultipartReader<R>where
R: UnwindSafe,
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