~ruther/map-led-strip

ref: 9eb4d9b498f88d738e5d3f2580004338e406ea7e map-led-strip/src/commands/command_data.rs -rw-r--r-- 1.2 KiB
9eb4d9b4 — František Boháček feat: reset animation in reset command 1 year, 9 months ago
                                                                                
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
use crate::animations::animation_storage::AnimationStorage;
use crate::commands::command::Command;
use crate::map::Map;

pub struct CommandData<'d, 'a> {
    command: &'d Command<'d>,
    map: &'d mut Map<'a>,
    animation_storage: &'d mut AnimationStorage
}

impl<'d, 'a> CommandData<'d, 'a> {
    pub fn new(command: &'d Command<'d>, map: &'d mut Map<'a>, animation_manager: &'d mut AnimationStorage) -> Self {
        CommandData {
            command,
            map,
            animation_storage: animation_manager
        }
    }

    pub fn animation_storage(self) -> &'d mut AnimationStorage {
        self.animation_storage
    }

    pub fn command(self) -> &'d Command<'d> {
        self.command
    }

    pub fn map(self) -> &'d mut Map<'a> {
        self.map
    }

    pub fn deconstruct_map(self) -> (&'d Command<'d>, &'d mut Map<'a>) {
        (self.command, self.map)
    }

    pub fn deconstruct_animation(self) -> (&'d Command<'d>, &'d mut AnimationStorage) {
        (self.command, self.animation_storage)
    }

    pub fn deconstruct(self) -> (&'d Command<'d>, &'d mut Map<'a>, &'d mut AnimationStorage) {
        (self.command, self.map, self.animation_storage)
    }
}
Do not follow this link