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 type | Input |
|---|---|
| an integer | type="number" |
f32, f64 | type="number" step="any" |
rust_decimal::Decimal, bigdecimal::BigDecimal, with the features of those names | type="number" step="any" |
jiff::civil::Date | type="date" |
jiff::civil::Time | type="time", to the minute |
jiff::civil::DateTime | type="datetime-local", to the minute |
jiff::Timestamp | type="datetime-local", to the minute, in the request’s time zone |
bool, Uuid, TenantId | type="text" |
A jiff::Zoned column has no control: no browser input carries a zone.
Required Associated Constants§
Provided Associated Constants§
Sourceconst INPUT_TYPE: &'static str = "text"
const INPUT_TYPE: &'static str = "text"
The type attribute of the text control that edits it.
Sourceconst STEP: Option<&'static str> = None
const STEP: Option<&'static str> = None
The control’s step attribute, when its input type takes one.
Sourceconst SORTABLE: bool = true
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§
Sourcefn parse_input(value: &str) -> Option<Self>
fn parse_input(value: &str) -> Option<Self>
Reads a trimmed, non-empty submission, or None when the type refuses it.
Sourcefn input_value(stored: &str, zone: &TimeZone) -> String
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.
Sourcefn form_value(posted: &str, zone: &TimeZone) -> String
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.
Sourcefn form_spelling(&self) -> String
fn form_spelling(&self) -> String
The form spelling of a stored value, which parse_input reads back:
its Display by default.
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.
impl TypedValue for Date
Binds a calendar date to a date control.
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.
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§impl TypedValue for Time
Binds a wall-clock time to a time control, which edits it to the minute.
impl TypedValue for Time
Binds a wall-clock time to a time control, which edits it to the minute.
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.
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>
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
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.
const NOUN: &'static str = "tablo-type-timestamp"
const INPUT_TYPE: &'static str = "datetime-local"
fn input_value(stored: &str, zone: &TimeZone) -> String
fn order(&self, other: &Timestamp) -> Option<Ordering>
Source§impl TypedValue for f32
Accepts finite values only.
impl TypedValue for f32
Accepts finite values only.