Struct tantivy::schema::Term
[−]
[src]
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>
.
Methods
impl Term
[src]
pub fn from_field_i64(field: Field, val: i64) -> 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 8 bytes.
The first four byte are dedicated to storing the field id as a u64. The 4 following bytes are encoding the u64 value.
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 8 bytes.
The first four byte are dedicated to storing the field id as a u64. The 4 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_text(&mut self, text: &str)
[src]
Set the texts only, keeping the field untouched.
impl<B> Term<B> where
B: AsRef<[u8]>,
[src]
B: AsRef<[u8]>,
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 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: Clone> Clone for Term<B> where
B: AsRef<[u8]>,
[src]
B: AsRef<[u8]>,
fn clone(&self) -> Term<B>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<B: PartialEq> PartialEq for Term<B> where
B: AsRef<[u8]>,
[src]
B: AsRef<[u8]>,
fn eq(&self, __arg_0: &Term<B>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Term<B>) -> bool
[src]
This method tests for !=
.
impl<B: PartialOrd> PartialOrd for Term<B> where
B: AsRef<[u8]>,
[src]
B: AsRef<[u8]>,
fn partial_cmp(&self, __arg_0: &Term<B>) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Term<B>) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Term<B>) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Term<B>) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Term<B>) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<B: Ord> Ord for Term<B> where
B: AsRef<[u8]>,
[src]
B: AsRef<[u8]>,
fn cmp(&self, __arg_0: &Term<B>) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<B: Eq> Eq for Term<B> where
B: AsRef<[u8]>,
[src]
B: AsRef<[u8]>,
impl<B: Hash> Hash for Term<B> where
B: AsRef<[u8]>,
[src]
B: AsRef<[u8]>,
fn hash<__HB: Hasher>(&self, __arg_0: &mut __HB)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<B> AsRef<[u8]> for Term<B> where
B: AsRef<[u8]>,
[src]
B: AsRef<[u8]>,