From c8bb484a531c9ecca88f3eb4596827a580818df8 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sun, 6 Oct 2024 05:51:39 -0500 Subject: [PATCH] fleshing out the core a bit more --- Cargo.lock | 25 +++++ Cargo.toml | 3 + justfile | 4 + src/rust/core/Cargo.toml | 55 +++++++++++ src/rust/core/images.rs | 11 +++ src/rust/core/kinds.rs | 18 ++-- src/rust/core/lib.rs | 7 ++ src/rust/core/mod.rs | 2 - src/rust/core/presentations.rs | 38 ++++++++ src/rust/core/service_items.rs | 52 ++++++++++ src/rust/core/slides.rs | 108 +++++++++++++++++++++ src/rust/core/songs.rs | 172 +++++++++++++++++++++++++++++++++ src/rust/core/videos.rs | 11 +++ 13 files changed, 497 insertions(+), 9 deletions(-) create mode 100644 src/rust/core/Cargo.toml create mode 100644 src/rust/core/images.rs create mode 100644 src/rust/core/lib.rs delete mode 100644 src/rust/core/mod.rs create mode 100644 src/rust/core/presentations.rs create mode 100644 src/rust/core/slides.rs create mode 100644 src/rust/core/songs.rs create mode 100644 src/rust/core/videos.rs diff --git a/Cargo.lock b/Cargo.lock index 86dd0d2..9725a70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -490,6 +490,31 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "core" +version = "0.1.0" +dependencies = [ + "color-eyre", + "configparser", + "dirs", + "fastrand 2.1.1", + "obws", + "quote", + "reqwest", + "rfd", + "serde", + "serde_derive", + "serde_json", + "sqlx", + "tar", + "time", + "tokio", + "tracing", + "tracing-subscriber", + "youtube_dl", + "zstd", +] + [[package]] name = "core-foundation" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index dff6e5c..1cdd18f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,6 @@ +[workspace] +members = ["src/rust/core"] + [package] name = "liblumina" version = "0.1.0" diff --git a/justfile b/justfile index fff41ce..a332b6d 100644 --- a/justfile +++ b/justfile @@ -14,5 +14,9 @@ clean: test: RUST_LOG=debug cargo test --benches --tests --all-features -- --nocapture +testcore: + RUST_LOG=debug cargo test -p core --benches --tests --all-features -- --nocapture + alias b := build alias r := run +alias tc := testcore diff --git a/src/rust/core/Cargo.toml b/src/rust/core/Cargo.toml new file mode 100644 index 0000000..e36be44 --- /dev/null +++ b/src/rust/core/Cargo.toml @@ -0,0 +1,55 @@ +[package] +name = "core" +version = "0.1.0" +edition = "2021" +authors = [ + "Chris Cochrun " +] +license = "GPL-3.0" + +# This will instruct Cargo to create a static +# library which CMake can link against +[lib] +crate-type = ["staticlib"] +path = "lib.rs" + +# [[bin]] +# name = "lumina" +# path = "src/rust/main.rs" + +[dependencies] +configparser = "3.0.2" +serde = "1.0.152" +serde_derive = "1.0.152" +quote = "1.0.27" +# cxx = "1.0.83" +# cxx-qt = "0.6.1" +# cxx-qt-lib = "0.6.1" +# home = "0.5.4" +dirs = "5.0.0" +# libsqlite3-sys = { version = ">=0.17.2", features = ["bundled"] } +youtube_dl = "0.8.0" +tar = "0.4.40" +zstd = "0.12.4" +serde_json = "1.0.104" +fastrand = "2.0.0" +rfd = { version = "0.12.1", features = ["xdg-portal"], default-features = false } +sqlx = { version = "0.8.2", features = ["sqlite", "runtime-tokio", "macros"] } +tokio = { version = "1.32.0", features = ["full"] } +tracing-subscriber = { version = "0.3.17", features = ["fmt", "std", "chrono", "time", "local-time", "env-filter"] } +tracing = "0.1.37" +time = { version = "0.3.29", features = ["formatting", "macros"] } +obws = "0.13.0" +reqwest = "0.11.23" +color-eyre = "0.6.3" +# ffmpeg-next = "6.0.0" + +# cxx-qt-build generates C++ code from the `#[cxx_qt::bridge]` module +# and compiles it together with the Rust static library +# [build-dependencies] +# cxx-qt-build = { version = "0.6.1", features = [ "link_qt_object_files" ] } +# qt-build-utils = "0.6.1" + +# [dependencies.confy] +# features = ["yaml_conf"] +# default-features = false \ No newline at end of file diff --git a/src/rust/core/images.rs b/src/rust/core/images.rs new file mode 100644 index 0000000..8d2cf08 --- /dev/null +++ b/src/rust/core/images.rs @@ -0,0 +1,11 @@ +pub struct Image { + title: String +} + +#[cfg(test)] +mod test { + #[test] + pub fn test_image() { + assert_eq!(true, true) + } +} diff --git a/src/rust/core/kinds.rs b/src/rust/core/kinds.rs index 4bc5618..b5b3be8 100644 --- a/src/rust/core/kinds.rs +++ b/src/rust/core/kinds.rs @@ -1,14 +1,10 @@ use std::{error::Error, fmt::Display}; -#[derive(Debug, Clone)] -pub enum PresKind { - Html, - Pdf, - Generic, -} +use crate::presentations::PresKind; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default, PartialEq, Eq)] pub enum ServiceItemKind { + #[default] Song, Video, Image, @@ -81,3 +77,11 @@ impl Display for ParseError { write!(f, "Error: {message}") } } + +#[cfg(test)] +mod test { + #[test] + pub fn test_kinds() { + assert_eq!(true, true) + } +} diff --git a/src/rust/core/lib.rs b/src/rust/core/lib.rs new file mode 100644 index 0000000..d74cff7 --- /dev/null +++ b/src/rust/core/lib.rs @@ -0,0 +1,7 @@ +pub mod service_items; +pub mod kinds; +pub mod slides; +pub mod songs; +pub mod videos; +pub mod presentations; +pub mod images; diff --git a/src/rust/core/mod.rs b/src/rust/core/mod.rs deleted file mode 100644 index ac8605d..0000000 --- a/src/rust/core/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod service_items; -pub mod kinds; diff --git a/src/rust/core/presentations.rs b/src/rust/core/presentations.rs new file mode 100644 index 0000000..0327de7 --- /dev/null +++ b/src/rust/core/presentations.rs @@ -0,0 +1,38 @@ + +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub enum PresKind { + Html, + #[default] + Pdf, + Generic, +} + +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct Presentation { + title: String, + kind: PresKind, +} + +impl Presentation { + pub fn new() -> Self { + Self { + title: "".to_string(), + ..Default::default() + } + } + + pub fn get_kind(&self) -> &PresKind { + &self.kind + } +} + +#[cfg(test)] +mod test { + use crate::presentations::{PresKind, Presentation}; + + #[test] + pub fn test_presentation() { + let pres = Presentation::new(); + assert_eq!(pres.get_kind(), &PresKind::Pdf) + } +} diff --git a/src/rust/core/service_items.rs b/src/rust/core/service_items.rs index 6276dd4..2dfb856 100644 --- a/src/rust/core/service_items.rs +++ b/src/rust/core/service_items.rs @@ -1,11 +1,63 @@ +use crate::images::Image; +use crate::presentations::Presentation; +use crate::songs::Song; +use crate::videos::Video; + use super::kinds::ServiceItemKind; +#[derive(Debug, Default, PartialEq)] struct ServiceItem { id: i32, database_id: i32, kind: ServiceItemKind, } +#[derive(Debug, Default, PartialEq)] struct ServiceItemModel { items: Vec, } + +impl From for ServiceItem { + fn from(_song: Song) -> Self { + Self { + kind: ServiceItemKind::Song, + ..Default::default() + } + } +} + +impl From