[][src]Struct tantivy::Term

pub struct Term<B = Vec<u8>>(_)
where
    B: AsRef<[u8]>
;

Term represents the value that the token can take.

It actually wraps a Vec<u8>.

Implementations

impl Term[src]

pub fn from_field_i64(field: Field, val: i64) -> Term[src]

Builds a term given a field, and a i64-value

Assuming the term has a field id of 1, and a i64 value of 3234, the Term will have 12 bytes.

The first four byte are dedicated to storing the field id as a u64. The 8 following bytes are encoding the u64 value.

pub fn from_field_f64(field: Field, val: f64) -> Term[src]

Builds a term given a field, and a f64-value

Assuming the term has a field id of 1, and a f64 value of 1.5, the Term will have 12 bytes.

The first four byte are dedicated to storing the field id as a u64. The 8 following bytes are encoding the f64 as a u64 value.

pub fn from_field_date(field: Field, val: &DateTime) -> Term[src]

Builds a term given a field, and a DateTime value

Assuming the term has a field id of 1, and a timestamp i64 value of 3234, the Term will have 12 bytes.

The first four byte are dedicated to storing the field id as a u64. The 8 following bytes are encoding the DateTime as i64 timestamp value.

pub fn from_facet(field: Field, facet: &Facet) -> Term[src]

Creates a Term given a facet.

pub fn from_field_text(field: Field, text: &str) -> Term[src]

Builds a term given a field, and a string value

Assuming the term has a field id of 2, and a text value of "abc", the Term will have 4 bytes. The first byte is 2, and the three following bytes are the utf-8 representation of "abc".

pub fn from_field_u64(field: Field, val: u64) -> Term[src]

Builds a term given a field, and a u64-value

Assuming the term has a field id of 1, and a u64 value of 3234, the Term will have 12 bytes.

The first four byte are dedicated to storing the field id as a u64. The 8 following bytes are encoding the u64 value.

pub fn set_field(&mut self, field: Field)[src]

Returns the field.

pub fn set_u64(&mut self, val: u64)[src]

Sets a u64 value in the term.

U64 are serialized using (8-byte) BigEndian representation. The use of BigEndian has the benefit of preserving the natural order of the values.

pub fn set_i64(&mut self, val: i64)[src]

Sets a i64 value in the term.

pub fn set_f64(&mut self, val: f64)[src]

Sets a f64 value in the term.

pub fn set_text(&mut self, text: &str)[src]

Set the texts only, keeping the field untouched.

impl<B> Term<B> where
    B: AsRef<[u8]>, 
[src]

pub fn wrap(data: B) -> Term<B>[src]

Wraps a source of data

pub fn field(&self) -> Field[src]

Returns the field.

pub fn get_u64(&self) -> u64[src]

Returns the u64 value stored in a term.

Panics

... or returns an invalid value if the term is not a u64 field.

pub fn get_i64(&self) -> i64[src]

Returns the i64 value stored in a term.

Panics

... or returns an invalid value if the term is not a i64 field.

pub fn get_f64(&self) -> f64[src]

Returns the f64 value stored in a term.

Panics

... or returns an invalid value if the term is not a f64 field.

pub fn text(&self) -> &str[src]

Returns the text associated with the term.

Panics

If the value is not valid utf-8. This may happen if the index is corrupted or if you try to call this method on a non-string type.

pub fn value_bytes(&self) -> &[u8][src]

Returns the serialized value of the term. (this does not include the field.)

If the term is a string, its value is utf-8 encoded. If the term is a u64, its value is encoded according to byteorder::LittleEndian.

pub fn as_slice(&self) -> &[u8][src]

Returns the underlying &[u8]

Trait Implementations

impl<B> AsRef<[u8]> for Term<B> where
    B: AsRef<[u8]>, 
[src]

impl<B: Clone> Clone for Term<B> where
    B: AsRef<[u8]>, 
[src]

impl Debug for Term[src]

impl<B: Eq> Eq for Term<B> where
    B: AsRef<[u8]>, 
[src]

impl<B: Hash> Hash for Term<B> where
    B: AsRef<[u8]>, 
[src]

impl<B: Ord> Ord for Term<B> where
    B: AsRef<[u8]>, 
[src]

impl<B: PartialEq> PartialEq<Term<B>> for Term<B> where
    B: AsRef<[u8]>, 
[src]

impl<B: PartialOrd> PartialOrd<Term<B>> for Term<B> where
    B: AsRef<[u8]>, 
[src]

impl<B> StructuralEq for Term<B> where
    B: AsRef<[u8]>, 
[src]

impl<B> StructuralPartialEq for Term<B> where
    B: AsRef<[u8]>, 
[src]

Auto Trait Implementations

impl<B> RefUnwindSafe for Term<B> where
    B: RefUnwindSafe

impl<B> Send for Term<B> where
    B: Send

impl<B> Sync for Term<B> where
    B: Sync

impl<B> Unpin for Term<B> where
    B: Unpin

impl<B> UnwindSafe for Term<B> where
    B: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T> Fruit for T where
    T: Send + Downcast
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,