pub struct OwnedPartHead { /* private fields */ }Available on crate feature
alloc only.Expand description
An owned copy of a PartHead. Its buffer is reused for the next head
copied into it, so a driver that keeps one never allocates per part once
the buffer has grown to the largest head.
§Examples
use form_net::{Boundary, Event, Limits, MultipartParser, OwnedPartHead, Policy};
let mut parser = MultipartParser::new(Boundary::new(b"X")?, &Limits::DEFAULT, &Policy::DEFAULT)?;
let body = b"--X\r\nContent-Disposition: form-data; name=\"a\"\r\n\r\n1\r\n--X--";
let mut kept = OwnedPartHead::new();
let step = parser.parse(body, true)?;
if let Event::PartStart(head) = step.event {
kept.copy_from(&head);
}
assert_eq!(kept.view().name(), "a");Implementations§
Source§impl OwnedPartHead
impl OwnedPartHead
Sourcepub fn new() -> OwnedPartHead
pub fn new() -> OwnedPartHead
An empty head; view of it is a field with no name.
Sourcepub fn with_capacity(capacity: usize) -> OwnedPartHead
pub fn with_capacity(capacity: usize) -> OwnedPartHead
An empty head whose buffer already holds capacity bytes.
Trait Implementations§
Source§impl Clone for OwnedPartHead
impl Clone for OwnedPartHead
Source§impl Debug for OwnedPartHead
impl Debug for OwnedPartHead
Source§impl Default for OwnedPartHead
impl Default for OwnedPartHead
Source§impl Drop for OwnedPartHead
impl Drop for OwnedPartHead
Auto Trait Implementations§
impl Freeze for OwnedPartHead
impl RefUnwindSafe for OwnedPartHead
impl Send for OwnedPartHead
impl Sync for OwnedPartHead
impl Unpin for OwnedPartHead
impl UnsafeUnpin for OwnedPartHead
impl UnwindSafe for OwnedPartHead
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