pub struct Serializer<'a, T>where
    T: Target,{ /* private fields */ }
Expand description

Implementations§

§

impl<'a, T> Serializer<'a, T>where T: Target,

pub fn new(target: T) -> Serializer<'a, T>

Create a new application/x-www-form-urlencoded serializer for the given target.

If the target is non-empty, its content is assumed to already be in application/x-www-form-urlencoded syntax.

pub fn for_suffix(target: T, start_position: usize) -> Serializer<'a, T>

Create a new application/x-www-form-urlencoded serializer for a suffix of the given target.

If that suffix is non-empty, its content is assumed to already be in application/x-www-form-urlencoded syntax.

pub fn clear(&mut self) -> &mut Serializer<'a, T>

Remove any existing name/value pair.

Panics if called after .finish().

pub fn encoding_override( &mut self, new: Option<&'a dyn Fn(&str) -> Cow<'_, [u8]>> ) -> &mut Serializer<'a, T>

Set the character encoding to be used for names and values before percent-encoding.

pub fn append_pair(&mut self, name: &str, value: &str) -> &mut Serializer<'a, T>

Serialize and append a name/value pair.

Panics if called after .finish().

pub fn append_key_only(&mut self, name: &str) -> &mut Serializer<'a, T>

Serialize and append a name of parameter without any value.

Panics if called after .finish().

pub fn extend_pairs<I, K, V>(&mut self, iter: I) -> &mut Serializer<'a, T>where I: IntoIterator, <I as IntoIterator>::Item: Borrow<(K, V)>, K: AsRef<str>, V: AsRef<str>,

Serialize and append a number of name/value pairs.

This simply calls append_pair repeatedly. This can be more convenient, so the user doesn’t need to introduce a block to limit the scope of Serializer’s borrow of its string.

Panics if called after .finish().

pub fn extend_keys_only<I, K>(&mut self, iter: I) -> &mut Serializer<'a, T>where I: IntoIterator, <I as IntoIterator>::Item: Borrow<K>, K: AsRef<str>,

Serialize and append a number of names without values.

This simply calls append_key_only repeatedly. This can be more convenient, so the user doesn’t need to introduce a block to limit the scope of Serializer’s borrow of its string.

Panics if called after .finish().

pub fn finish(&mut self) -> <T as Target>::Finished

If this serializer was constructed with a string, take and return that string.

use form_urlencoded;
let encoded: String = form_urlencoded::Serializer::new(String::new())
    .append_pair("foo", "bar & baz")
    .append_pair("saison", "Été+hiver")
    .finish();
assert_eq!(encoded, "foo=bar+%26+baz&saison=%C3%89t%C3%A9%2Bhiver");

Panics if called more than once.

Auto Trait Implementations§

§

impl<'a, T> !RefUnwindSafe for Serializer<'a, T>

§

impl<'a, T> !Send for Serializer<'a, T>

§

impl<'a, T> !Sync for Serializer<'a, T>

§

impl<'a, T> Unpin for Serializer<'a, T>where T: Unpin,

§

impl<'a, T> !UnwindSafe for Serializer<'a, T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

§

fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>

§

fn type_name(&self) -> &'static str

§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
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.
source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more