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§
Sourcefn iter_top_level_fields(
&self,
) -> impl Iterator<Item = Result<(&'doc str, &'doc RawValue)>>
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
_vectorsand_geofields are ignored by this method, meaning they are not returned by this method.
Sourcefn top_level_fields_count(&self) -> usize
fn top_level_fields_count(&self) -> usize
Number of top level fields, excluding _vectors and _geo
Sourcefn top_level_field(&self, k: &str) -> Result<Option<&'doc RawValue>>
fn top_level_field(&self, k: &str) -> Result<Option<&'doc RawValue>>
Get the top-level with the specified name, if exists.
- The
_vectorsand_geofields are ignored by this method, meaning e.g.top_level_field("_vectors")will returnOk(None)
Sourcefn vectors_field(&self) -> Result<Option<&'doc RawValue>>
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.
Sourcefn geo_field(&self) -> Result<Option<&'doc RawValue>>
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.