#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ParticipantKind {
Participant,
Actor,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Participant {
pub id: String,
pub label: String,
pub kind: ParticipantKind,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParticipantBox {
pub label: Option<String>,
pub color: Option<String>,
pub participants: Vec<usize>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct AutonumberState {
pub enabled: bool,
pub next: usize,
pub step: usize,
}
impl Default for AutonumberState {
fn default() -> Self {
Self {
enabled: false,
next: 1,
step: 1,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LineStyle {
Solid,
Dashed,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ArrowHead {
None,
Filled,
Cross,
Async,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NotePlacement {
LeftOf,
RightOf,
Over,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BlockKind {
Loop,
Alt,
Opt,
Par,
Critical,
Break,
Rect,
}
impl BlockKind {
pub fn keyword(self) -> &'static str {
match self {
Self::Loop => "loop",
Self::Alt => "alt",
Self::Opt => "opt",
Self::Par => "par",
Self::Critical => "critical",
Self::Break => "break",
Self::Rect => "rect",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BlockDividerKind {
Else,
And,
Option,
}
impl BlockDividerKind {
pub fn keyword(self) -> &'static str {
match self {
Self::Else => "else",
Self::And => "and",
Self::Option => "option",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SequenceEvent {
Message {
from: usize,
to: usize,
line_style: LineStyle,
arrow_head: ArrowHead,
text: String,
number: Option<usize>,
},
Note {
placement: NotePlacement,
participants: Vec<usize>,
text: String,
},
ActivateStart {
participant: usize,
},
ActivateEnd {
participant: usize,
},
CreateParticipant {
participant: usize,
},
DestroyParticipant {
participant: usize,
},
BlockStart { kind: BlockKind, label: String },
BlockDivider {
kind: BlockDividerKind,
label: String,
},
BlockEnd,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Sequence {
pub title: Option<String>,
pub participants: Vec<Participant>,
pub participant_boxes: Vec<ParticipantBox>,
pub events: Vec<SequenceEvent>,
pub autonumber: AutonumberState,
}