Expand description
Term represents the value that the token can take.
It actually wraps a Vec<u8>
.
Implementations
sourceimpl Term
impl Term
sourcepub fn from_field_u64(field: Field, val: u64) -> Term
pub fn from_field_u64(field: Field, val: u64) -> Term
Builds a term given a field, and a u64-value
sourcepub fn from_field_i64(field: Field, val: i64) -> Term
pub fn from_field_i64(field: Field, val: i64) -> Term
Builds a term given a field, and a i64-value
sourcepub fn from_field_f64(field: Field, val: f64) -> Term
pub fn from_field_f64(field: Field, val: f64) -> Term
Builds a term given a field, and a f64-value
sourcepub fn from_field_date(field: Field, val: DateTime) -> Term
pub fn from_field_date(field: Field, val: DateTime) -> Term
Builds a term given a field, and a DateTime value
sourcepub fn from_facet(field: Field, facet: &Facet) -> Term
pub fn from_facet(field: Field, facet: &Facet) -> Term
Creates a Term
given a facet.
sourcepub fn from_field_text(field: Field, text: &str) -> Term
pub fn from_field_text(field: Field, text: &str) -> Term
Builds a term given a field, and a string value
sourcepub fn set_u64(&mut self, val: u64)
pub fn set_u64(&mut self, val: u64)
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.
sourcepub fn clear_with_type(&mut self, typ: Type)
pub fn clear_with_type(&mut self, typ: Type)
Removes the value_bytes and set the type code.
sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Truncate the term right after the field and the type code.
sourcepub fn append_bytes(&mut self, bytes: &[u8])
pub fn append_bytes(&mut self, bytes: &[u8])
Truncate the term right after the field and the type code.
sourceimpl<B> Term<B> where
B: AsRef<[u8]>,
impl<B> Term<B> where
B: AsRef<[u8]>,
sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Returns the u64
value stored in a term.
Returns None if the term is not of the u64 type, or if the term byte representation is invalid.
sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Returns the i64
value stored in a term.
Returns None if the term is not of the i64 type, or if the term byte representation is invalid.
sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Returns the f64
value stored in a term.
Returns None if the term is not of the f64 type, or if the term byte representation is invalid.
sourcepub fn as_date(&self) -> Option<DateTime>
pub fn as_date(&self) -> Option<DateTime>
Returns the Date
value stored in a term.
Returns None if the term is not of the Date type, or if the term byte representation is invalid.
sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns the text associated with the term.
Returns None if the field is not of string type or if the bytes are not valid utf-8.
sourcepub fn as_facet(&self) -> Option<Facet>
pub fn as_facet(&self) -> Option<Facet>
Returns the facet associated with the term.
Returns None if the field is not of facet type or if the bytes are not valid utf-8.
sourcepub fn as_bytes(&self) -> Option<&[u8]>
pub fn as_bytes(&self) -> Option<&[u8]>
Returns the bytes associated with the term.
Returns None if the field is not of bytes type.
sourcepub fn value_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn value_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
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
.
Trait Implementations
sourceimpl<B> Ord for Term<B> where
B: AsRef<[u8]>,
impl<B> Ord for Term<B> where
B: AsRef<[u8]>,
sourceimpl<B> PartialOrd<Term<B>> for Term<B> where
B: AsRef<[u8]>,
impl<B> PartialOrd<Term<B>> for Term<B> where
B: AsRef<[u8]>,
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<B> Eq for Term<B> where
B: AsRef<[u8]>,
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
sourceimpl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more