aboutsummaryrefslogtreecommitdiffstats
path: root/src/task.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2024-09-22 17:35:32 +0100
committerLibravatar cel 🌸 <cel@blos.sm>2024-09-22 17:35:32 +0100
commit811ff64dd08c8835d19c57fd959e42a28d800a53 (patch)
tree7290a8ba56da79d65ea858c8a36fd245862e33e1 /src/task.rs
parentc3fde18b74fa967a02b3a922a9a3554b80207b06 (diff)
downloadfj-811ff64dd08c8835d19c57fd959e42a28d800a53.tar.gz
fj-811ff64dd08c8835d19c57fd959e42a28d800a53.tar.bz2
fj-811ff64dd08c8835d19c57fd959e42a28d800a53.zip
WIP: dbHEADmain
Diffstat (limited to '')
-rw-r--r--src/task.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/task.rs b/src/task.rs
index dcfe776..59aa502 100644
--- a/src/task.rs
+++ b/src/task.rs
@@ -1,36 +1,52 @@
use std::{
borrow::{Borrow, Cow},
+ collections::HashSet,
str::FromStr,
};
use chrono::{NaiveDateTime, TimeDelta};
use sqlx::{
encode::IsNull,
+ prelude::FromRow,
sqlite::{SqliteArgumentValue, SqliteTypeInfo, SqliteValue},
Decode, Sqlite, Type, TypeInfo, Value, ValueRef,
};
+#[derive(FromRow)]
pub struct Task {
+ id: Option<i64>,
pub name: String,
pub cron: Option<Schedule>,
pub archived: bool,
pub description: Option<String>,
+ pub categories: HashSet<String>,
}
impl Task {
pub fn new(
name: String,
cron: Option<Schedule>,
- archived: bool,
description: Option<String>,
+ categories: Option<HashSet<String>>,
) -> Self {
Self {
+ id: None,
name,
cron,
- archived,
+ archived: false,
description,
+ categories: categories.unwrap_or_else(|| HashSet::new()),
}
}
+
+ pub fn id(&self) -> Option<i64> {
+ self.id
+ }
+
+ pub fn add_id(mut self, id: i64) -> Self {
+ self.id = Some(id);
+ self
+ }
}
pub struct Schedule(cron::Schedule);
@@ -64,6 +80,7 @@ impl Type<Sqlite> for Schedule {
}
}
+#[repr(transparent)]
pub struct Category(String);
impl Category {