Trait serializers::Serializer
source · pub trait Serializer<T> {
fn serialize_into(&self, value: &T, builder: &mut Builder);
fn to_value(&self, value: &T) -> Value { ... }
fn serialize(&self, value: &T) -> String { ... }
fn serialize_iter<'a, I>(&self, values: I) -> String
where
I: IntoIterator<Item = &'a T>,
T: 'a,
{ ... }
}
Expand description
The trait you implement in order to make a serializer.
Required Methods
sourcefn serialize_into(&self, value: &T, builder: &mut Builder)
fn serialize_into(&self, value: &T, builder: &mut Builder)
Add key-value pairs to the builder for the given object.
You shouldn’t have to call this method yourself. It’ll be called by other method in this trait.
Provided Methods
sourcefn serialize_iter<'a, I>(&self, values: I) -> Stringwhere
I: IntoIterator<Item = &'a T>,
T: 'a,
fn serialize_iter<'a, I>(&self, values: I) -> Stringwhere
I: IntoIterator<Item = &'a T>,
T: 'a,
Turn the given iterable into JSON array. The main usecase for this is to turn Vec
s into
JSON arrays, but works for any iterator.