Trait StructForm

Source
pub trait StructForm<Model> {
    type Field;

    // Required methods
    fn new(model: &Model) -> Self;
    fn set_input(&mut self, field: Self::Field, value: String);
    fn submit(&mut self) -> Result<Model, ParseError>;
    fn submit_update(&mut self, model: Model) -> Result<Model, ParseError>;
    fn submit_attempted(&self) -> bool;
    fn is_empty(&self) -> bool;

    // Provided methods
    fn has_unsaved_changes(&self, pristine: &Model) -> bool
       where Self: Clone,
             Model: Clone + PartialEq { ... }
    fn validation_error(&self) -> Option<ParseError>
       where Self: Clone { ... }
}

Required Associated Types§

Required Methods§

Source

fn new(model: &Model) -> Self

Source

fn set_input(&mut self, field: Self::Field, value: String)

Source

fn submit(&mut self) -> Result<Model, ParseError>

Source

fn submit_update(&mut self, model: Model) -> Result<Model, ParseError>

Source

fn submit_attempted(&self) -> bool

Source

fn is_empty(&self) -> bool

Provided Methods§

Source

fn has_unsaved_changes(&self, pristine: &Model) -> bool
where Self: Clone, Model: Clone + PartialEq,

Source

fn validation_error(&self) -> Option<ParseError>
where Self: Clone,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§