wolfrpg_map_parser/command/set_variable_command/
operators.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::set_variable_command::assignment::Assignment;
use crate::command::set_variable_command::calculation::Calculation;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Operators {
    assignment: Assignment,
    calculation: Calculation,
}

impl Operators {
    pub fn new(operators: u8) -> Self {
        Self {
            assignment: Assignment::from_u8(operators & 0x0f),
            calculation: Calculation::from_u8(operators >> 4),
        }
    }

    pub fn assignment(&self) -> &Assignment {
        &self.assignment
    }

    pub fn assignment_mut(&mut self) -> &mut Assignment {
        &mut self.assignment
    }

    pub fn calculation(&self) -> &Calculation {
        &self.calculation
    }

    pub fn calculation_mut(&mut self) -> &mut Calculation {
        &mut self.calculation
    }
}