pub trait FromDoc: Sized {
// Required method
fn from_doc(doc: DocRef<'_>) -> Result<Self>;
}Expand description
Reconstruct Self from a DocRef.
Implemented by the #[derive(FromDoc)] macro from the zvec-derive
crate (enabled via the derive cargo feature). The derive:
- reads scalar fields via the matching
DocRef::get_*method, - treats
#[zvec(pk)]fields as the doc’s primary key (viaDocRef::pk_copy), - leaves
#[zvec(skip)]fields initialised byDefault::default, - tolerates missing fields that are
Option<T>(returnsNone), - but errors on missing fields that are not
Option.
Implement this manually if the derive’s rules don’t fit.
Required Methods§
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.