pub trait WithSchema {
// Required method
fn schema(version: u32, context: &mut WithSchemaContext) -> Schema;
}
Expand description
This trait must be implemented by all data structures you wish to be able to save.
It must encode the schema for the datastructure when saved using the given version number. When files are saved, the schema is encoded into the file. when loading, the schema is inspected to make sure that the load will safely succeed. This is only for increased safety, the file format does not in fact use the schema for any other purpose, the design is schema-less at the core, the schema is just an added layer of safety (which can be disabled).
Required Methods§
Sourcefn schema(version: u32, context: &mut WithSchemaContext) -> Schema
fn schema(version: u32, context: &mut WithSchemaContext) -> Schema
Returns a representation of the schema used by this Serialize implementation for the given version. The WithSchemaContext can be used to guard against recursive data structures. See documentation of WithSchemaContext.
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.