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
use savefile-derive::Savefile;
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.
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.