macro_rules! impl_serialize_row_via_value_list {
    ($t:ident$(<$($targ:tt $(: $tbound:tt)?),*>)?) => { ... };
}
👎Deprecated since 0.15.1: Legacy serialization API is not type-safe and is going to be removed soon
Expand description

Implements the SerializeRow trait for a type, provided that the type already implements the legacy ValueList trait.

§Note

The translation from one trait to another encounters a performance penalty and does not utilize the stronger guarantees of SerializeRow. Before resorting to this macro, you should consider other options instead:

  • If the impl was generated using the ValueList procedural macro, you should switch to the SerializeRow procedural macro. The new macro behaves differently by default, so please read its documentation first!
  • If the impl was written by hand, it is still preferable to rewrite it manually. You have an opportunity to make your serialization logic type-safe and potentially improve performance.

Basically, you should consider using the macro if you have a hand-written impl and the moment it is not easy/not desirable to rewrite it.

§Example

struct NoGenerics {}
impl ValueList for NoGenerics {
    fn serialized(&self) -> SerializedResult<'_> {
        ().serialized()
    }
}
impl_serialize_row_via_value_list!(NoGenerics);

// Generic types are also supported. You must specify the bounds if the
// struct/enum contains any.
struct WithGenerics<T, U: Clone>(T, U);
impl<T: Value, U: Clone + Value> ValueList for WithGenerics<T, U> {
    fn serialized(&self) -> SerializedResult<'_> {
        let mut values = LegacySerializedValues::new();
        values.add_value(&self.0);
        values.add_value(&self.1.clone());
        Ok(Cow::Owned(values))
    }
}
impl_serialize_row_via_value_list!(WithGenerics<T, U: Clone>);