wolfrpg_map_parser/command/set_string_command/
operation.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
39
40
41
42
43
44
#[cfg(feature = "serde")]
use serde::Serialize;
use crate::command::set_string_command::string_operation::StringOperation;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Operation {
    operation: StringOperation,
    input_cancel: bool,
    input_replace: bool,
}

impl Operation {
    pub fn new(operation: u8) -> Self {
        Self {
            operation: StringOperation::new(operation & 0x0f),
            input_replace: operation & 0b00010000 != 0,
            input_cancel: operation  & 0b00100000 != 0,
        }
    }

    pub fn operation(&self) -> &StringOperation {
        &self.operation
    }

    pub fn operation_mut(&mut self) -> &mut StringOperation {
        &mut self.operation
    }

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

    pub fn input_cancel_mut(&mut self) -> &mut bool {
        &mut self.input_cancel
    }

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

    pub fn input_replace_mut(&mut self) -> &mut bool {
        &mut self.input_replace
    }
}