Skip to main content

CanonicalText

Enum CanonicalText 

Source
#[non_exhaustive]
pub enum CanonicalText { Date, Timestamp, ZonedTimestamp, Decimal { scale: u8, }, Float { significant: u8, }, Boolean, AsCast, }
Expand description

What a value’s text is, by its type.

One classification, so no two engines can disagree about which types have a canonical text and which are written by the engine’s own cast.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Date

A calendar day: YYYY-MM-DD, as in 2026-01-05.

§

Timestamp

A moment with no time zone: YYYY-MM-DD HH:MM:SS, then a point and the fraction of a second to the microsecond with its trailing zeros dropped. A whole second has no point and no fraction: 2026-01-05 12:34:56.12 and 2026-01-05 00:00:00.

§

ZonedTimestamp

A moment with a time zone: the same moment in UTC, written as a Timestamp is and then +00:00, whatever zone the value or the session is in. 14:34:56.12 at +02:00 is 2026-01-05 12:34:56.12+00:00.

§

Decimal

A decimal: every digit of its declared scale after a point, and none where the scale is zero. A DECIMAL(12, 2) ten is 10.00, a negative half is -0.50, and the separator is always a point.

Fields

§scale: u8

How many digits follow the point.

§

Float

A floating number: the value rounded to significant digits and written the way C’s printf writes %.{significant}g.

Without an exponent where the rounded value’s power of ten is at least -4 and below significant, and with one otherwise; trailing zeros and a bare point dropped; an exponent as e, a sign and at least two digits. A double ten is 10 (never 10.0), a tenth 0.1, 0.1 + 0.2 is 0.3, 1.5e-7 is 1.5e-07, and 10^20 is 1e+20. A zero is 0, whatever its sign.

A double carries DOUBLE_DIGITS and a single-precision number SINGLE_DIGITS: the most digits of a decimal that survive the trip into the type and back. A value the source wrote with that many digits or fewer reads back as written, and the binary noise past them — the 4 at the end of 0.30000000000000004 — is never shown. A single-precision value reads the same on an engine that holds it as a double. Not-a-number and the infinities have no canonical text.

Fields

§significant: u8

How many significant digits the value is rounded to.

§

Boolean

A truth value: true or false, on an engine that holds it as a number too.

§

AsCast

Every other type, written by the engine’s own cast to text.

Implementations§

Source§

impl CanonicalText

Source

pub fn of(data_type: &DataType) -> Self

The canonical text of a value of data_type.

Trait Implementations§

Source§

impl Clone for CanonicalText

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CanonicalText

Source§

impl Debug for CanonicalText

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CanonicalText

Source§

impl PartialEq for CanonicalText

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CanonicalText

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.