Skip to main content

Serializer

Struct Serializer 

Source
pub struct Serializer<'s> { /* private fields */ }
Available on crate feature alloc only.
Expand description

Appends urlencoded pairs to an existing string, for example a URL that already ends in ?. The first pair is not preceded by &; whatever the string held before is left untouched.

§Examples

let mut url = String::from("https://example.com/search?");
form_net::Serializer::new(&mut url)
    .append_pair("q", "rust forms")
    .append_pairs([("page", "2"), ("sort", "new")]);
assert_eq!(url, "https://example.com/search?q=rust+forms&page=2&sort=new");

Implementations§

Source§

impl<'s> Serializer<'s>

Source

pub fn new(out: &'s mut String) -> Serializer<'s>

A serializer that appends to out.

Source

pub fn append_pair(&mut self, name: &str, value: &str) -> &mut Self

Appends one pair.

Source

pub fn append_pairs<I, N, V>(&mut self, pairs: I) -> &mut Self
where I: IntoIterator<Item = (N, V)>, N: AsRef<str>, V: AsRef<str>,

Appends every pair, in order.

Source

pub fn finish(self) -> &'s mut String

Ends the serializer and returns the string.

Trait Implementations§

Source§

impl<'s> Debug for Serializer<'s>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s> !UnwindSafe for Serializer<'s>

§

impl<'s> Freeze for Serializer<'s>

§

impl<'s> RefUnwindSafe for Serializer<'s>

§

impl<'s> Send for Serializer<'s>

§

impl<'s> Sync for Serializer<'s>

§

impl<'s> Unpin for Serializer<'s>

§

impl<'s> UnsafeUnpin for Serializer<'s>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.