pub struct Boundary { /* private fields */ }Expand description
A validated boundary with its delimiter (CRLF "--" boundary, 5 to 74
bytes) and the failure table of the streaming matcher, built once.
Debug prints the boundary: it is not secret.
§Examples
use form_net::Boundary;
let b = Boundary::new(b"----WebKitFormBoundaryx7Y")?;
assert_eq!(b.delimiter(), b"\r\n------WebKitFormBoundaryx7Y");
assert!(Boundary::new(b"").is_err());
assert!(Boundary::new(&[b'a'; 71]).is_err());
assert!(Boundary::new(b"ends with space ").is_err());
assert!(Boundary::new(b"has\"quote").is_err());
assert_eq!(Boundary::parse(b"multipart/form-data; boundary=\"a b\"")?.as_bytes(), b"a b");Implementations§
Source§impl Boundary
impl Boundary
Sourcepub fn parse(content_type: &[u8]) -> Result<Boundary, FormError>
pub fn parse(content_type: &[u8]) -> Result<Boundary, FormError>
Reads the boundary from a whole multipart/form-data Content-Type
value.
§Errors
UnsupportedMediaType for any other media type;
Syntax { InvalidContentType | MissingBoundary | DuplicateBoundary | InvalidBoundary }.
§Examples
let b = form_net::Boundary::parse(b"multipart/form-data; boundary=----x")?;
assert_eq!(b.as_bytes(), b"----x");
assert!(form_net::Boundary::parse(b"text/plain").is_err());Trait Implementations§
impl Copy for Boundary
impl Eq for Boundary
impl StructuralPartialEq for Boundary
Auto Trait Implementations§
impl Freeze for Boundary
impl RefUnwindSafe for Boundary
impl Send for Boundary
impl Sync for Boundary
impl Unpin for Boundary
impl UnsafeUnpin for Boundary
impl UnwindSafe for Boundary
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