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::mutable_command::MutableCommand;

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

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