#urlencoded #forms #deserialize #shapely #serialization

shapely-urlencoded

URL encoded form serialization and deserialization for Shapely types

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

MIT/Apache

19KB
179 lines

shapely-urlencoded

experimental free of syn crates.io documentation MIT/Apache-2.0 licensed

[!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:

at your option.

Dependencies

~295KB