#[non_exhaustive]pub enum MultipartEvent<'p> {
PartStart(PartHead<'p>),
Data(&'p [u8]),
PartEnd(PartSummary),
End,
NeedInput,
}Expand description
What the parser found.
Per part the order is always PartStart, any number of Data (none for
an empty part), PartEnd. A Data slice is never empty. After the last
part comes End. NeedInput can appear anywhere between.
Debug prints the length of Data, never the bytes.
§Examples
let mut rest = &b"--X\r\nContent-Disposition: form-data; name=a\r\n\r\n12\r\n--X--"[..];
let mut seen = String::new();
loop {
let step = parser.parse(rest, true)?;
rest = &rest[step.consumed..];
match step.event {
MultipartEvent::PartStart(head) => seen.push_str(head.name()),
MultipartEvent::Data(bytes) => seen.push_str(&format!(" {}", bytes.len())),
MultipartEvent::PartEnd(_) => seen.push_str(" end"),
MultipartEvent::End | MultipartEvent::NeedInput => break,
_ => {}
}
}
assert_eq!(seen, "a 2 end");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
PartStart(PartHead<'p>)
A part’s headers were read and checked.
Data(&'p [u8])
Bytes of the current part’s data.
PartEnd(PartSummary)
The current part ended.
End
The close delimiter was read: the form is complete.
NeedInput
Every byte given was consumed; give more.
Trait Implementations§
Auto Trait Implementations§
impl<'p> Forget for MultipartEvent<'p>
impl<'p> Freeze for MultipartEvent<'p>
impl<'p> Move for MultipartEvent<'p>
impl<'p> RefUnwindSafe for MultipartEvent<'p>
impl<'p> Send for MultipartEvent<'p>
impl<'p> Sync for MultipartEvent<'p>
impl<'p> Unpin for MultipartEvent<'p>
impl<'p> UnsafeUnpin for MultipartEvent<'p>
impl<'p> UnwindSafe for MultipartEvent<'p>
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