pub struct QueryDict { /* private fields */ }
Expand description
QueryDict.
This type can be used to parse and serialize URL query strings.
The QueryDict uses Vec<_>
internally to store the items, so it preserves
the item order and allows multiple items with the same key. This also means
that complexity of some operations is O(n)
. However, this should not pose
a problem in practice, as the number of query parameters is usually small.
It is a trade-off between performance and footprint.
Implementations§
Source§impl QueryDict
impl QueryDict
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new instance of QueryDict with a given initial capacity.
Sourcepub fn add<T>(&mut self, item: T)where
T: Into<QueryDictItem>,
pub fn add<T>(&mut self, item: T)where
T: Into<QueryDictItem>,
Add a given item.
This is an O(1)
operation.
Sourcepub fn set<T>(&mut self, item: T)where
T: Into<QueryDictItem>,
pub fn set<T>(&mut self, item: T)where
T: Into<QueryDictItem>,
Replace all items having the same name (if any).
This is an O(n)
operation.
Sourcepub fn remove<N>(&mut self, key: &N)
pub fn remove<N>(&mut self, key: &N)
Remove all items with a given key.
This is an O(n)
operation.
Sourcepub fn get<'a, N>(&'a self, key: &'a N) -> KeyIter<'a> ⓘ
pub fn get<'a, N>(&'a self, key: &'a N) -> KeyIter<'a> ⓘ
Get header fields with a given key.
This is an O(n)
operation.
Sourcepub fn last<'a, N>(&'a self, key: &'a N) -> Option<&'a QueryDictItem>
pub fn last<'a, N>(&'a self, key: &'a N) -> Option<&'a QueryDictItem>
Get the last item with a given key.
This is an O(n)
operation.
Sourcepub fn last_value<'a, N>(&'a self, key: &'a N) -> Option<&'a QueryDictValue>
pub fn last_value<'a, N>(&'a self, key: &'a N) -> Option<&'a QueryDictValue>
Get value of the last item with a given key.
This is an O(n)
operation.