Trait diem_crypto::validatable::Validate
source · pub trait Validate: Sized {
type Unvalidated;
// Required methods
fn validate(unvalidated: &Self::Unvalidated) -> Result<Self>;
fn to_unvalidated(&self) -> Self::Unvalidated;
}Expand description
The Validate trait is used in tandem with the Validatable type in order to provide deferred
validation for types.
Trait Contract
Any type V which implement this trait must adhere to the following contract:
VandV::Unvalidatedare byte-for-byte equivalent.VandV::Unvalidatedhave equivalentHashimplementations.VandV::Unvalidatedmust have equivalentSerializeandDeserializeimplementation. This means thatVandV:Unvalidatedhave equivalent serialized formats and that you can deserialize aV::Unvalidatedfrom aVthat was previously serialized.
Required Associated Types§
sourcetype Unvalidated
type Unvalidated
The unvalidated form of some type V
Required Methods§
sourcefn validate(unvalidated: &Self::Unvalidated) -> Result<Self>
fn validate(unvalidated: &Self::Unvalidated) -> Result<Self>
Attempt to validate a V::Unvalidated and returning a validated V on success
sourcefn to_unvalidated(&self) -> Self::Unvalidated
fn to_unvalidated(&self) -> Self::Unvalidated
Return the unvalidated form of type V