merge methods into 1

This commit is contained in:
vcoppe
2026-10-03 17:47:04 +02:00
parent 891a08a3cc
commit 639e7491eb
5 changed files with 14 additions and 38 deletions
+7 -9
View File
@@ -1,9 +1,9 @@
use crate::{
Append, Clean, Crop, Delete, DeleteAll, Duplicate, Elevation, Extract, Load, Merge, Metadata,
MoveWaypoint, New, NewTrack, NewTrackSegment, NewWaypoint, Replace, Reverse, Split, Style,
Time,
};
use crate::{Apply, CommandError, State};
use crate::{
Clean, Crop, Delete, DeleteAll, Duplicate, Elevation, Extract, Load, Merge, Metadata,
MoveWaypoint, New, NewTrack, NewTrackSegment, NewWaypoint, Reverse, SpliceTrackpoints, Split,
Style, Time,
};
/// A user action that edits the files. Each variant wraps the command's own struct, whose
/// effect is implemented in its own file (see `Apply`).
@@ -22,8 +22,7 @@ pub enum Command<'a> {
NewTrack(NewTrack),
NewTrackSegment(NewTrackSegment),
Reverse(Reverse),
Append(Append<'a>),
Replace(Replace<'a>),
SpliceTrackpoints(SpliceTrackpoints<'a>),
NewWaypoint(NewWaypoint<'a>),
MoveWaypoint(MoveWaypoint),
Crop(Crop),
@@ -48,8 +47,7 @@ impl Apply for Command<'_> {
Command::NewTrack(c) => c.apply(state),
Command::NewTrackSegment(c) => c.apply(state),
Command::Reverse(c) => c.apply(state),
Command::Append(c) => c.apply(state),
Command::Replace(c) => c.apply(state),
Command::SpliceTrackpoints(c) => c.apply(state),
Command::NewWaypoint(c) => c.apply(state),
Command::MoveWaypoint(c) => c.apply(state),
Command::Crop(c) => c.apply(state),
@@ -1,15 +0,0 @@
use crate::{Apply, CommandError, State};
#[derive(Debug)]
pub struct Append<'a> {
pub lng: &'a [f64],
pub lat: &'a [f64],
pub ele: &'a [f64],
}
impl Apply for Append<'_> {
fn apply(self, _state: &mut State) -> Result<(), CommandError> {
// TODO
Err(CommandError::NotImplemented("append"))
}
}
@@ -1,4 +1,3 @@
mod append;
mod clean;
mod crop;
mod elevation;
@@ -6,12 +5,11 @@ mod extract;
mod merge;
mod move_waypoint;
mod new_waypoint;
mod replace;
mod reverse;
mod splice_trackpoints;
mod split;
mod time;
pub use append::*;
pub use clean::*;
pub use crop::*;
pub use elevation::*;
@@ -19,7 +17,7 @@ pub use extract::*;
pub use merge::*;
pub use move_waypoint::*;
pub use new_waypoint::*;
pub use replace::*;
pub use reverse::*;
pub use splice_trackpoints::*;
pub use split::*;
pub use time::*;
@@ -1,7 +1,7 @@
use crate::{Apply, CommandError, State};
#[derive(Debug)]
pub struct Replace<'a> {
pub struct SpliceTrackpoints<'a> {
pub start: u32,
pub end: u32,
pub lng: &'a [f64],
@@ -9,9 +9,9 @@ pub struct Replace<'a> {
pub ele: &'a [f64],
}
impl Apply for Replace<'_> {
impl Apply for SpliceTrackpoints<'_> {
fn apply(self, _state: &mut State) -> Result<(), CommandError> {
// TODO
Err(CommandError::NotImplemented("replace"))
Err(CommandError::NotImplemented("splice_trackpoints"))
}
}