Add cli & lib crates
This commit is contained in:
13
lib/Cargo.toml
Normal file
13
lib/Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "stl_lib"
|
||||
version = "2.5.0"
|
||||
authors = ["Joakim Hulthe <joakim@hulthe.net>"]
|
||||
license = "MPL-2.0"
|
||||
edition = "2018"
|
||||
|
||||
|
||||
[dependencies]
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
uuid = { version = "0.8", features = ["serde", "v4"] }
|
||||
|
||||
4
lib/src/api.rs
Normal file
4
lib/src/api.rs
Normal file
@ -0,0 +1,4 @@
|
||||
pub mod url {
|
||||
pub const SESSIONS: &str = "/api/sessions";
|
||||
pub const WAIT_FOR_EVENT: &str = "/api/wait_for_event";
|
||||
}
|
||||
27
lib/src/category.rs
Normal file
27
lib/src/category.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use chrono::{DateTime, Local};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub type CategoryKey = Uuid;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Category {
|
||||
/// The name of the category
|
||||
pub name: String,
|
||||
|
||||
/// The description of the category
|
||||
pub description: Option<String>,
|
||||
|
||||
/// The HTML color of the category in the rendered view
|
||||
pub color: String,
|
||||
|
||||
/// If the session is not active, this will be None
|
||||
pub started: Option<DateTime<Local>>,
|
||||
|
||||
/// The parent category of this category
|
||||
/// If none, the category has no parent
|
||||
pub parent: Option<CategoryKey>,
|
||||
|
||||
/// Whether the item has been "deleted", e.g. it shoudn't be shown in the view
|
||||
pub deleted: bool,
|
||||
}
|
||||
3
lib/src/lib.rs
Normal file
3
lib/src/lib.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub mod api;
|
||||
pub mod v2;
|
||||
pub mod wfe;
|
||||
63
lib/src/v2.rs
Normal file
63
lib/src/v2.rs
Normal file
@ -0,0 +1,63 @@
|
||||
pub(self) use chrono::{DateTime, Local};
|
||||
pub(self) use serde::{Deserialize, Serialize};
|
||||
pub(self) use uuid::Uuid;
|
||||
|
||||
/// Stuff in the default namespace
|
||||
pub mod global {}
|
||||
|
||||
pub mod trees {
|
||||
pub mod category {
|
||||
use super::super::*;
|
||||
|
||||
pub const NAME: &str = "CATEGORIES";
|
||||
|
||||
pub type K = Uuid;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct V {
|
||||
/// The name of the category
|
||||
pub name: String,
|
||||
|
||||
/// The description of the category
|
||||
pub description: Option<String>,
|
||||
|
||||
/// The HTML color of the category in the rendered view
|
||||
pub color: String,
|
||||
|
||||
/// If the session is not active, this will be None
|
||||
pub started: Option<DateTime<Local>>,
|
||||
|
||||
/// The parent category of this category
|
||||
/// If none, the category has no parent
|
||||
pub parent: Option<K>,
|
||||
|
||||
// FIXME: this field is currently not used
|
||||
/// Whether the item has been "deleted", e.g. it shoudn't be shown in the view
|
||||
pub deleted: bool,
|
||||
}
|
||||
}
|
||||
|
||||
pub mod session {
|
||||
use super::super::*;
|
||||
|
||||
pub const NAME: &str = "SESSIONS";
|
||||
|
||||
pub type K = Uuid;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct V {
|
||||
/// The UUID of the category to which this session belongs
|
||||
pub category: trees::category::K,
|
||||
|
||||
/// The time when this session was started
|
||||
pub started: DateTime<Local>,
|
||||
|
||||
/// The time when this session was ended
|
||||
pub ended: DateTime<Local>,
|
||||
|
||||
// FIXME: this field is currently not used
|
||||
/// Whether the item has been "deleted", e.g. it shoudn't be shown in the view
|
||||
pub deleted: bool,
|
||||
}
|
||||
}
|
||||
}
|
||||
6
lib/src/wfe.rs
Normal file
6
lib/src/wfe.rs
Normal file
@ -0,0 +1,6 @@
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct WaitForEvent {
|
||||
pub timeout: bool,
|
||||
}
|
||||
Reference in New Issue
Block a user