pub trait Model:
Attributes
+ ModelNaming
+ Conversion
+ Serialization
+ Sized
+ Send
+ Sync {
// Required methods
fn new() -> Self;
fn errors(&self) -> &Errors;
fn errors_mut(&mut self) -> &mut Errors;
// Provided methods
fn initialize(attrs: HashMap<String, Value>) -> Result<Self, AttributeError> { ... }
fn is_valid(&self) -> bool { ... }
fn is_invalid(&self) -> bool { ... }
fn validate(&mut self) -> bool { ... }
}Expand description
The minimum viable model interface shared by RustRails model types.
Required Methods§
Sourcefn errors_mut(&mut self) -> &mut Errors
fn errors_mut(&mut self) -> &mut Errors
Returns the mutable error collection for validation updates.
Provided Methods§
Sourcefn initialize(attrs: HashMap<String, Value>) -> Result<Self, AttributeError>
fn initialize(attrs: HashMap<String, Value>) -> Result<Self, AttributeError>
Creates a new instance and applies the provided attributes.
Sourcefn is_invalid(&self) -> bool
fn is_invalid(&self) -> bool
Returns true when the model considers itself invalid.
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.