Trait diem_sdk::crypto::validatable::Validate[][src]

pub trait Validate {
    type Unvalidated;
    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 and V::Unvalidated are byte-for-byte equivalent.
  • V and V::Unvalidated have equivalent Hash implementations.
  • V and V::Unvalidated must have equivalent Serialize and Deserialize implementation. This means that V and V:Unvalidated have equivalent serialized formats and that you can deserialize a V::Unvalidated from a V that was previously serialized.

Associated Types

The unvalidated form of some type V

Required methods

Attempt to validate a V::Unvalidated and returning a validated V on success

Return the unvalidated form of type V

Implementors