aragog/
new.rs

1use crate::Error;
2
3/// The `New` trait of the Aragog library.
4/// This trait provides the possibility to initialize a Type from an other one. Its main use
5/// it to transform a Http form into a [`Record`] model instance.
6///
7/// [`Record`]: crate::Record
8pub trait New<T>: Sized {
9    /// Instantiate and returns a new `Self` instance from `T`.
10    ///
11    /// # Errors
12    ///
13    /// Can fail and return an error, the error is in most of the cases an [`Error`]::[`ValidationError`]
14    /// on fields validation failure
15    ///
16    /// [`Error`]: crate::Error
17    /// [`ValidationError`]: crate::Error::ValidationError
18    fn new(form: T) -> Result<Self, Error>;
19}