pub struct GoalSlot {
pub goal: Option<Goal>,
pub armed: bool,
pub pending_round: Option<String>,
pub next_revision: u64,
}Expand description
A session’s goal together with whether automatic rounds are armed. Arming is never persisted: a goal read back from the log is disarmed until a person resumes it.
Fields§
§goal: Option<Goal>§armed: bool§pending_round: Option<String>The turn id of the round handed out and not yet started. At most one round is outstanding, so turns that end while it waits start no other.
next_revision: u64The least revision the next goal may take, so a goal created after a clear never repeats a revision an earlier round still carries.
Implementations§
Source§impl GoalSlot
impl GoalSlot
pub fn view(&self, spent: u64) -> Option<GoalView>
pub fn create( &mut self, objective: String, limits: GoalLimits, origin: TurnOrigin, ) -> Result<Goal, GoalError>
Sourcepub fn update(
&mut self,
goal_id: &str,
revision: u64,
action: GoalAction,
origin: TurnOrigin,
spent: u64,
max_rounds_limit: u32,
) -> Result<Goal, GoalError>
pub fn update( &mut self, goal_id: &str, revision: u64, action: GoalAction, origin: TurnOrigin, spent: u64, max_rounds_limit: u32, ) -> Result<Goal, GoalError>
spent is what the goal’s rounds have spent; max_rounds_limit the
most rounds an edit may give it.
pub fn clear(&mut self, origin: TurnOrigin) -> Result<(), GoalError>
Sourcepub fn disarm(&mut self) -> bool
pub fn disarm(&mut self) -> bool
Stop automatic rounds without changing the goal — a round that ended abnormally (cancelled, errored, out of budget) leaves it for a person to resume.
Sourcepub fn block_if_spent(&mut self, spent: u64, next: u64) -> bool
pub fn block_if_spent(&mut self, spent: u64, next: u64) -> bool
Mark an active goal blocked whose budget its rounds have spent, next
input included, as one whose rounds are all used is. Whether it changed.
Sourcepub fn next_round(&mut self, spent: u64) -> (Option<GoalRound>, bool)
pub fn next_round(&mut self, spent: u64) -> (Option<GoalRound>, bool)
The next automatic round, or None when the goal is not active and
armed or a round is already outstanding. A goal whose rounds or
token budget (against spent) are used up is marked blocked instead;
the second value says whether the goal changed. The round counts as
started only once it is claimed.
Sourcepub fn claim_round(&mut self, turn_id: &str) -> bool
pub fn claim_round(&mut self, turn_id: &str) -> bool
Start the outstanding round turn_id, counting it. false when it is
no longer wanted — the goal was paused, cleared, changed or disarmed
since it was handed out — and the turn must not run.
Sourcepub fn abandon_round(&mut self, turn_id: &str)
pub fn abandon_round(&mut self, turn_id: &str)
Give up the outstanding round turn_id without running it, so the
next turn to end may hand out another.