Struct serde_qs::Config
[−]
[src]
pub struct Config { /* fields omitted */ }
To override the default serialization parameters, first construct a new Config.
A max_depth
of 0 implies no nesting: the result will be a flat map.
This is mostly useful when the maximum nested depth is known beforehand,
to prevent denial of service attacks by providing incredibly deeply nested
inputs.
The default value for max_depth
is 5.
use serde_qs::Config; use std::collections::HashMap; let config = Config::with_max_depth(0); let map: HashMap<String, String> = config.deserialize_str("a[b][c]=1") .unwrap(); assert_eq!(map.get("a[b][c]").unwrap(), "1"); let config = Config::with_max_depth(10); let map: HashMap<String, HashMap<String, HashMap<String, String>>> = config.deserialize_str("a[b][c]=1").unwrap(); assert_eq!(map.get("a").unwrap().get("b").unwrap().get("c").unwrap(), "1");
Methods
impl Config
[src]
fn with_max_depth(depth: usize) -> Config
Construct a new Config
with the specified maximum depth of nesting.
fn max_depth(&self) -> usize
Get maximum depth parameter.
impl Config
[src]
fn deserialize_bytes<'de, T: Deserialize<'de>>(
&self,
input: &[u8]
) -> Result<T, Error>
&self,
input: &[u8]
) -> Result<T, Error>
Deserializes a querystring from a &[u8]
using this Config
.
fn deserialize_str<'de, T: Deserialize<'de>>(
&self,
input: &str
) -> Result<T, Error>
&self,
input: &str
) -> Result<T, Error>
Deserializes a querystring from a &str
using this Config
.
fn deserialize_reader<'de, T, R>(&self, reader: R) -> Result<T, Error> where
T: Deserialize<'de>,
R: Read,
T: Deserialize<'de>,
R: Read,
Deserializes a querystring from a reader using this Config
.