diff --git a/src/todo/file.rs b/src/todo/file.rs index b0326a0..60fcbfd 100644 --- a/src/todo/file.rs +++ b/src/todo/file.rs @@ -10,6 +10,11 @@ pub struct File { pub date: NaiveDate, } +pub enum FileError{ + //IOError(&'static str), + ParseError(&'static str) +} + impl File { fn capture_as_number(capture: ®ex::Captures, name: &str) -> Result { Ok(capture @@ -37,7 +42,7 @@ impl File { } impl TryFrom for File { - type Error = String; + type Error = FileError; fn try_from(direntry: DirEntry) -> Result { let re = File::get_file_regex(); @@ -59,10 +64,6 @@ impl TryFrom for File { date: NaiveDate::from_ymd_opt(year, month, day).unwrap(), }); }; - Err(format!( - "Could not parse file name => {{ name: {:?}, re: {:?} }}", - file_name, re - ) - .to_string()) + Err(FileError::ParseError("Could not parse file name")) } } diff --git a/src/todo/tasks.rs b/src/todo/tasks.rs index 11d580b..b3c1357 100644 --- a/src/todo/tasks.rs +++ b/src/todo/tasks.rs @@ -15,7 +15,7 @@ pub struct TaskGroup { pub struct Task { pub status: Status, pub text: String, - level: u8, +// level: u8, pub subtasks: Option>, } @@ -31,17 +31,6 @@ pub enum TaskError { } impl Task { - fn find_text<'a>(node: &'a AstNode<'a>) -> String { - let mut text = String::new(); - for child in node.descendants() { - let data_ref = child.data.borrow(); - if let NodeValue::Text(contents) = &data_ref.value { - text.push_str(format!("{}\n ", &contents.clone()).as_str()); - }; - } - text - } - fn extract_text<'a>(node: &'a AstNode<'a>) -> Result { let data_ref = node.data.borrow(); if let NodeValue::Text(contents) = &data_ref.value { @@ -144,7 +133,7 @@ impl<'a> TryFrom<&'a AstNode<'a>> for Task { status, text, subtasks, - level: 1, + // level: 1, }) } else { Err(TaskError::ParsingError(