#[non_exhaustive]pub enum Nesting {
Flat,
Brackets,
Dots,
}Expand description
How keys are nested.
use std::collections::BTreeMap;
use deser_urlencoded::{DeserializerConfig, Nesting};
type Nested = BTreeMap<String, BTreeMap<String, u32>>;
let value: Nested = deser_urlencoded::from_str("a[b]=1").unwrap();
assert_eq!(value["a"]["b"], 1);
let dots = DeserializerConfig::builder().nesting(Nesting::Dots).build();
let value: Nested = dots.from_str("a.b=1").unwrap();
assert_eq!(value["a"]["b"], 1);
let flat = DeserializerConfig::builder().nesting(Nesting::Flat).build();
let value: BTreeMap<String, u32> = flat.from_str("a[b]=1").unwrap();
assert_eq!(value["a[b]"], 1);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Flat
Keys are not nested, they are taken as they are.
Brackets
Nested keys are in brackets: a[b][0]=1 and a[]=1.
This is how Rails, PHP and the qs library of Node write nested
keys.
Dots
Nested keys are separated with dots: a.b.0=1.
Trait Implementations§
impl Copy for Nesting
impl Eq for Nesting
impl StructuralPartialEq for Nesting
Auto Trait Implementations§
impl Freeze for Nesting
impl RefUnwindSafe for Nesting
impl Send for Nesting
impl Sync for Nesting
impl Unpin for Nesting
impl UnsafeUnpin for Nesting
impl UnwindSafe for Nesting
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more