Skip to main content

TypedValue

Trait TypedValue 

Source
pub trait TypedValue: Display + FromStr {
    const NOUN: &'static str;
    const INPUT_TYPE: &'static str = "text";
    const STEP: Option<&'static str> = None;
    const SORTABLE: bool = true;

    // Provided methods
    fn parse_input(value: &str) -> Option<Self> { ... }
    fn input_value(stored: &str, zone: &TimeZone) -> String { ... }
    fn form_value(posted: &str, zone: &TimeZone) -> String { ... }
    fn form_spelling(&self) -> String { ... }
    fn order(&self, _other: &Self) -> Option<Ordering> { ... }
}
Expand description

Parses a typed column’s text submission and names the type in the error it produces.

A text control over a typed column renders the stored value in the input its type names, and a value the type refuses is an inline error naming it: `twelve` is not a valid whole number. The built-in types:

Column typeInput
an integertype="number"
f32, f64type="number" step="any"
rust_decimal::Decimal, bigdecimal::BigDecimal, with the features of those namestype="number" step="any"
jiff::civil::Datetype="date"
jiff::civil::Timetype="time", to the minute
jiff::civil::DateTimetype="datetime-local", to the minute
jiff::Timestamptype="datetime-local", to the minute, in the request’s time zone
bool, Uuid, TenantIdtype="text"

A jiff::Zoned column has no control: no browser input carries a zone.

Required Associated Constants§

Source

const NOUN: &'static str

The message naming this type in a validation error, such as tablo-type-date. An id no catalog holds reads as written, so "color" names the type in every locale.

Provided Associated Constants§

Source

const INPUT_TYPE: &'static str = "text"

The type attribute of the text control that edits it.

Source

const STEP: Option<&'static str> = None

The control’s step attribute, when its input type takes one.

Source

const SORTABLE: bool = true

Whether a database ORDER BY over the stored column orders values as the type does, on every driver. The PanelModel derive makes a column of the type sortable only when it does. false for the decimal types, which some drivers store as text and so sort by spelling: 10.00, 100, 9.50.

Provided Methods§

Source

fn parse_input(value: &str) -> Option<Self>

Reads a trimmed, non-empty submission, or None when the type refuses it.

Source

fn input_value(stored: &str, zone: &TimeZone) -> String

The control’s value for a stored value’s form spelling, shown in the request’s time zone zone: the spelling itself by default.

Source

fn form_value(posted: &str, zone: &TimeZone) -> String

The form spelling of what the control posted, read in the request’s time zone zone: the posted text itself by default. A type whose control posts a wall-clock time, as a timestamp’s does, reads it here, so every later step parses one spelling.

Source

fn form_spelling(&self) -> String

The form spelling of a stored value, which parse_input reads back: its Display by default.

Source

fn order(&self, _other: &Self) -> Option<Ordering>

How self orders against other, which a text field’s min and max compare by. None by default: a type without an order takes no bound.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TypedValue for Date

Binds a calendar date to a date control.

Source§

const NOUN: &'static str = "tablo-type-date"

Source§

const INPUT_TYPE: &'static str = "date"

Source§

fn order(&self, other: &Date) -> Option<Ordering>

Source§

impl TypedValue for DateTime

Binds a date and wall-clock time without a zone to a datetime-local control, which edits it to the minute.

Source§

const NOUN: &'static str = "tablo-type-date-time"

Source§

const INPUT_TYPE: &'static str = "datetime-local"

Source§

fn input_value(stored: &str, _zone: &TimeZone) -> String

Source§

fn order(&self, other: &DateTime) -> Option<Ordering>

Source§

impl TypedValue for Time

Binds a wall-clock time to a time control, which edits it to the minute.

Source§

const NOUN: &'static str = "tablo-type-time"

Source§

const INPUT_TYPE: &'static str = "time"

Source§

fn input_value(stored: &str, _zone: &TimeZone) -> String

Source§

fn order(&self, other: &Time) -> Option<Ordering>

Source§

impl TypedValue for Timestamp

Binds a timestamp to a datetime-local control, which shows and reads the wall-clock time in the request’s time_zone.

Source§

fn parse_input(value: &str) -> Option<Timestamp>

Parses RFC 3339 only: a wall-clock time names no instant until form_value reads it in a zone.

Source§

fn form_value(posted: &str, zone: &TimeZone) -> String

An instant spelled with an offset comes back in RFC 3339 UTC, and a datetime-local value is read in zone; anything else is kept as posted, for the parse to refuse.

Source§

const NOUN: &'static str = "tablo-type-timestamp"

Source§

const INPUT_TYPE: &'static str = "datetime-local"

Source§

fn input_value(stored: &str, zone: &TimeZone) -> String

Source§

fn order(&self, other: &Timestamp) -> Option<Ordering>

Source§

impl TypedValue for Uuid

Source§

const NOUN: &'static str = "tablo-type-identifier"

Source§

impl TypedValue for bool

Source§

const NOUN: &'static str = "tablo-type-boolean"

Source§

impl TypedValue for f32

Accepts finite values only.

Source§

const NOUN: &'static str = "tablo-type-number"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

const STEP: Option<&'static str>

Source§

fn parse_input(value: &str) -> Option<f32>

Source§

fn order(&self, other: &f32) -> Option<Ordering>

Source§

impl TypedValue for f64

Source§

const NOUN: &'static str = "tablo-type-number"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

const STEP: Option<&'static str>

Source§

fn parse_input(value: &str) -> Option<f64>

Source§

fn order(&self, other: &f64) -> Option<Ordering>

Source§

impl TypedValue for i8

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &i8) -> Option<Ordering>

Source§

impl TypedValue for i16

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &i16) -> Option<Ordering>

Source§

impl TypedValue for i32

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &i32) -> Option<Ordering>

Source§

impl TypedValue for i64

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &i64) -> Option<Ordering>

Source§

impl TypedValue for i128

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &i128) -> Option<Ordering>

Source§

impl TypedValue for isize

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &isize) -> Option<Ordering>

Source§

impl TypedValue for u8

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &u8) -> Option<Ordering>

Source§

impl TypedValue for u16

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &u16) -> Option<Ordering>

Source§

impl TypedValue for u32

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &u32) -> Option<Ordering>

Source§

impl TypedValue for u64

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &u64) -> Option<Ordering>

Source§

impl TypedValue for u128

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &u128) -> Option<Ordering>

Source§

impl TypedValue for usize

Source§

const NOUN: &'static str = "tablo-type-integer"

Source§

const INPUT_TYPE: &'static str = "number"

Source§

fn order(&self, other: &usize) -> Option<Ordering>

Implementors§

Source§

impl TypedValue for TenantId

Source§

const NOUN: &'static str = "tablo-type-identifier"