mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-10-28 02:47:17 +00:00
progress
This commit is contained in:
1 parent
41b9116c6a
commit
97d597e139
181 files changed
+1970
-2643
No files matched your search
@@ -0,0 +1,30 @@
|
||||
use std::fmt;
|
||||
|
||||
use crate::State;
|
||||
|
||||
/// The effect of a command on the engine state.
|
||||
///
|
||||
/// Each command is a small struct holding its arguments, with its effect implemented in its
|
||||
/// own file. Effects are built from the reusable patterns in `pattern/`.
|
||||
pub trait Apply {
|
||||
fn apply(self, state: &mut State) -> Result<(), CommandError>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum CommandError {
|
||||
/// The command would not change anything.
|
||||
NothingToDo,
|
||||
/// The input data could not be parsed.
|
||||
InvalidData(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for CommandError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::NothingToDo => write!(f, "nothing to do"),
|
||||
Self::InvalidData(err) => write!(f, "invalid data: {err}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for CommandError {}
|
||||
Reference in new issue
Block a user