Trait RoleActivity

Source
pub trait RoleActivity<Candidate, TimeStamp> {
    type Activity: RuntimeEnum + Delimited + Into<DispatchError>;

    // Required method
    fn is_idle(who: &Candidate) -> Result<(), Self::Activity>;

    // Provided method
    fn is_active(who: &Candidate) -> Result<Self::Activity, ()> { ... }
}
Expand description

A lightweight abstraction for determining whether a role-bearing Candidate is currently idle or actively performing duties.

This trait models real-time operational activity, independent of role lifecycle, status, or eligibility. It is intended to compose with role management, funding, and compensation logic.

§Semantics

The core API uses an **inverted pattern which allows activity to be represented with structured context rather than a lossy boolean.

The associated Activity type must represent non-fatal engagement and be convertible into [DispatchError].

Required Associated Types§

Source

type Activity: RuntimeEnum + Delimited + Into<DispatchError>

Describes the duty currently being performed by the candidate.

Returned when the candidate is active. When converted into [DispatchError], it must clearly indicate why the operation is blocked and what must occur to withdraw from or complete the ongoing activity.

This type represents non-fatal operational engagement only.

Required Methods§

Source

fn is_idle(who: &Candidate) -> Result<(), Self::Activity>

Returns Ok(()) if the candidate is currently idle (not performing duties).

Returns Err(Activity) if the candidate is active, where Activity describes the duty being performed.

This method must not mutate state and should reflect real-time activity.

Provided Methods§

Source

fn is_active(who: &Candidate) -> Result<Self::Activity, ()>

Returns Ok(Activity) if the candidate is active, where Activity describes the duty being performed.

Returns Err(()) if the candidate is idle.

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.

Implementors§