pub trait Phase {
type CRSElements: Hashable;
type RawContribution: Hashable;
type Contribution: Hashable;
// Required methods
fn parent_hash(contribution: &Self::RawContribution) -> ContributionHash;
fn elements(contribution: &Self::Contribution) -> &Self::CRSElements;
fn validate(
root: &Self::CRSElements,
contribution: &Self::RawContribution,
) -> Option<Self::Contribution>;
fn is_linked_to(
contribution: &Self::Contribution,
elements: &Self::CRSElements,
) -> bool;
}
Expand description
A trait abstracting common behavior between both setup phases.
This trait provides us with enough functionality to verify the contribution logs produced by both phases.
Required Associated Types§
Sourcetype CRSElements: Hashable
type CRSElements: Hashable
The type of the elements constituting this phase.
This elements will be internally valid, although possibly not correctly linked with respect to other contributions.
Sourcetype RawContribution: Hashable
type RawContribution: Hashable
The type of a contribution before any kind of validation.
Sourcetype Contribution: Hashable
type Contribution: Hashable
A contribution after having been validated.
Required Methods§
Sourcefn parent_hash(contribution: &Self::RawContribution) -> ContributionHash
fn parent_hash(contribution: &Self::RawContribution) -> ContributionHash
The hash of the parent element for a raw contribution.
Sourcefn elements(contribution: &Self::Contribution) -> &Self::CRSElements
fn elements(contribution: &Self::Contribution) -> &Self::CRSElements
The elements in a contribution.
Sourcefn validate(
root: &Self::CRSElements,
contribution: &Self::RawContribution,
) -> Option<Self::Contribution>
fn validate( root: &Self::CRSElements, contribution: &Self::RawContribution, ) -> Option<Self::Contribution>
Validate a contribution relative to some root elements.
This might fail, hence the Option.
Sourcefn is_linked_to(
contribution: &Self::Contribution,
elements: &Self::CRSElements,
) -> bool
fn is_linked_to( contribution: &Self::Contribution, elements: &Self::CRSElements, ) -> bool
Check if a contribution is linked to some parent elements.
If a contribution is linked to those elements, then it builds upon those elements correctly.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.