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:
V
andV::Unvalidated
are byte-for-byte equivalent.V
andV::Unvalidated
have equivalentHash
implementations.V
andV::Unvalidated
must have equivalentSerialize
andDeserialize
implementation. This means thatV
andV:Unvalidated
have equivalent serialized formats and that you can deserialize aV::Unvalidated
from aV
that 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