Install
# Cargo.toml
[]
= "0.2.0"
Usage
You can use the parsers provided in this crate directly, examples are available in each parser's tests.
use DuplicateQS;
let parsed = parse;
let values = parsed.values; // Will give you a vector of b"bar" and b"baz"
Or you can use serde(with serde
feature, enabled by default)
use Deserialize;
use ;
let parsed: MyStruct = from_str.unwrap;
// or
let parsed: MyStruct = parse.deserialize.unwrap;
There are also crates for actix_web
(serde-querystring-actix
) and axum
(serde-querystring-axum
) which provide extractors for their frameworks and can be used without directly relying on the core crate.
Parsers
Simple Mode
Simply parses key=value pairs, accepting only one value per key. In case a key is repeated, we only collect the last value.
use ;
parse;
// or
let res: MyStruct = from_str.unwrap;
Repeated key mode
Supports vectors or values by repeating a key.
use ;
parse;
// or
let res: MyStruct = from_str.unwrap;
Delimiter mode
Supports vectors or values by using a delimiter byte(ex. b'|').
use ;
parse;
// or
let res: MyStruct = from_str.unwrap;
Brackets mode
Supports vectors or values by using a brackets and subkeys.
use ;
parse;
// or
let res: MyStruct = from_str.unwrap;
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.