Trait diem_sdk::crypto::validatable::Validate
pub trait Validate: Sized {
type Unvalidated;
// Required methods
fn validate(unvalidated: &Self::Unvalidated) -> Result<Self, Error>;
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§
type Unvalidated
type Unvalidated
The unvalidated form of some type V
Required Methods§
fn validate(unvalidated: &Self::Unvalidated) -> Result<Self, Error>
fn validate(unvalidated: &Self::Unvalidated) -> Result<Self, Error>
Attempt to validate a V::Unvalidated and returning a validated V on success
fn to_unvalidated(&self) -> Self::Unvalidated
fn to_unvalidated(&self) -> Self::Unvalidated
Return the unvalidated form of type V