command_history 1.1.0

A library for managing command history in Rust applications.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::num::NonZeroUsize;

use super::command::Command;

pub trait CommandHistory<C: Command> {
    fn execute_command(&self, command: C, ctx: &C::Context);
    fn undo(&self, ctx: &C::Context);
    fn redo(&self, ctx: &C::Context);
    fn set_history_limit(&self, limit: NonZeroUsize);

    fn batch_execute(&self, commands: Vec<C>, ctx: &C::Context) {
        for command in commands {
            self.execute_command(command, ctx);
        }
    }
}