serde_html_form-0.2.6/.cargo_vcs_info.json 0000644 00000000136 00000000001 0014212 0 ustar {
"git": {
"sha1": "24a380f581c3ef036d96970af446fa6fc6066c85"
},
"path_in_vcs": ""
} serde_html_form-0.2.6/.gitignore 0000644 0000000 0000000 00000000022 10461020230 0014764 0 ustar 0000000 0000000 target
Cargo.lock
serde_html_form-0.2.6/.rustfmt.toml 0000644 0000000 0000000 00000000245 10461020230 0015462 0 ustar 0000000 0000000 format_code_in_doc_comments = true
imports_granularity = "Crate"
use_small_heuristics = "Max"
newline_style = "Unix"
reorder_imports = true
use_try_shorthand = true
serde_html_form-0.2.6/CHANGELOG.md 0000644 0000000 0000000 00000003260 10461020230 0014614 0 ustar 0000000 0000000 # 0.2.6
Fix deserialization of optional sequences of a single non-string element.
# 0.2.5
Add `push_to_string` for serializing a struct to the end of an existing `String`
buffer (instead of allocating a fresh one for the serialized output).
# 0.2.4
Fix deserialization of optional sequences of a single element.
# 0.2.3
Improve README and crate documentation (now the exact same, instead of just a
single-line description).
# 0.2.2
This release only upgrades one of the crates' dev-dependencies.
# 0.2.1
This release only upgrades one of the crates' private dependencies.
# 0.2.0
Support deserialization of sequences with duplicate keys.
This used to fail, but passes now:
```rust
let result = vec![("foo".to_owned(), 1), ("bar".to_owned(), 2), ("foo".to_owned(), 3)];
assert_eq!(super::from_str("foo=1&bar=2&foo=3"), Ok(result));
```
This should mainly affect deserialization to a type that's explicitly a sequence, like arrays or `Vec`,
but some other things were changed too so if you are getting unexpected deserialization errors, please open an issue.
This release has a minimum Rust version of 1.56.
# 0.1.1
Support deserialization of `Option`al values to better support forms with optional inputs of non-string types:
```rust
#[derive(Deserialize, PartialEq)]
struct MyForm {
field: Option,
}
// What browsers send when a value is given
assert_eq!(serde_html_form::from_str("field=5").unwrap(), MyForm { field: Some(5) });
// What browsers send when no value is given
assert_eq!(serde_html_form::from_str("field=").unwrap(), MyForm { field: None });
// This also works
assert_eq!(serde_html_form::from_str("").unwrap(), MyForm { field: None });
```
# 0.1.0
Initial release.
serde_html_form-0.2.6/Cargo.toml 0000644 00000002653 00000000001 0012216 0 ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
rust-version = "1.56"
name = "serde_html_form"
version = "0.2.6"
exclude = ["/.github"]
description = "(De-)serialization support for the `application/x-www-form-urlencoded` format"
readme = "README.md"
keywords = [
"serde",
"serialization",
"urlencoded",
]
categories = [
"encoding",
"web-programming",
]
license = "MIT"
repository = "https://github.com/jplatte/serde_html_form"
[lib]
bench = false
[[bench]]
name = "upstream_comparison"
harness = false
[dependencies.form_urlencoded]
version = "1.0.1"
[dependencies.indexmap]
version = "2.0.0"
[dependencies.itoa]
version = "1.0.1"
[dependencies.ryu]
version = "1.0.9"
optional = true
[dependencies.serde]
version = "1.0.136"
[dev-dependencies.assert_matches2]
version = "0.1.0"
[dev-dependencies.divan]
version = "0.1.11"
[dev-dependencies.serde]
version = "1.0.136"
features = ["derive"]
[dev-dependencies.serde_urlencoded]
version = "0.7.1"
[features]
default = ["ryu"]
serde_html_form-0.2.6/Cargo.toml.orig 0000644 00000002151 00000000001 0013146 0 ustar [package]
name = "serde_html_form"
version = "0.2.6"
license = "MIT"
repository = "https://github.com/jplatte/serde_html_form"
description = "(De-)serialization support for the `application/x-www-form-urlencoded` format"
categories = ["encoding", "web-programming"]
keywords = ["serde", "serialization", "urlencoded"]
exclude = ["/.github"]
edition = "2021"
rust-version = "1.56"
[lib]
bench = false
[features]
default = ["ryu"]
[dependencies]
# Percent encoding and mapping of query string to pair of key-values
form_urlencoded = "1.0.1"
# Used for internal buffering during deserialization
indexmap = "2.0.0"
# Fast integer serialization
itoa = "1.0.1"
# Fast and better-looking float serialization
ryu = { version = "1.0.9", optional = true }
# Contains the Serializer and Deserializer traits
serde = "1.0.136"
[dev-dependencies]
# For the assert_matches! macro
assert_matches2 = "0.1.0"
# Some tests use structs that derive Serialize / Deserialize
serde = { version = "1.0.136", features = ["derive"] }
# For benchmarks
divan = "0.1.11"
serde_urlencoded = "0.7.1"
[[bench]]
name = "upstream_comparison"
harness = false
serde_html_form-0.2.6/Cargo.toml.orig 0000644 0000000 0000000 00000002151 10461020230 0015670 0 ustar 0000000 0000000 [package]
name = "serde_html_form"
version = "0.2.6"
license = "MIT"
repository = "https://github.com/jplatte/serde_html_form"
description = "(De-)serialization support for the `application/x-www-form-urlencoded` format"
categories = ["encoding", "web-programming"]
keywords = ["serde", "serialization", "urlencoded"]
exclude = ["/.github"]
edition = "2021"
rust-version = "1.56"
[lib]
bench = false
[features]
default = ["ryu"]
[dependencies]
# Percent encoding and mapping of query string to pair of key-values
form_urlencoded = "1.0.1"
# Used for internal buffering during deserialization
indexmap = "2.0.0"
# Fast integer serialization
itoa = "1.0.1"
# Fast and better-looking float serialization
ryu = { version = "1.0.9", optional = true }
# Contains the Serializer and Deserializer traits
serde = "1.0.136"
[dev-dependencies]
# For the assert_matches! macro
assert_matches2 = "0.1.0"
# Some tests use structs that derive Serialize / Deserialize
serde = { version = "1.0.136", features = ["derive"] }
# For benchmarks
divan = "0.1.11"
serde_urlencoded = "0.7.1"
[[bench]]
name = "upstream_comparison"
harness = false
serde_html_form-0.2.6/LICENSE 0000644 0000000 0000000 00000001777 10461020230 0014023 0 ustar 0000000 0000000 Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
serde_html_form-0.2.6/README.md 0000644 0000000 0000000 00000006754 10461020230 0014275 0 ustar 0000000 0000000 # `serde_html_form`
(De-)serialization support for the `application/x-www-form-urlencoded` format.
This crate is a Rust library for serialising to and deserialising from
the [`application/x-www-form-urlencoded`][urlencoded] format. It is built
upon [Serde], a high performance generic serialization framework and [rust-url],
a URL parser for Rust.
It is a fork of [`serde_urlencoded`], with additional support for maps or
structs with fields of sequence type (e.g. `Vec`). It also supports
`Option` in values, treating `foo=` as `foo: None`.
[rust-url]: https://github.com/servo/rust-url
[Serde]: https://github.com/serde-rs/serde
[urlencoded]: https://url.spec.whatwg.org/#application/x-www-form-urlencoded
[`serde_urlencoded`]: https://github.com/nox/serde_urlencoded
## Examples
Sequences like `value=x&value=y`:
```rust
use serde::Deserialize;
#[derive(Debug, PartialEq, Deserialize)]
struct Form {
// By default, at least one occurrence of this field must be present (this
// is mandated by how serde works).
//
// Since this is usually not desired, use `serde(default)` to instantiate
// this struct's field with a `Default` value if input doesn't contain that
// field.
#[serde(default)]
value: Vec,
}
assert_eq!(
serde_html_form::from_str("value=&value=abc"),
Ok(Form { value: vec!["".to_owned(), "abc".to_owned()] })
);
assert_eq!(
serde_html_form::from_str(""),
Ok(Form { value: vec![] })
);
```
Sequences like `value[]=x&value[]=y`:
```rust
use serde::Deserialize;
#[derive(Debug, PartialEq, Deserialize)]
struct Form {
// If you want to support `value[]=x&value[]=y`, you can use
// `serde(rename)`. You could even use `serde(alias)` instead to allow both,
// but note that mixing both in one input string would also be allowed then.
#[serde(default, rename = "value[]")]
value: Vec,
}
assert_eq!(
serde_html_form::from_str("value[]=x&value[]=y"),
Ok(Form { value: vec!["x".to_owned(), "y".to_owned()] })
);
assert_eq!(
serde_html_form::from_str("value[]=hello"),
Ok(Form { value: vec!["hello".to_owned()] })
);
```
Optional values:
```rust
use serde::Deserialize;
#[derive(Debug, PartialEq, Deserialize)]
struct Form {
// Finally, this crate also supports deserializing empty values as `None`
// if your values are `Option`s.
// Note that serde's `Deserialize` derive implicitly allows omission of
// `Option`-typed fields (except when combined with some other attributes).
single: Option,
// Not using `serde(default)` here to require at least one occurrence.
at_least_one: Vec