#[non_exhaustive]pub enum Progress<'d, F> {
Field {
name: &'d str,
value: &'d [u8],
},
File(F),
NeedInput,
End,
}Available on crate feature
alloc only.Expand description
What completed during a Driver::push. Debug shows a field’s name
and value length, never the value.
§Examples
let body = b"--X\r\nContent-Disposition: form-data; name=a\r\n\r\n1\r\n--X\r\nContent-Disposition: form-data; name=f; filename=a.txt\r\n\r\nhi\r\n--X--";
let (mut pos, mut seen) = (0, Vec::new());
loop {
let (n, progress) = driver.push(&body[pos..], true, &mut NoInspector)?;
pos += n;
match progress {
Progress::Field { name, value } => seen.push(format!("{name}: {} bytes", value.len())),
Progress::File(file) => seen.push(format!("file: {} bytes", file.len())),
_ => break, // End; NeedInput would mean the body was cut short
}
}
assert_eq!(seen, ["a: 1 bytes", "file: 2 bytes"]);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.
Field
A text field ended: its name and value.
File(F)
A file part ended: the sink’s output.
NeedInput
Every byte given was consumed; give more.
End
The form is complete.
Trait Implementations§
Auto Trait Implementations§
impl<'d, F> Forget for Progress<'d, F>
impl<'d, F> Freeze for Progress<'d, F>where
F: Freeze,
impl<'d, F> Move for Progress<'d, F>
impl<'d, F> RefUnwindSafe for Progress<'d, F>where
F: RefUnwindSafe,
impl<'d, F> Send for Progress<'d, F>where
F: Send,
impl<'d, F> Sync for Progress<'d, F>where
F: Sync,
impl<'d, F> Unpin for Progress<'d, F>where
F: Unpin,
impl<'d, F> UnsafeUnpin for Progress<'d, F>where
F: UnsafeUnpin,
impl<'d, F> UnwindSafe for Progress<'d, F>where
F: 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