pub struct Term<B = Vec<u8>>(/* private fields */)
where
B: AsRef<[u8]>;
Expand description
Term represents the value that the token can take.
It actually wraps a Vec<u8>
.
Implementations§
Source§impl Term
impl Term
Sourcepub fn from_field_ip_addr(field: Field, ip_addr: Ipv6Addr) -> Term
pub fn from_field_ip_addr(field: Field, ip_addr: Ipv6Addr) -> Term
Builds a term given a field, and a Ipv6Addr
-value
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_bool(field: Field, val: bool) -> Term
pub fn from_field_bool(field: Field, val: bool) -> Term
Builds a term given a field, and a bool
-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 from_field_bytes(field: Field, bytes: &[u8]) -> Term
pub fn from_field_bytes(field: Field, bytes: &[u8]) -> Term
Builds a term bytes.
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 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 set_ip_addr(&mut self, val: Ipv6Addr)
pub fn set_ip_addr(&mut self, val: Ipv6Addr)
Sets a Ipv6Addr
value in the term.
Sourcepub fn truncate_value_bytes(&mut self, len: usize)
pub fn truncate_value_bytes(&mut self, len: usize)
Truncates the value bytes of the term. Value and field type stays the same.
Sourcepub fn value_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn value_bytes_mut(&mut self) -> &mut [u8] ⓘ
Returns the value bytes as mutable slice
Sourcepub fn append_bytes(&mut self, bytes: &[u8]) -> &mut [u8] ⓘ
pub fn append_bytes(&mut self, bytes: &[u8]) -> &mut [u8] ⓘ
Appends value bytes to the Term.
This function returns the segment that has just been added.
Source§impl<B> Term<B>
impl<B> Term<B>
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_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the bool
value stored in a term.
Returns None
if the term is not of the bool 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] ⓘ
pub fn value_bytes(&self) -> &[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§
Source§impl<B> Ord for Term<B>
impl<B> Ord for Term<B>
Source§impl<B> PartialOrd for Term<B>
impl<B> PartialOrd for Term<B>
impl<B> Eq for Term<B>
Auto Trait Implementations§
impl<B> Freeze for Term<B>where
B: Freeze,
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more