nmd_core/compilable_text/
compilable_text_part.rs

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
use getset::{Getters, MutGetters, Setters};
use serde::Serialize;
use crate::codex::modifier::ModifiersBucket;


#[derive(Debug, Clone, Serialize)]
pub enum CompilableTextPartType {
    Fixed,
    Compilable{ incompatible_modifiers: ModifiersBucket },
}

#[derive(Debug, Getters, Setters, MutGetters, Clone, Serialize)]
pub struct CompilableTextPart {

    #[getset(get_mut = "pub", get = "pub", set = "pub")]
    content: String,

    #[getset(get = "pub", set = "pub")]
    part_type: CompilableTextPartType,
}

impl CompilableTextPart {
    
    pub fn new(content: String, part_type: CompilableTextPartType) -> Self {
        Self {
            content,
            part_type,
        }
    }

    pub fn new_fixed(content: String) -> Self {
        Self::new(content, CompilableTextPartType::Fixed)
    }

    pub fn new_compilable(content: String, incompatible_modifiers: ModifiersBucket) -> Self {
        Self::new(content, CompilableTextPartType::Compilable { incompatible_modifiers })
    }
}