pub enum FieldValue {
String(String),
Int64(i64),
Float64(f64),
Bool(bool),
Vector(Vec<f32>),
}Expand description
A metadata field value (tagged union).
Used in:
VectorData: Stores actual metadata values for each vectorMetadataIndexKey: Encodes values in index keys for filtering
§Encoding
This type has two encoding modes:
- Value encoding (via
Encode/Decodetraits): Little-endian, used inVectorData - Sortable encoding (via
encode_sortable/decode_sortable): Big-endian with sign-bit transformations, used inMetadataIndexKeyfor correct lexicographic ordering
Variants§
String(String)
Int64(i64)
Float64(f64)
Bool(bool)
Vector(Vec<f32>)
Vector value - Not valid in metadata index keys.
Implementations§
Source§impl FieldValue
impl FieldValue
Sourcepub fn field_type(&self) -> FieldType
pub fn field_type(&self) -> FieldType
Returns the type discriminant for this value.
Sourcepub fn encode_sortable(&self, buf: &mut BytesMut)
pub fn encode_sortable(&self, buf: &mut BytesMut)
Encode the field value for use in keys (sortable encoding).
Uses big-endian sortable encodings for numeric types:
- Int64: XOR with sign bit to make negative numbers sort before positive
- Float64: IEEE 754 sortable encoding
This encoding preserves lexicographic ordering in keys:
- Strings: Natural byte ordering via TerminatedBytes
- Integers: -100 < 0 < 100
- Floats: -1.0 < 0.0 < 1.0
- Bools: false < true
§Panics
Panics if called on a Vector variant since vectors should not appear in index keys.
Sourcepub fn decode_sortable(buf: &mut &[u8]) -> Result<Self, EncodingError>
pub fn decode_sortable(buf: &mut &[u8]) -> Result<Self, EncodingError>
Decode a field value from sortable key encoding.
§Errors
Returns an error if the buffer is too short or contains invalid data.
Also returns an error for Vector type since vectors should not appear in index keys.
Source§impl FieldValue
impl FieldValue
Sourcepub fn decode_with_dimensions(
buf: &mut &[u8],
dimensions: usize,
) -> Result<Self, EncodingError>
pub fn decode_with_dimensions( buf: &mut &[u8], dimensions: usize, ) -> Result<Self, EncodingError>
Decode a FieldValue that may be a Vector, using the provided dimensions.
This is used when decoding VectorData records where vectors are stored as fields.
Trait Implementations§
Source§impl Clone for FieldValue
impl Clone for FieldValue
Source§fn clone(&self) -> FieldValue
fn clone(&self) -> FieldValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FieldValue
impl Debug for FieldValue
Source§impl Decode for FieldValue
Decode implementation for FieldValue (value encoding, little-endian).
impl Decode for FieldValue
Decode implementation for FieldValue (value encoding, little-endian).
Note: For Vector type, this implementation requires the dimensions to be known.
Use FieldValue::decode_with_dimensions when decoding from VectorData records.
Source§impl Encode for FieldValue
Encode implementation for FieldValue (value encoding, little-endian).
impl Encode for FieldValue
Encode implementation for FieldValue (value encoding, little-endian).
This is used in VectorData for storing metadata and vector values.
Source§impl From<AttributeValue> for FieldValue
impl From<AttributeValue> for FieldValue
Source§fn from(attr: AttributeValue) -> Self
fn from(attr: AttributeValue) -> Self
Source§impl From<FieldValue> for AttributeValue
impl From<FieldValue> for AttributeValue
Source§fn from(field: FieldValue) -> Self
fn from(field: FieldValue) -> Self
Source§impl PartialEq for FieldValue
impl PartialEq for FieldValue
impl StructuralPartialEq for FieldValue
Auto Trait Implementations§
impl Freeze for FieldValue
impl RefUnwindSafe for FieldValue
impl Send for FieldValue
impl Sync for FieldValue
impl Unpin for FieldValue
impl UnsafeUnpin for FieldValue
impl UnwindSafe for FieldValue
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);