44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
//! Project submissions (`record_as: projects` - absorbs what used to be
|
|||
|
|
//! called "inquiries"). A visitor submits a project idea plus who it's
|
||
|
|
//! for (org/contact details, captured as plain payload fields - no
|
||
|
|
//! separate Organization aggregate yet, see the event-sourcing plan).
|
||
|
|
//! `Open -> Accepted | Declined` - a real b2b-pipeline pair of terminal
|
||
|
|
//! states rather than the old generic `Handled`.
|
||
|
|
use super::AggregateKind;
|
||
|
|
|
||
|
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||
|
|
pub enum State {
|
||
|
|
Open,
|
||
|
|
Accepted,
|
||
|
|
Declined,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl AggregateKind for State {
|
||
|
|
const AGGREGATE_TYPE: &'static str = "project";
|
||
|
|
const INITIAL_STATE: Self = State::Open;
|
||
|
|
|
||
|
|
fn from_event_type(event_type: &str) -> Option<Self> {
|
||
|
|
match event_type {
|
||
|
|
"submitted" => Some(State::Open),
|
||
|
|
"accepted" => Some(State::Accepted),
|
||
|
|
"declined" => Some(State::Declined),
|
||
|
|
_ => None,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
fn event_type(self) -> &'static str {
|
||
|
|
match self {
|
||
|
|
State::Open => "submitted",
|
||
|
|
State::Accepted => "accepted",
|
||
|
|
State::Declined => "declined",
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
fn allowed(self) -> &'static [Self] {
|
||
|
|
match self {
|
||
|
|
State::Open => &[State::Accepted, State::Declined],
|
||
|
|
State::Accepted | State::Declined => &[],
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|