pub trait Serializer<T> {
// Required method
fn serialize_into(&self, value: &T, builder: &mut Builder);
// Provided methods
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.