3 stable releases
Uses new Rust 2024
new 3.0.0 | Mar 11, 2025 |
---|---|
2.0.1 | Mar 11, 2025 |
#3 in #urlencoded
28 downloads per month
19KB
179 lines
shapely-urlencoded
[!IMPORTANT]
There is no stable shapely API as of now (even though it's >1.0.0). The design is very much still being explored.
Expect multiple major versions in the near future — (note left 2025-03-11)
A serialization and deserialization library for URL encoded form data using the shapely runtime reflection system.
Features
- Simple URL encoded form data deserialization for any type implementing the
Shapely
trait - Support for query string parsing
- Detailed error reporting with context
- Support for nested structs and scalar values
Example
use shapely::Shapely;
use shapely_urlencoded::from_urlencoded;
#[derive(Debug, Shapely, PartialEq)]
struct SearchParams {
query: String,
page: u64,
}
let query_string = "query=rust+programming&page=2";
let mut partial = SearchParams::partial();
from_urlencoded(&mut partial, query_string).expect("Failed to parse URL encoded data");
let params = partial.build::<SearchParams>();
assert_eq!(params, SearchParams { query: "rust programming".to_string(), page: 2 });
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Dependencies
~295KB