rsynko_session/attention.rs
1use crate::SessionSorts;
2use ambassador::delegatable_trait;
3use std::time::Duration;
4
5/// Specifies what beginning, saying, running, and ending mean to whoever asked for the work.
6#[delegatable_trait]
7pub trait AttentionAlg: SessionSorts {
8 /// States that a run has begun, and whether a run of this kind can be held still.
9 fn begun(&mut self, id: &Self::Id, holdable: bool);
10
11 /// States one thing a run said.
12 fn heard(&mut self, id: &Self::Id, report: Self::Report);
13
14 /// States how long a run has been running, not counting the time it was held still.
15 fn ran_for(&mut self, id: &Self::Id, elapsed: Duration);
16
17 /// States how a run ended.
18 fn ended(&mut self, id: &Self::Id, ending: Result<Self::Ending, Self::Refusal>);
19
20 /// States what the request wants of its run now.
21 fn wanted(&self, id: &Self::Id) -> Wanted;
22}
23
24/// Denotes what a request wants of the run working on its behalf.
25///
26/// Removing a request, pausing it, and leaving the application are three ways of stating one of
27/// these three things, and a run is attended to by what is wanted rather than by why.
28#[derive(Clone, Copy, Debug, PartialEq, Eq)]
29pub enum Wanted {
30 /// Denotes a request that wants its run to carry on.
31 Running,
32 /// Denotes a request that wants its run held still, and kept.
33 Held,
34 /// Denotes a request that wants no run at all.
35 Unwanted,
36}