blob: 3e41c6ff2debe4c3d9600c5c0920c9b490866b74 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
//! Builder patterns to manipulate an unprocessed thread of patches
use crate::Patch;
/// Abstraction over a generic email
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Mail<'mail> {
/// A git-sent email with patch information
Git(Patch<'mail>),
/// A non git-mail reply
Mail(String),
}
/// A tree of patches that can be filtered to yield a `PatchSet`
pub struct PatchTree<'mail> {
/// The current patch
pub this: Mail<'mail>,
/// All replies to this patch mail
pub children: Vec<PatchTree<'mail>>,
/// Mark an email as selected
pub selected: bool,
}
impl<'mail> PatchTree<'mail> {
pub fn new(initial: Patch<'mail>) -> Self {
Self {
this: Mail::Git(initial),
children: Default::default(),
selected: false,
}
}
/// Select a specific mail into the tree
pub fn select(&mut self) {
self.selected = true;
}
/// Deselect a single mail from the tree
pub fn deselect(&mut self) {
self.selected = false;
}
}
|