Skip to main content

InputType

Trait InputType 

Source
pub trait InputType:
    Send
    + Sync
    + 'static {
    // Required method
    fn key(&self) -> &'static str;

    // Provided methods
    fn html_type(&self) -> &'static str { ... }
    fn resolve_options(
        &self,
        _raw: &Value,
        _types: &FieldRegistry,
    ) -> Result<ResolvedOptions, OptionsError> { ... }
    fn option_keys(&self) -> Vec<&'static str> { ... }
    fn rules(&self, _opts: &ResolvedOptions) -> Vec<Rule> { ... }
    fn attributes(&self, _opts: &ResolvedOptions) -> BTreeMap<String, String> { ... }
    fn adornments(&self, _opts: &ResolvedOptions) -> Vec<Adornment> { ... }
    fn assets(&self, _opts: &ResolvedOptions) -> Vec<&'static str> { ... }
}
Expand description

An input variant of the text field: its HTML type, the rules it contributes, and how it parameterises the one text control (extra attributes, adjacent adornments). The extension point a plugin builds on (a currency input, say) instead of reimplementing a field. An input parameterises the single text control; anything needing different control markup is a FieldType.

Required Methods§

Source

fn key(&self) -> &'static str

The registry key naming this input (text, email, url, currency).

Provided Methods§

Source

fn html_type(&self) -> &'static str

The HTML type attribute.

Source

fn resolve_options( &self, _raw: &Value, _types: &FieldRegistry, ) -> Result<ResolvedOptions, OptionsError>

Types this input’s own keys from the field’s options blob (the same blob the field type reads) once at boot. Default: no options.

Source

fn option_keys(&self) -> Vec<&'static str>

The keys this input reads from the field’s entry (min, max, step for a number). A key no part of the field reads is refused.

Source

fn rules(&self, _opts: &ResolvedOptions) -> Vec<Rule>

Rules this input contributes (an email input adds Rule::Email).

Source

fn attributes(&self, _opts: &ResolvedOptions) -> BTreeMap<String, String>

Extra <input> attributes (a number input’s min/max/step). Names are validated at boot and may not collide with the ones the template owns.

Source

fn adornments(&self, _opts: &ResolvedOptions) -> Vec<Adornment>

Controls placed beside the input (a copy button, a currency symbol).

Source

fn assets(&self, _opts: &ResolvedOptions) -> Vec<&'static str>

Asset-registry keys this input needs (a heavy widget’s script/style). The copy button needs none, since its island ships in core laterite.js.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§