Skip to main content

FromDoc

Trait FromDoc 

Source
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 (via DocRef::pk_copy),
  • leaves #[zvec(skip)] fields initialised by Default::default,
  • tolerates missing fields that are Option<T> (returns None),
  • but errors on missing fields that are not Option.

Implement this manually if the derive’s rules don’t fit.

Required Methods§

Source

fn from_doc(doc: DocRef<'_>) -> Result<Self>

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.

Implementors§