Expand description
Structured Field Values (RFC 9651): Items, Lists, and Dictionaries with every bare item type, parsed into borrowed views.
The parser follows RFC 9651 section 4.2 exactly, as a loop with explicit
state; inner lists cannot nest, so there is no recursion. A field is
accepted or refused as a whole, as section 4.2 requires. Every limit of
section 3 is enforced through Limits, whose defaults meet each
minimum.
§Examples
use parse_net::sfv::{self, BareItem, Member};
let site = sfv::parse_item(b"same-origin")?;
assert_eq!(site.bare, BareItem::Token("same-origin"));
let prio = sfv::parse_dictionary(b"u=1, i")?;
assert!(matches!(prio.get("u"), Some(Member::Item(i)) if i.bare == BareItem::Integer(1)));
assert!(matches!(prio.get("i"), Some(Member::Item(i)) if i.bare == BareItem::Boolean(true)));
let list = sfv::parse_list(b"(\"foo\" \"bar\");lvl=5, abc;a=?0")?;
assert_eq!(list.len(), 2);
let Some(Member::InnerList(inner)) = list.iter().next() else { unreachable!() };
assert_eq!(inner.len(), 2);Structs§
- ByteSeq
- A Byte Sequence: the base64 text between the colons.
- Decimal
- A Decimal in thousandths: at most 12 integer and 3 fractional digits.
- Dict
Iter - The members of a validated
Dictionary. - Dictionary
- A validated Dictionary. Every member is kept in order; a repeated key’s
last value wins in
getandindex_into. - Dictionary
Lines - Several field lines read as one Dictionary.
- Display
String - A Display String: the percent-encoded text between the quotes, validated as UTF-8 during the parse.
- Inner
Iter - The items of a validated
InnerList. - Inner
List - An inner list: items in parentheses, and its own parameters.
- Item
- An item: a bare item and its parameters.
- List
- A validated List.
- List
Iter - The members of a validated
List. - List
Lines - Several field lines read as one List.
- Param
Iter - The parameters of a validated
SfParams. - Parser
- The configurable parser.
- SfParams
- Parameters of an item or an inner list. A repeated key keeps every
occurrence;
gettakes the last, as RFC 9651 requires. - SfString
- A String: the content between the quotes, only
\"and\\escapes.
Enums§
Traits§
- Visitor
- Receives a parse as events: the single-pass form, for callers that read one key or count items without building a view.
Functions§
- parse_
dictionary - Parses a Dictionary with the default
Limits(RFC 9651 section 4.2.2). - parse_
dictionary_ lines - Parses several field lines as one Dictionary with the default
Limits. - parse_
item - Parses an Item with the default
Limits(RFC 9651 section 4.2.3). - parse_
list - Parses a List with the default
Limits(RFC 9651 section 4.2.1). - parse_
list_ lines - Parses several field lines as one List with the default
Limits.