Skip to main content

FieldType

Trait FieldType 

Source
pub trait FieldType:
    Send
    + Sync
    + 'static {
    // Required methods
    fn view_key(&self) -> &'static str;
    fn view_model(&self, cx: &FieldCx<'_>) -> FieldVm;
    fn render_default(&self, vm: &FieldVm) -> Markup;

    // Provided methods
    fn resolve_options(
        &self,
        _raw: &Value,
    ) -> Result<ResolvedOptions, OptionsError> { ... }
    fn intrinsic_rules(&self, _opts: &ResolvedOptions) -> Vec<Rule> { ... }
    fn chrome(&self) -> Chrome { ... }
    fn assets(&self, _opts: &ResolvedOptions) -> Vec<&'static str> { ... }
}
Expand description

A field type: behaviour registered once per string key.

Required Methods§

Source

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

The stable key for override resolution and default-template selection (bare like text for core; dotted vendor.name for plugins).

Source

fn view_model(&self, cx: &FieldCx<'_>) -> FieldVm

Builds the serialisable presentation payload. Pure, no IO.

Source

fn render_default(&self, vm: &FieldVm) -> Markup

The built-in presenter over the view-model (an Askama partial). Not called when an override wins.

Provided Methods§

Source

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

Types the descriptor’s raw options blob once at boot. A failure aborts boot naming the resource + field. Default: no options.

Source

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

Rules this type always contributes, merged before the descriptor’s own (e.g. the text field’s email input contributes Rule::Email).

Source

fn chrome(&self) -> Chrome

Whether the framework wraps this field in standard chrome.

Source

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

Asset-registry keys this type’s control needs on any page that renders it (a heavy widget’s script/style). The page shell collects, dedupes, and emits them; keys must exist in the asset registry. Default: none, so a type whose widget ships in core laterite.js declares nothing.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§