#[non_exhaustive]pub enum ArrayFormat {
Repeat,
Brackets,
Indices,
}Expand description
How sequences are written.
use std::collections::BTreeMap;
use deser_urlencoded::{ArrayFormat, SerializerConfig};
let value = BTreeMap::from([("a", vec![1, 2])]);
let with = |arrays| {
SerializerConfig::builder().arrays(arrays).build().to_string(&value).unwrap()
};
assert_eq!(with(ArrayFormat::Repeat), "a=1&a=2");
assert_eq!(with(ArrayFormat::Brackets), "a%5B%5D=1&a%5B%5D=2");
assert_eq!(with(ArrayFormat::Indices), "a%5B0%5D=1&a%5B1%5D=2");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.
Repeat
The key is repeated for every element (a=1&a=2).
This is what HTML forms send for <select multiple> and what
URLSearchParams produces. The elements have to be atoms.
Brackets
The key is repeated with empty brackets (a[]=1&a[]=2).
The elements have to be atoms.
Indices
The key is repeated with the index of the element (a[0]=1&a[1]=2,
with Nesting::Dots a.0=1&a.1=2).
This is the only format that supports sequences of maps and sequences.
Trait Implementations§
Source§impl Clone for ArrayFormat
impl Clone for ArrayFormat
impl Copy for ArrayFormat
Source§impl Debug for ArrayFormat
impl Debug for ArrayFormat
Source§impl Default for ArrayFormat
impl Default for ArrayFormat
impl Eq for ArrayFormat
Source§impl PartialEq for ArrayFormat
impl PartialEq for ArrayFormat
impl StructuralPartialEq for ArrayFormat
Auto Trait Implementations§
impl Freeze for ArrayFormat
impl RefUnwindSafe for ArrayFormat
impl Send for ArrayFormat
impl Sync for ArrayFormat
impl Unpin for ArrayFormat
impl UnsafeUnpin for ArrayFormat
impl UnwindSafe for ArrayFormat
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