diff --git a/README.md b/README.md index 9efaab231e39c45ab4c49c293612bde90beae24d..f3b40006ee5e391462dd68608b9908e28ff8c863 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Simply use cmake to build in another folder of the source folder: ```bash -cmake -Bbuild -DCMAKE_CXX_COMPILER=clang++ -CDMAKE_INSTALL_PREFIX=$HOME/.local -GNinja +cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -CDMAKE_INSTALL_PREFIX=$HOME/.local -GNinja ninja -Cbuild ninja -Cbuild install ``` diff --git a/src/Rust/Cargo.lock b/src/Rust/Cargo.lock index 55a9cd7a64a9379ee95029ebd0118e7a92c0c751..47469ac74a485126a89bcfc0a6c3438c6a2dcdbe 100644 --- a/src/Rust/Cargo.lock +++ b/src/Rust/Cargo.lock @@ -458,6 +458,7 @@ version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ + "indexmap 2.0.2", "itoa", "ryu", "serde", @@ -686,6 +687,8 @@ version = "0.5.0" dependencies = [ "cbindgen", "log", + "serde", + "serde_json", "vvs_ass", ] diff --git a/src/Rust/Cargo.toml b/src/Rust/Cargo.toml index 7cfb804b33b601230a3e7fb2a18848960ffbe9de..3408350a8e4d1f7a15317cbf5ab3e6cdc5821b4e 100644 --- a/src/Rust/Cargo.toml +++ b/src/Rust/Cargo.toml @@ -25,14 +25,18 @@ nom = { version = "7", default-features = false, features = ["std"] } nom_locate = { version = "4", default-features = false, features = ["std"] } # SerDe -toml = { version = "0.8", default-features = false, features = [ - "parse", - "display", +serde_json = { version = "1", default-features = false, features = [ + "std", + "preserve_order", ] } serde = { version = "1", default-features = false, features = [ "std", "derive", ] } +toml = { version = "0.8", default-features = false, features = [ + "parse", + "display", +] } [profile.release] strip = true diff --git a/src/Rust/vvs_lib/Cargo.toml b/src/Rust/vvs_lib/Cargo.toml index 77b27a26befd71c76263c68dc3dcc623bf3b5c42..51056514553bd345159574f5de1118718cc9f4e7 100644 --- a/src/Rust/vvs_lib/Cargo.toml +++ b/src/Rust/vvs_lib/Cargo.toml @@ -12,6 +12,8 @@ crate-type = ["staticlib"] [dependencies] log.workspace = true +serde.workspace = true +serde_json.workspace = true vvs_ass = { path = "../vvs_ass" } diff --git a/src/Rust/vvs_lib/src/lib.rs b/src/Rust/vvs_lib/src/lib.rs index 55ca5a319b76da0fd1d559629bf89afc726ece35..9dbbf954af4c0d82d78a9b1fda9279b7f87db1cc 100644 --- a/src/Rust/vvs_lib/src/lib.rs +++ b/src/Rust/vvs_lib/src/lib.rs @@ -7,6 +7,7 @@ use std::ffi::c_char; pub mod ass; +pub mod vivy; /// Represents a string slice, the user may not modify this slice, never! Note that the string is /// not null terminated and may contains null bytes in it, use the len attribute to get the length diff --git a/src/Rust/vvs_lib/src/vivy.rs b/src/Rust/vvs_lib/src/vivy.rs new file mode 100644 index 0000000000000000000000000000000000000000..6866461b58f6df7467d35795797f2bceeaaa227d --- /dev/null +++ b/src/Rust/vvs_lib/src/vivy.rs @@ -0,0 +1,35 @@ +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; + +#[derive(Debug, PartialEq, Eq)] +pub enum VivyDocumentCapabilities { + AudioAble = (1 << 1), + VideoAble = (1 << 2), + AssAble = (1 << 3), +} + +#[derive(Debug, Deserialize, Serialize)] +#[serde(rename_all = "PascalCase")] +pub struct VivyDocument { + #[serde(default = "u64::default")] + pub capabilities: u64, + pub name: String, +} + +#[derive(Debug, Deserialize, Serialize)] +#[serde(rename_all = "PascalCase")] +#[serde(tag = "DocumentVersion", content = "SubDocuments")] +pub enum VivySubDocument { + Alpha { + sub_ass: Option<PathBuf>, + sub_audio: Option<PathBuf>, + sub_video: Option<PathBuf>, + }, +} + +#[test] +fn test_deserialize() { + if let Err(err) = serde_json::from_str::<VivyDocument>(include_str!("../test/sample.vivy")) { + panic!("{err}") + } +} diff --git a/src/Rust/vvs_lib/test/sample.vivy b/src/Rust/vvs_lib/test/sample.vivy new file mode 100644 index 0000000000000000000000000000000000000000..16bd90a6d3d88e195f8cc8d76fd6672145dde2fb --- /dev/null +++ b/src/Rust/vvs_lib/test/sample.vivy @@ -0,0 +1,10 @@ +{ + "Name": "test", + "Capabilities": 12, + "DocumentVersion": "alpha", + "SubDocuments": { + "SubAss": "vivy/src/Rust/vvs_ass/utils/empty.ass", + "SubVideo": "data/4036f7f60c08bf70741f118eca95dff61facfb66199351e9e40900071cd5322d.mkv" + } +} +