Trait Document

Source
pub trait Document<'doc> {
    // Required methods
    fn iter_top_level_fields(
        &self,
    ) -> impl Iterator<Item = Result<(&'doc str, &'doc RawValue)>>;
    fn top_level_fields_count(&self) -> usize;
    fn top_level_field(&self, k: &str) -> Result<Option<&'doc RawValue>>;
    fn vectors_field(&self) -> Result<Option<&'doc RawValue>>;
    fn geo_field(&self) -> Result<Option<&'doc RawValue>>;
}
Expand description

A view into a document that can represent either the current version from the DB, the update data from payload or other means, or the merged updated version.

The ’doc lifetime is meant to live sufficiently for the document to be handled by the extractors.

Required Methods§

Source

fn iter_top_level_fields( &self, ) -> impl Iterator<Item = Result<(&'doc str, &'doc RawValue)>>

Iterate over all top-level fields of the document, returning their name and raw JSON value.

  • The returned values may contain nested fields.
  • The _vectors and _geo fields are ignored by this method, meaning they are not returned by this method.
Source

fn top_level_fields_count(&self) -> usize

Number of top level fields, excluding _vectors and _geo

Source

fn top_level_field(&self, k: &str) -> Result<Option<&'doc RawValue>>

Get the top-level with the specified name, if exists.

  • The _vectors and _geo fields are ignored by this method, meaning e.g. top_level_field("_vectors") will return Ok(None)
Source

fn vectors_field(&self) -> Result<Option<&'doc RawValue>>

Returns the unparsed value of the _vectors field from the document data.

This field alone is insufficient to retrieve vectors, as they may be stored in a dedicated location in the database. Use a super::vector_document::VectorDocument to access the vector.

This method is meant as a convenience for implementors of super::vector_document::VectorDocument.

Source

fn geo_field(&self) -> Result<Option<&'doc RawValue>>

Returns the unparsed value of the _geo field from the document data.

This field alone is insufficient to retrieve geo data, as they may be stored in a dedicated location in the database. Use a [super::geo_document::GeoDocument] to access the vector.

This method is meant as a convenience for implementors of [super::geo_document::GeoDocument].

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.

Implementations on Foreign Types§

Source§

impl<'doc, D> Document<'doc> for &D
where D: Document<'doc>,

Implementors§

Source§

impl<'d, 'doc: 'd, 't: 'd, Mapper: FieldIdMapper> Document<'d> for MergedDocument<'d, 'doc, 't, Mapper>

Source§

impl<'doc> Document<'doc> for DocumentFromVersions<'_, 'doc>

Source§

impl<'t, Mapper: FieldIdMapper> Document<'t> for DocumentFromDb<'t, Mapper>