wolfrpg_map_parser/command/string_condition_command/
operator.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
#[cfg(feature = "serde")]
use serde::Serialize;
use crate::command::string_condition_command::compare_operator::CompareOperator;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Operator {
    value_is_variable: bool,
    operator: CompareOperator
}

impl Operator {
    pub fn new(operator: u8) -> Self {
        Self {
            value_is_variable: operator & 0b00000001 != 0,
            operator: CompareOperator::new(operator >> 4)
        }
    }

    pub fn value_is_variable(&self) -> bool {
        self.value_is_variable
    }

    pub fn value_is_variable_mut(&mut self) -> &mut bool {
        &mut self.value_is_variable
    }

    pub fn operator(&self) -> &CompareOperator {
        &self.operator
    }

    pub fn operator_mut(&mut self) -> &mut CompareOperator {
        &mut self.operator
    }
}