pub fn parse_item(value: &[u8]) -> Result<Item<'_>, ParseError>Expand description
Parses an Item with the default Limits (RFC 9651 section 4.2.3).
§Errors
ErrorKind::TrailingData; for the bare item:
ErrorKind::InvalidNumber (- alone, 1., a Decimal after @),
ErrorKind::NumberOverflow (16 digits, 13 integer digits in a Decimal,
4 fractional digits), ErrorKind::InvalidByte,
ErrorKind::InvalidQuotedPair, ErrorKind::UnterminatedQuote,
ErrorKind::InvalidBase64, ErrorKind::InvalidPercentEncoding
(uppercase hex in a Display String), ErrorKind::InvalidUtf8,
ErrorKind::OutOfRange (a Date outside years 1 to 9999),
ErrorKind::TooLong; for parameters: ErrorKind::InvalidKey,
ErrorKind::TooManyMembers.
§Examples
use parse_net::sfv::{self, BareItem};
assert_eq!(sfv::parse_item(b"?1")?.bare, BareItem::Boolean(true));
assert_eq!(sfv::parse_item(b"@1659578233")?.bare, BareItem::Date(1_659_578_233));
assert!(sfv::parse_item(b"%\"%C3%A9\"").is_err());