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§
Provided Methods§
Sourcefn resolve_options(
&self,
_raw: &Value,
_types: &FieldRegistry,
) -> Result<ResolvedOptions, OptionsError>
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.
Sourcefn option_keys(&self) -> Vec<&'static str>
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.
Sourcefn rules(&self, _opts: &ResolvedOptions) -> Vec<Rule>
fn rules(&self, _opts: &ResolvedOptions) -> Vec<Rule>
Rules this input contributes (an email input adds Rule::Email).
Sourcefn attributes(&self, _opts: &ResolvedOptions) -> BTreeMap<String, String>
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.
Sourcefn adornments(&self, _opts: &ResolvedOptions) -> Vec<Adornment>
fn adornments(&self, _opts: &ResolvedOptions) -> Vec<Adornment>
Controls placed beside the input (a copy button, a currency symbol).
Sourcefn assets(&self, _opts: &ResolvedOptions) -> Vec<&'static str>
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".