Install
# Cargo.toml
[]
= "0.1.0"
Usage
You can use the parsers provided in this crate directly, examples are available in each parser's tests.
let parsed = parse;
let values = parser.values; // Will give you a vector of b"bar" and b"baz"
Or you can use serde(with serde
feature, enabled by default)
use de;
let parsed: MyStruct = from_str.unwrap;
There is also serde-querystring-actix
crate to support actix-web
. It provides QueryString
extractor which works just like the actix-web's own web::Query but uses serde-querystring
to deserialize.
Parsers
UrlEncodedQS
or ParseMode::UrlEncoded
Simply parses key=value pairs, accepting only one value per key. In case a key is repeated, we only collect the last value.
DuplicateQS
or ParseMode::Duplicate
Just like UrlEncoded mode, except that if a key is repeated, we collect ALL the values for that key which can be collected later as a vector.
DelimiterQS
or ParseMode::Delimiter
Uses a delimiter byte to parse multiple values from a slice of value, ex: "key=value1|value2|value3"
BracketsQS
or ParseMode::Brackets
Works like the PHP querystring parser, using brackets and subkeys to assign values, ex: "key[a]=value&key[b]=value"
Credit
We use some lines of code from form_urlencoded
to parse percent encoded chars.
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.