#[non_exhaustive]pub enum CellValue<'a> {
Empty,
Bool(bool),
Int(i64),
Float(f64),
Decimal(Decimal),
Text(&'a str),
Timestamp(DateTime<Utc>),
Icon(IconValue<'a>),
Image(ImageValue<'a>),
Link(LinkValue<'a>),
Custom(&'a dyn GridValue),
}Expand description
A cell value. Numbers, points in time and borrowed text do not allocate.
== compares two values of one variant: floats with f64::eq (a NaN is
not equal to itself, -0.0 equals 0.0), decimals by value (1.0 equals
1.00), icons by path and text, custom values by
GridValue::cmp_value. Values of two variants are never equal, not
even Int(1) and Float(1.0). GridRow::changed_columns diffs rows
with it; CellValue::cmp_total is the order.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Empty
No value.
Bool(bool)
A boolean.
Int(i64)
An integer.
Float(f64)
A floating point number.
Decimal(Decimal)
An exact decimal number with its scale: money, quantities with a
fixed number of decimals. 12.30 shows as 12.30. Needs the
decimal feature.
Text(&'a str)
Text borrowed from the row.
Timestamp(DateTime<Utc>)
A point in time. Shown in UTC as 2026-11-04 12:34:56 until a column
formatter exists; another zone or format is a CellValue::Custom
value with its own text. A date without a time is the timestamp of
its midnight in UTC.
Icon(IconValue<'a>)
An icon with the text that stands for it. The body paints the icon; the text is what a screen reader, a tooltip, the quick filter, a copy and the sort read.
Image(ImageValue<'a>)
An image with the text that stands for it: a raster or a colour SVG
that the grid’s image source (LiveGridState::with_image_source)
finds by its id. Like an icon, the body paints the image and the text
is what a screen reader, a tooltip, the quick filter, a copy and the
sort read.
Link(LinkValue<'a>)
A link: its text, which the cell shows in the theme’s link colour,
underlined, and the address a click on the text or Enter on the
focused cell opens (LiveGridState::with_link_opener). The text is
the value everywhere else, as an icon’s: the sort, the quick filter,
a copy, an export and a screen reader, which hears “link” after it.
Painted by the body: no element per cell.
Custom(&'a dyn GridValue)
A value of the application’s own type, borrowed from the row: its own
order, text and export. See GridValue.
Implementations§
Source§impl CellValue<'_>
impl CellValue<'_>
Sourcepub fn cmp_total(&self, other: &Self) -> Ordering
pub fn cmp_total(&self, other: &Self) -> Ordering
A total order across all values: Empty first, then Bool,
numbers, Timestamp, Text, Icon and Image, and Custom last,
each by value.
Numbers follow f64::total_cmp, and an Int compares exactly, as
the float of its value would: Int(1) equals Float(1.0) and
Int(2^53 + 1) is above Float(2^53). So -0.0 sorts just below 0.0
and Int(0), a negative NaN before -∞ and a positive NaN after +∞.
A Decimal (the decimal feature) is a number too and compares
exactly by its value, whatever its scale: Decimal(1.00) equals
Int(1) and Float(1.0), Decimal(0.1) is below Float(0.1),
whose binary value is a little above 0.1, and a zero Decimal of any
sign or scale sorts as Int(0), above -0.0.
Timestamps compare by time. An Icon, an Image and a Link sort
by their text, as Text does: an icon, an image, a link and a text
with the same text are equal. Custom values compare with
GridValue::cmp_value, which keeps the order total.
Not the same as ==, which compares floats with f64::eq (a NaN is
not equal to itself, -0.0 equals 0.0), compares decimals by value
(1.0 equals 1.00) and never calls values of two variants equal.
Trait Implementations§
impl<'a> Copy for CellValue<'a>
Auto Trait Implementations§
impl<'a> Freeze for CellValue<'a>
impl<'a> !RefUnwindSafe for CellValue<'a>
impl<'a> Send for CellValue<'a>
impl<'a> Sync for CellValue<'a>
impl<'a> Unpin for CellValue<'a>
impl<'a> UnsafeUnpin for CellValue<'a>
impl<'a> !UnwindSafe for CellValue<'a>
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more