Skip to main content

xrpl/models/
model.rs

1//! Base model
2
3use super::XRPLModelResult;
4
5/// A trait that implements basic functions to every model.
6pub trait Model {
7    /// Collects a models errors and returns the first error that occurs.
8    fn get_errors(&self) -> XRPLModelResult<()> {
9        Ok(())
10    }
11
12    /// Simply forwards the error from `get_errors` if there was one.
13    fn validate(&self) -> XRPLModelResult<()> {
14        self.get_errors()
15    }
16
17    /// Checks if the model is valid.
18    fn is_valid(&self) -> bool {
19        self.validate().is_ok()
20    }
21}