wolfrpg_map_parser/command/set_string_command/
operation.rs1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::command::set_string_command::string_operation::StringOperation;
4
5#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6#[derive(PartialEq, Clone)]
7pub struct Operation {
8 operation: StringOperation,
9 input_cancel: bool,
10 input_replace: bool,
11}
12
13impl Operation {
14 pub fn new(operation: u8) -> Self {
15 Self {
16 operation: StringOperation::new(operation & 0x0f),
17 input_replace: operation & 0b00010000 != 0,
18 input_cancel: operation & 0b00100000 != 0,
19 }
20 }
21
22 pub fn operation(&self) -> &StringOperation {
23 &self.operation
24 }
25
26 pub fn operation_mut(&mut self) -> &mut StringOperation {
27 &mut self.operation
28 }
29
30 pub fn input_cancel(&self) -> bool {
31 self.input_cancel
32 }
33
34 pub fn input_cancel_mut(&mut self) -> &mut bool {
35 &mut self.input_cancel
36 }
37
38 pub fn input_replace(&self) -> bool {
39 self.input_replace
40 }
41
42 pub fn input_replace_mut(&mut self) -> &mut bool {
43 &mut self.input_replace
44 }
45}