pub trait RoleProbation<Candidate>: RoleManager<Candidate> {
Show 14 methods
// Required methods
fn is_on_probation(who: &Candidate) -> DispatchResult;
fn is_permanent(who: &Candidate) -> DispatchResult;
fn can_be_permanent(who: &Candidate) -> DispatchResult;
fn can_revoke_permanence(who: &Candidate) -> DispatchResult;
fn risk_probation(who: &Candidate) -> DispatchResult;
fn risk_permanence(who: &Candidate) -> DispatchResult;
fn secure_permanence(who: &Candidate) -> DispatchResult;
fn set_permanence(who: &Candidate) -> Result<Self::Status, DispatchError>;
fn revoke_permanence(who: &Candidate) -> Result<Self::Status, DispatchError>;
// Provided methods
fn on_risk_probation(_who: &Candidate) { ... }
fn on_risk_permanence(_who: &Candidate) { ... }
fn on_secure_permanence(_who: &Candidate) { ... }
fn on_set_permance(_who: &Candidate) { ... }
fn on_revoke_permanence(_who: &Candidate) { ... }
}Expand description
Extends RoleManager to introduce probation and permanent status mechanics
for role-based systems.
This trait manages the probation lifecycle of candidates, tracking their risk, confirmation, and eligibility for permanent status. Typical applications include:
- Employees - probation periods before permanent employment.
- Validators or council members - temporary risk periods before confirmed full status.
- Accounts or participants - temporary monitoring before achieving full privileges.
§Concepts
- Probation / Risk: Candidate is under evaluation; actions or failures may have consequences.
- Permanent / Confirmation: Candidate has successfully passed evaluation; fully confirmed.
- Secure: Temporarily avoids risk without confirming permanent status.
§Probation Flow
- A new enrolled candidate starts in probation status.
- Upon negative performance, they risk losing permanence.
- Upon meeting required criteria, they are confirmed permanent.
- If a permanent candidate violates policies, permanent status may be revoked.
§Invariants
- Candidates should not simultaneously be in probation and permanent status.
Required Methods§
Sourcefn is_on_probation(who: &Candidate) -> DispatchResult
fn is_on_probation(who: &Candidate) -> DispatchResult
Checks if the candidate is currently under probation.
Returns DispatchError if the query fails.
Sourcefn is_permanent(who: &Candidate) -> DispatchResult
fn is_permanent(who: &Candidate) -> DispatchResult
Checks if the candidate has secured permanent / confirmed status.
Returns DispatchError if the query fails.
Sourcefn can_be_permanent(who: &Candidate) -> DispatchResult
fn can_be_permanent(who: &Candidate) -> DispatchResult
Checks if the candidate is eligible to become permanent.
Returns DispatchError if the candidate is not eligible.
Sourcefn can_revoke_permanence(who: &Candidate) -> DispatchResult
fn can_revoke_permanence(who: &Candidate) -> DispatchResult
Checks if the candidate’s permanent status can be revoked, returning them to probation.
Returns DispatchError if the candidate is not eligible.
Sourcefn risk_probation(who: &Candidate) -> DispatchResult
fn risk_probation(who: &Candidate) -> DispatchResult
Places the candidate’s probation at risk (risking permanence).
Returns DispatchError if the candidate is not in probation.
Sourcefn risk_permanence(who: &Candidate) -> DispatchResult
fn risk_permanence(who: &Candidate) -> DispatchResult
Places the candidate’s permanence at risk (risking probation).
Returns DispatchError if the candidate is not in permanence.
Sourcefn secure_permanence(who: &Candidate) -> DispatchResult
fn secure_permanence(who: &Candidate) -> DispatchResult
Marks the candidate as positively progressing toward permanent status.
This indicates that the candidate has demonstrated sufficient performance or compliance during probation, making them eligible to become permanent once probation concludes.
Returns DispatchError if the candidate is not in probation.
Sourcefn set_permanence(who: &Candidate) -> Result<Self::Status, DispatchError>
fn set_permanence(who: &Candidate) -> Result<Self::Status, DispatchError>
Marks the candidate as secured / confirmed / permanent.
Returns the new status on success.
Returns DispatchError if the operation fails.
Sourcefn revoke_permanence(who: &Candidate) -> Result<Self::Status, DispatchError>
fn revoke_permanence(who: &Candidate) -> Result<Self::Status, DispatchError>
Revokes permanent status and places the candidate back under probation.
Returns the new status on success.
Returns DispatchError if the operation fails.
Provided Methods§
Sourcefn on_risk_probation(_who: &Candidate)
fn on_risk_probation(_who: &Candidate)
Hook triggered after the candidate under probation risks their permanence.
Default implementation is a no-op.
Sourcefn on_risk_permanence(_who: &Candidate)
fn on_risk_permanence(_who: &Candidate)
Hook triggered after the permanent candidate risks their permanence.
Default implementation is a no-op.
Sourcefn on_secure_permanence(_who: &Candidate)
fn on_secure_permanence(_who: &Candidate)
Hook triggered after a candidate secures being permanently promoted soon without negative impacts.
Default implementation is a no-op.
Sourcefn on_set_permance(_who: &Candidate)
fn on_set_permance(_who: &Candidate)
Hook triggered after a candidate gets permanent status.
Default implementation is a no-op.
Sourcefn on_revoke_permanence(_who: &Candidate)
fn on_revoke_permanence(_who: &Candidate)
Hook triggered after a candidate’s permanence is revoked, placing them back under probation.
Default implementation is a no-op.
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.