Make eval compile again
This commit is contained in:
parent
d8782fa28a
commit
de1f4a303f
4 changed files with 79 additions and 257 deletions
36
src/eval/command.rs
Normal file
36
src/eval/command.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use chrono::NaiveDate;
|
||||
|
||||
use crate::files::SourcedCommand;
|
||||
|
||||
use super::{DateRange, Entry, Result};
|
||||
|
||||
pub struct CommandState<'a> {
|
||||
command: SourcedCommand<'a>,
|
||||
range: DateRange,
|
||||
|
||||
from: Option<NaiveDate>,
|
||||
until: Option<NaiveDate>,
|
||||
entries: HashMap<NaiveDate, Entry>,
|
||||
}
|
||||
|
||||
impl<'a> CommandState<'a> {
|
||||
pub fn new(command: SourcedCommand<'a>, range: DateRange) -> Self {
|
||||
Self {
|
||||
range,
|
||||
command,
|
||||
from: None,
|
||||
until: None,
|
||||
entries: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn eval(self) -> Result<Self> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn entries(self) -> Vec<Entry> {
|
||||
self.entries.into_values().collect()
|
||||
}
|
||||
}
|
||||
23
src/eval/error.rs
Normal file
23
src/eval/error.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use std::result;
|
||||
|
||||
use chrono::NaiveDate;
|
||||
|
||||
use crate::files::commands::{Span, Time};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
DeltaInvalidStep {
|
||||
span: Span,
|
||||
start: NaiveDate,
|
||||
start_time: Option<Time>,
|
||||
prev: NaiveDate,
|
||||
prev_time: Option<Time>,
|
||||
},
|
||||
DeltaNoTime {
|
||||
span: Span,
|
||||
start: NaiveDate,
|
||||
prev: NaiveDate,
|
||||
},
|
||||
}
|
||||
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue