Struct Document

Source
pub struct Document(/* private fields */);
Expand description

A document in a Xapian database

Implementations§

Source§

impl Document

Source

pub fn add_boolean_term(&mut self, term: impl AsRef<str>)

Add a boolean term to the document

Source

pub fn add_posting( &mut self, term: impl AsRef<str>, pos: c_uint, increment: impl Into<Option<c_uint>>, )

Add an occurrence of term at the position given by pos

Source

pub fn add_term( &mut self, term: impl AsRef<str>, increment: impl Into<Option<c_uint>>, )

Add a term to the document, without positional information

Source

pub fn clear_terms(&mut self)

Remove all terms and postings from the document

Source

pub fn data(&self) -> Bytes

Get the data blob stored in this document

Source

pub fn id(&self) -> Option<DocId>

Get the document ID (if any) associated with this document

Source

pub fn remove_term(&mut self, term: impl AsRef<str>)

Remove term and all postings associated with it from this document

Source

pub fn set_data(&mut self, data: impl AsRef<[u8]>)

Set the data blob stored alongside this document

Source

pub fn set_value(&mut self, slot: impl Into<Slot>, value: impl ToValue)

Set the value stored in the given slot number

Xapian values are stored as strings, but are often more useful in some other form. To accomodate this, ToValue is used to serialize data in a Xapian-friendly fashion. This trait is already implemented for most numeric primitives, string types and byte collections.

Source

pub fn terms(&self) -> TermIter

Retrieve an iterator over the terms in this document

Source

pub fn value<T: FromValue>( &self, slot: impl Into<Slot>, ) -> Option<Result<T, T::Error>>

Retrieve the value (if any) stored in the given slot number

Xapian values are stored as strings, but are often more useful in some other form. To accomodate this, FromValue is used to deserialize data from its Xapian representation. This trait is already implemented for most numeric primitives, string types and byte collections.

Returns None when there is no value stored in slot Returns Some(Err(T::Error) when there is a value but deserialization fails Returns Some(Ok(T)) otherwise

Trait Implementations§

Source§

impl Debug for Document

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Document

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Document

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Match> for Document

Source§

fn from(value: Match) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.