chatter/
chat.rs

1use crate::{Choice, Line};
2
3#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
4pub struct ChatPosition(pub(crate) Option<usize>);
5
6impl ChatPosition {
7    pub fn end() -> ChatPosition {
8        ChatPosition(None)
9    }
10
11    pub fn start() -> ChatPosition {
12        ChatPosition(Some(0))
13    }
14}
15
16pub enum ChatContent {
17    Line(Line),
18    Choices(Vec<Choice>),
19}
20
21pub struct Chat {
22    content: Vec<ChatContent>,
23}
24
25impl Chat {
26    pub fn get(&self, position: ChatPosition) -> Option<&ChatContent> {
27        match position.0 {
28            Some(pos) => Some(&self.content[pos]),
29            None => None,
30        }
31    }
32
33    pub fn new(content: Vec<ChatContent>) -> Chat {
34        Chat { content }
35    }
36}