pub trait Schema {
// Required method
fn schema() -> DynamicSchema;
}Expand description
A type whose postcard wire shape is describable by a
DynamicSchema.
Schema is implemented for every T: Document (via the M9
derive, see obj_derive::Document) and also for hand-written
“historical” types that describe the wire shape of an older
version of a Document. Historical types never need to be
Documents themselves — they exist purely to describe bytes the
current reader still has on disk.
Separating Schema from Document keeps the migration registry
(#82) honest: a historical_schemas() entry refers to a
Schema-only type that owns no collection name and has no
Document::VERSION of its own (the (u32, ...) pair on the
outside carries the version).
§Power-of-ten posture
- Rule 9. No
dyn; static dispatch via the associated function below. - Rule 5. Implementations return a fresh
DynamicSchemaby value — pure data, no shared mutable state.
Required Methods§
Sourcefn schema() -> DynamicSchema
fn schema() -> DynamicSchema
Return the postcard wire-shape description for Self.
Implementations build the schema bottom-up from the variants
in DynamicSchema. The derive (M10 #82) emits a Schema
impl for every #[derive(Document)] type alongside the
Document impl; hand-impls follow the same shape.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".