diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index f82491b2..ba7e034c 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -66,7 +66,7 @@ jobs: - run: docker run -v "$(pwd)":/workdir --platform linux/x86_64 quay.io/pypa/manylinux2014_x86_64 /bin/bash /workdir/.github/workflows/manylinux_build_script.sh - uses: actions/upload-artifact@v3 with: - name: pyoxigraph_x86_64_linux + name: pyoxigraph_wheel_x86_64_linux path: target/wheels/*.whl wheel_mac: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8dfe3899..894a14de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,6 +51,9 @@ jobs: - run: cargo publish working-directory: ./oxrocksdb-sys continue-on-error: true + - run: cargo publish + working-directory: ./lib/oxsdatatypes + continue-on-error: true - run: cargo publish working-directory: ./lib/oxrdf continue-on-error: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 98dff40f..32c85291 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,6 +26,8 @@ jobs: with: submodules: true - run: rustup update && rustup component add clippy + - run: cargo clippy + working-directory: ./lib/oxsdatatypes - run: cargo clippy working-directory: ./lib/oxrdf - run: cargo clippy @@ -41,6 +43,8 @@ jobs: with: submodules: true - run: rustup override set 1.60.0 && rustup component add clippy + - run: cargo clippy -- -D warnings -D clippy::all + working-directory: ./lib/oxsdatatypes - run: cargo clippy -- -D warnings -D clippy::all working-directory: ./lib/oxrdf - run: cargo clippy -- -D warnings -D clippy::all diff --git a/Cargo.lock b/Cargo.lock index 967c3296..97300c25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -982,16 +982,15 @@ dependencies = [ "digest", "getrandom", "hex", - "js-sys", "lazy_static", "libc", "md-5", - "nom", "oxhttp", "oxilangtag", "oxiri", "oxrdf", "oxrocksdb-sys", + "oxsdatatypes", "rand", "regex", "rio_api", @@ -1069,6 +1068,7 @@ dependencies = [ "lasso", "oxilangtag", "oxiri", + "oxsdatatypes", "rand", ] @@ -1081,6 +1081,14 @@ dependencies = [ "libc", ] +[[package]] +name = "oxsdatatypes" +version = "0.1.0" +dependencies = [ + "js-sys", + "nom", +] + [[package]] name = "parking_lot" version = "0.12.1" diff --git a/Cargo.toml b/Cargo.toml index f7e74791..fa929eca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ members = [ "js", "lib", "lib/oxrdf", + "lib/oxsdatatypes", "lib/spargebra", "lib/sparesults", "lib/sparql-smith", diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 5a901148..e99d39f6 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -34,11 +34,11 @@ rio_api = "0.8" rio_turtle = "0.8" rio_xml = "0.8" hex = "0.4" -nom = "7" siphasher = "0.3" lazy_static = "1" sysinfo = "0.27" -oxrdf = { version = "0.1.1", path="oxrdf", features = ["rdf-star"] } +oxrdf = { version = "0.1.1", path="oxrdf", features = ["rdf-star", "oxsdatatypes"] } +oxsdatatypes = { version = "0.1.0", path="oxsdatatypes" } spargebra = { version = "0.2.3", path="spargebra", features = ["rdf-star"] } sparesults = { version = "0.1.3", path="sparesults", features = ["rdf-star"] } @@ -48,7 +48,6 @@ oxrocksdb-sys = { version = "0.3.10", path="../oxrocksdb-sys" } oxhttp = { version = "0.1", optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] -js-sys = "0.3" getrandom = {version="0.2", features=["js"]} [dev-dependencies] diff --git a/lib/oxrdf/Cargo.toml b/lib/oxrdf/Cargo.toml index d598764f..d8c876b9 100644 --- a/lib/oxrdf/Cargo.toml +++ b/lib/oxrdf/Cargo.toml @@ -21,6 +21,7 @@ rdf-star = [] rand = "0.8" oxilangtag = "0.1" oxiri = "0.2" +oxsdatatypes = { version = "0.1.0", path="../oxsdatatypes", optional = true } lasso = { version = "0.6", features = ["inline-more"] } [package.metadata.docs.rs] diff --git a/lib/oxrdf/src/literal.rs b/lib/oxrdf/src/literal.rs index 048d6323..bdca3eb0 100644 --- a/lib/oxrdf/src/literal.rs +++ b/lib/oxrdf/src/literal.rs @@ -3,6 +3,8 @@ use crate::vocab::rdf; use crate::vocab::xsd; use crate::NamedNodeRef; use oxilangtag::{LanguageTag, LanguageTagParseError}; +#[cfg(feature = "oxsdatatypes")] +use oxsdatatypes::*; use std::borrow::Cow; use std::fmt; use std::fmt::Write; @@ -293,6 +295,134 @@ impl From for Literal { } } +#[cfg(feature = "oxsdatatypes")] +impl From for Literal { + #[inline] + fn from(value: Boolean) -> Self { + Self::new_typed_literal(value.to_string(), xsd::BOOLEAN) + } +} + +#[cfg(feature = "oxsdatatypes")] +impl From for Literal { + #[inline] + fn from(value: Float) -> Self { + Self::new_typed_literal(value.to_string(), xsd::FLOAT) + } +} + +#[cfg(feature = "oxsdatatypes")] +impl From for Literal { + #[inline] + fn from(value: Double) -> Self { + Self::new_typed_literal(value.to_string(), xsd::DOUBLE) + } +} + +#[cfg(feature = "oxsdatatypes")] +impl From for Literal { + #[inline] + fn from(value: Integer) -> Self { + Self::new_typed_literal(value.to_string(), xsd::INTEGER) + } +} + +#[cfg(feature = "oxsdatatypes")] +impl From for Literal { + #[inline] + fn from(value: Decimal) -> Self { + Self::new_typed_literal(value.to_string(), xsd::DECIMAL) + } +} + +#[cfg(feature = "oxsdatatypes")] +impl From for Literal { + #[inline] + fn from(value: DateTime) -> Self { + Self::new_typed_literal(value.to_string(), xsd::DATE_TIME) + } +} + +#[cfg(feature = "oxsdatatypes")] +impl From