thot_core/runner/resources/
script_association.rs1use crate::project::script::Script;
2use std::hash::{Hash, Hasher};
3
4#[derive(Clone, Debug)]
5pub struct ScriptAssociation {
6 _priority: i32,
8 _autorun: bool,
9 _script: Script,
10}
11
12impl ScriptAssociation {
13 pub fn new(priority: i32, autorun: bool, script: Script) -> Self {
14 Self {
15 _priority: priority,
16 _autorun: autorun,
17 _script: script,
18 }
19 }
20
21 pub fn priority(&self) -> i32 {
22 self._priority
23 }
24
25 pub fn autorun(&self) -> bool {
26 self._autorun
27 }
28
29 pub fn script(&self) -> &Script {
30 &self._script
31 }
32}
33
34impl PartialEq for ScriptAssociation {
35 fn eq(&self, other: &Self) -> bool {
36 self.script().rid.eq(&other.script().rid)
37 }
38}
39
40impl Eq for ScriptAssociation {}
41
42impl Hash for ScriptAssociation {
43 fn hash<H: Hasher>(&self, state: &mut H) {
44 self.script().rid.hash(state);
45 }
46}
47
48#[cfg(test)]
49#[path = "./script_association_test.rs"]
50mod script_association_test;