pub struct UrlEncodedQS<'a> { /* private fields */ }
Expand description

The simplest parser for querystring It parses the whole querystring, and overwrites each repeated key’s value. it does not support vectors, maps nor tuples, but provides the best performance.

Note

Keys are decoded when calling the parse method, but values are lazily decoded when you call the value method for their keys.

Example

use serde_querystring::UrlEncodedQS;

let slice = b"key=value";

let parser = UrlEncodedQS::parse(slice);

assert_eq!(parser.keys(), vec![&Cow::Borrowed(b"key")]);
assert_eq!(
    parser.value(b"key"),
    Some(Some(Cow::Borrowed("value".as_bytes())))
);

Implementations§

source§

impl<'a> UrlEncodedQS<'a>

source

pub fn deserialize<T: Deserialize<'a>>(self) -> Result<T, Error>

Deserialize the parsed slice into T

source§

impl<'a> UrlEncodedQS<'a>

source

pub fn parse(slice: &'a [u8]) -> Self

Parse a slice of bytes into a UrlEncodedQS

source

pub fn keys(&self) -> Vec<&Cow<'a, [u8]>>

Returns a vector containing all the keys in querystring.

source

pub fn value(&self, key: &'a [u8]) -> Option<Option<Cow<'a, [u8]>>>

Returns the last value assigned to a key.

It returns None if the key doesn’t exist in the querystring, and returns Some(None) if the last assignment to a key doesn’t have a value, ex "&key&"

Note

Percent decoding the value is done on-the-fly every time this function is called.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for UrlEncodedQS<'a>

§

impl<'a> Send for UrlEncodedQS<'a>

§

impl<'a> Sync for UrlEncodedQS<'a>

§

impl<'a> Unpin for UrlEncodedQS<'a>

§

impl<'a> UnwindSafe for UrlEncodedQS<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.