pub struct Term<B = Vec<u8>>(_)
where
B: AsRef<[u8]>;
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_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.
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_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
sourceimpl<B> Hash for Term<B>where
B: AsRef<[u8]>,
impl<B> Hash for Term<B>where
B: AsRef<[u8]>,
1.3.0fn hash_slice<H>(data: &[Self], state: &mut H)where
H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H)where
H: Hasher,
Hasher
]. Read moresourceimpl<B> Ord for Term<B>where
B: AsRef<[u8]>,
impl<B> Ord for Term<B>where
B: AsRef<[u8]>,
sourceimpl<B> PartialEq<Term<B>> for Term<B>where
B: AsRef<[u8]>,
impl<B> PartialEq<Term<B>> 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]>,
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
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> CallHasher for Twhere
T: Hash + ?Sized,
impl<T> CallHasher for Twhere
T: Hash + ?Sized,
sourceimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
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>
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 moresourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn 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. Read moresourcefn 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. Read moresourceimpl<T> DowncastSync for Twhere
T: Any + Send + Sync,
impl<T> DowncastSync for Twhere
T: Any + Send + Sync,
sourcefn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>
Arc<Trait>
(where Trait: Downcast
) to Arc<Any>
. Arc<Any>
can then be
further downcast
into Arc<ConcreteType>
where ConcreteType
implements Trait
. Read more