diff --git a/Cargo.lock b/Cargo.lock index cd2fa00..62e2396 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,94 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "proc-macro2" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "907a61bd0f64c2f29cd1cf1dc34d05176426a3f504a78010f08416ddb7b13708" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" + +[[package]] +name = "serde" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "stremio-official-addons" version = "2.0.11" +dependencies = [ + "once_cell", + "serde_json", +] + +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" diff --git a/official-addons-v2/Cargo.toml b/official-addons-v2/Cargo.toml index ac1a608..506b515 100644 --- a/official-addons-v2/Cargo.toml +++ b/official-addons-v2/Cargo.toml @@ -14,7 +14,14 @@ include = [ "/README.md" ] -[lib] -doctest = false +[features] + +default = ["json", "std"] +std = ["serde_json/std", "once_cell/std"] + +json = ["serde_json", "once_cell"] [dependencies] + +serde_json = { version = "1", optional = true, default-features = false } +once_cell = { version = "1", optional = true, default-features = false } diff --git a/official-addons-v2/src/lib.rs b/official-addons-v2/src/lib.rs index 3b09baf..8a5afe5 100644 --- a/official-addons-v2/src/lib.rs +++ b/official-addons-v2/src/lib.rs @@ -1 +1,27 @@ +#[cfg(feature = "json")] +pub use serde_json::Value; +#[cfg(feature = "json")] +use once_cell::sync::Lazy; + +/// The JSON file's content pub const ADDONS: &'static [u8] = include_bytes!("../addons.json"); + +#[cfg(feature = "json")] +/// The JSON file content but after json validation +pub const ADDONS_JSON: Lazy = + Lazy::new(|| serde_json::from_slice(ADDONS).expect("Valid JSON")); + +// todo: parsed addons manifests + +#[cfg(test)] +mod test { + use super::*; + + #[test] + #[cfg(feature = "json")] + fn addons_file_is_valid_json() { + let addons_json = ADDONS_JSON.clone(); + + assert_ne!(addons_json, serde_json::Value::Null); + } +} \ No newline at end of file