From 761d1d181232e08fdedf500eed7cac0038911f70 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 17 Mar 2020 12:33:29 +1000 Subject: [PATCH] add card queue/type enums --- rslib/Cargo.toml | 2 ++ rslib/src/card.rs | 33 +++++++++++++++++++++++++++++++++ rslib/src/lib.rs | 1 + 3 files changed, 36 insertions(+) create mode 100644 rslib/src/card.rs diff --git a/rslib/Cargo.toml b/rslib/Cargo.toml index 4d4f51e86..7250b185c 100644 --- a/rslib/Cargo.toml +++ b/rslib/Cargo.toml @@ -36,6 +36,8 @@ slog = { version = "2.5.2", features = ["max_level_trace", "release_max_level_de slog-term = "2.5.0" slog-async = "2.4.0" slog-envlogger = "2.2.0" +serde_repr = "0.1.5" +num_enum = "0.4.2" [target.'cfg(target_vendor="apple")'.dependencies] rusqlite = { version = "0.21.0", features = ["trace"] } diff --git a/rslib/src/card.rs b/rslib/src/card.rs new file mode 100644 index 000000000..1ee1386b0 --- /dev/null +++ b/rslib/src/card.rs @@ -0,0 +1,33 @@ +// Copyright: Ankitects Pty Ltd and contributors +// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html + +use num_enum::TryFromPrimitive; +use serde_repr::{Deserialize_repr, Serialize_repr}; + +#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, TryFromPrimitive, Clone, Copy)] +#[repr(u8)] +pub enum CardType { + New = 0, + Learn = 1, + Review = 2, + Relearn = 3, +} + +#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, TryFromPrimitive, Clone, Copy)] +#[repr(i8)] +pub enum CardQueue { + /// due is the order cards are shown in + New = 0, + /// due is a unix timestamp + Learn = 1, + /// due is days since creation date + Review = 2, + DayLearn = 3, + /// due is a unix timestamp. + /// preview cards only placed here when failed. + PreviewRepeat = 4, + /// cards are not due in these states + Suspended = -1, + UserBuried = -2, + SchedBuried = -3, +} diff --git a/rslib/src/lib.rs b/rslib/src/lib.rs index f66dd1bd6..b2e410d8c 100644 --- a/rslib/src/lib.rs +++ b/rslib/src/lib.rs @@ -10,6 +10,7 @@ pub fn version() -> &'static str { } pub mod backend; +pub mod card; pub mod cloze; pub mod collection; pub mod err;