pub trait Serialize: WithSchema {
// Required method
fn serialize(
&self,
serializer: &mut Serializer<'_, impl Write>
) -> Result<(), SavefileError>;
}
Expand description
This trait must be implemented for all data structures you wish to be able to serialize. To actually serialize data: create a Serializer, then call serialize on your data to save, giving the Serializer as an argument.
The most convenient way to implement this is to use
#[macro_use] extern crate savefile-derive;
and the use #[derive(Serialize)]
Required Methods§
sourcefn serialize(
&self,
serializer: &mut Serializer<'_, impl Write>
) -> Result<(), SavefileError>
fn serialize( &self, serializer: &mut Serializer<'_, impl Write> ) -> Result<(), SavefileError>
Serialize self into the given serializer. In versions prior to 0.15, ‘Serializer’ did not accept a type parameter. It now requires a type parameter with the type of writer expected.
Object Safety§
This trait is not object safe.