Skip to main content

ErrorKind

Enum ErrorKind 

Source
#[non_exhaustive]
#[repr(u8)]
pub enum ErrorKind {
Show 49 variants Empty = 0, NotToken = 1, InvalidByte = 2, BareCr = 3, LineFeed = 4, Nul = 5, Control = 6, UnterminatedQuote = 7, InvalidQuotedPair = 8, UnbalancedComment = 9, CommentTooDeep = 10, TooManyMembers = 11, TooManyEmptyElements = 12, TrailingSeparator = 13, ExpectedSeparator = 14, TrailingData = 15, DuplicateParameter = 16, MissingValue = 17, InvalidNumber = 18, NumberOverflow = 19, OutOfRange = 20, InvalidDate = 21, WeekdayMismatch = 22, InvalidMediaType = 23, Wildcard = 24, InvalidBoundary = 25, InvalidQValue = 26, InvalidEntityTag = 27, InvalidRange = 28, InvalidCharset = 29, UnsupportedCharset = 30, InvalidPercentEncoding = 31, InvalidUtf8 = 32, ControlInDecoded = 33, InvalidHost = 34, InvalidPort = 35, InvalidAddress = 36, InvalidOrigin = 37, InvalidKey = 38, TooLong = 39, InvalidBase64 = 40, InvalidEncodedWord = 41, SectionGap = 42, TooManySections = 43, InvalidAddrSpec = 44, LineTooLong = 45, Malformed = 46, TooManyHops = 47, BufferTooSmall = 48,
}
Expand description

What a parser refused.

Every variant names what was refused. Unless a variant says otherwise, the caller’s response is the same: treat the field as malformed. For a request field that means refusing the request (HTTP 400) or ignoring the field where its RFC allows that; for a field a server produced, it means a bug in the producer.

The enum is #[non_exhaustive]: new kinds may be added in minor versions.

§Examples

use parse_net::{scan, ErrorKind};

let err = scan::check_field_value(b"a\rb").unwrap_err();
assert_eq!(err.kind(), ErrorKind::BareCr);
assert_eq!(ErrorKind::BareCr.message(), "bare CR");

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.
§

Empty = 0

A value or element that must not be empty was empty.

§

NotToken = 1

Bytes that must form a token (RFC 9110 section 5.6.2) do not.

§

InvalidByte = 2

A byte not allowed at this position.

§

BareCr = 3

A CR byte. CR is a request-smuggling vector: refuse the whole message, do not just drop the field.

§

LineFeed = 4

An LF byte inside a value. Refuse the whole message.

§

Nul = 5

A NUL byte. Refuse the whole message.

§

Control = 6

Another control byte (0x01 to 0x1F except HTAB, or DEL).

§

UnterminatedQuote = 7

A quoted string with no closing ", or one that would have to continue on the next field line.

§

InvalidQuotedPair = 8

The byte after \ in a quoted string is not HTAB / SP / VCHAR / obs-text.

§

UnbalancedComment = 9

A ( without its ), or a ) without its (.

§

CommentTooDeep = 10

Comment nesting deeper than Limits::max_comment_depth.

§

TooManyMembers = 11

More list members, parameters, dictionary members, or encoded words than the configured limit allows.

§

TooManyEmptyElements = 12

More empty list elements (a, , , b) than Limits::max_empty_elements.

§

TrailingSeparator = 13

A separator with nothing after it where the grammar forbids that.

§

ExpectedSeparator = 14

Two members without the separator between them.

§

TrailingData = 15

Bytes after a complete value.

§

DuplicateParameter = 16

A parameter name repeated where repetition is refused.

§

MissingValue = 17

A name without =value where a value is required.

§

InvalidNumber = 18

Digits were expected; a sign, space, or other byte was found.

§

NumberOverflow = 19

A number larger than its type or the RFC allows.

§

OutOfRange = 20

A value outside its valid range, such as a year outside 1 to 9999.

§

InvalidDate = 21

A date that does not exist, or that matches no accepted format.

§

WeekdayMismatch = 22

The weekday does not agree with the date.

§

InvalidMediaType = 23

A media type that does not match type "/" subtype parameters.

§

Wildcard = 24

* as a type or subtype where a concrete media type is required.

§

InvalidBoundary = 25

A boundary parameter that breaks RFC 2046 section 5.1.1.

§

InvalidQValue = 26

A q value outside the RFC 9110 section 12.4.2 grammar.

§

InvalidEntityTag = 27

An entity tag outside [ "W/" ] DQUOTE *etagc DQUOTE.

§

InvalidRange = 28

A range set or Content-Range that is malformed or inconsistent.

§

InvalidCharset = 29

A malformed charset name.

§

UnsupportedCharset = 30

A well-formed charset that parse-net does not decode. Only UTF-8, US-ASCII, and ISO-8859-1 are decoded.

§

InvalidPercentEncoding = 31

A % not followed by two hex digits, or uppercase hex where only lowercase is allowed.

§

InvalidUtf8 = 32

Bytes that must be UTF-8 are not (overlong forms and surrogates included).

§

ControlInDecoded = 33

A decoded value contains a control byte. Never copy such a value into another header or a log.

§

InvalidHost = 34

A host that is not a reg-name, IPv4 address, or IP literal, or that carries userinfo (@).

§

InvalidPort = 35

A port that is not digits, or is above 65535.

§

InvalidAddress = 36

An IP literal that is not a valid address, or a name made only of digits and dots that is not a valid IPv4 address.

§

InvalidOrigin = 37

An Origin that is not null or scheme "://" host [ ":" port ].

§

InvalidKey = 38

A Structured Field key outside ( lcalpha / "*" ) *( lcalpha / DIGIT / "_" / "-" / "." / "*" ).

§

TooLong = 39

A string, token, key, byte sequence, address, or local part longer than its limit.

§

InvalidBase64 = 40

Bytes outside the base64 alphabet, or a misplaced =.

§

InvalidEncodedWord = 41

A malformed RFC 2047 encoded word.

§

SectionGap = 42

RFC 2231 sections that are missing, repeated, or out of order, or a charset on a section other than 0.

§

TooManySections = 43

More RFC 2231 sections than Limits::max_rfc2231_sections.

§

InvalidAddrSpec = 44

An address outside the strict RFC 5322 addr-spec.

§

LineTooLong = 45

An email header line over 998 bytes.

§

Malformed = 46

A structure that is wrong as a whole. For a forwarded chain, use the peer address.

§

TooManyHops = 47

A forwarded chain longer than the hop limit. Use the peer address.

§

BufferTooSmall = 48

The output buffer is shorter than the decoded value. Nothing was written; retry with a buffer of the size the matching *_len function reports.

Implementations§

Source§

impl ErrorKind

Source

pub const fn message(self) -> &'static str

The fixed text ParseError’s Display uses for this kind.

§Examples
assert_eq!(parse_net::ErrorKind::InvalidByte.message(), "invalid byte");

Trait Implementations§

Source§

impl Clone for ErrorKind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ErrorKind

Source§

impl Debug for ErrorKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ErrorKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ErrorKind

Source§

impl Hash for ErrorKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ErrorKind

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ErrorKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.