diff --git a/Cargo.toml b/Cargo.toml index 3d43103..b4235d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "julid-rs" # 1.61803398874989484 -#---------------^ -version = "1.6.180339887498" +#----------------^ +version = "1.6.1803398874989" authors = ["Joe Ardent "] edition = "2024" keywords = ["ulid", "sqlite", "julid", "uuid", "guid"] @@ -16,12 +16,15 @@ repository = "https://git.kittencollective.com/nebkor/julid-rs" all-features = true [features] -default = ["serde", "sqlx"] # just the regular crate +default = ["serde", "sqlx", "cli", "std", "chrono"] # no uuid or sqlite plugin +chrono = ["dep:chrono"] +cli = ["dep:clap", "chrono"] serde = ["dep:serde"] sqlx = ["dep:sqlx"] +std = ["chrono/std", "serde?/alloc"] uuid = ["dep:uuid"] -# WARNING! don't enable this feature in your project's Cargo.toml if using julid-rs as a dependency; +# WARNING! don't enable this feature in your project's Cargo.toml if using julid-rs as a Rust dependency; # see https://gitlab.com/nebkor/julid/-/issues/1 plugin = ["dep:sqlite-loadable"] # builds libjulid.* for loading into sqlite @@ -32,12 +35,11 @@ crate-type = ["cdylib", "rlib"] [dependencies] rand = "0.8" -# for the CLI -clap = { version = "4", default-features = false, features = ["help", "usage", "std", "derive"] } -chrono = { version = "0.4", default-features = false, features = ["std", "time"] } - # all other deps are optional -serde = { version = "1.0", features = ["derive"], optional = true } +chrono = { version = "0.4", default-features = false, features = ["std"], optional = true } +# for the CLI +clap = { version = "4", default-features = false, features = ["help", "usage", "std", "derive"], optional = true } +serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } sqlx = { version = "0.8", features = ["sqlite"], default-features = false, optional = true } sqlite-loadable = { version = "0.0.5", optional = true } uuid = { version = "1.17", default-features = false, optional = true } @@ -54,3 +56,4 @@ harness = false [[bin]] name = "julid-gen" path = "src/bin/gen.rs" +required-features = ["chrono", "cli"] diff --git a/VERSION b/VERSION index 20fc392..6afea78 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6180339887498 +1.61803398874989 diff --git a/src/julid.rs b/src/julid.rs index 011a9bb..9396ceb 100644 --- a/src/julid.rs +++ b/src/julid.rs @@ -116,6 +116,7 @@ impl Julid { (self.0 & bitmask!(UNIQUE_BITS)) as u64 } + #[cfg(feature = "chrono")] /// Returns the timestamp as a `chrono::DateTime` (feature /// `chrono` (default)) pub fn created_at(&self) -> chrono::DateTime { diff --git a/src/serde.rs b/src/serde.rs index 3eb1dd7..d37bad5 100644 --- a/src/serde.rs +++ b/src/serde.rs @@ -34,6 +34,7 @@ impl<'de> Visitor<'de> for JulidVisitor { } } + #[cfg(feature = "std")] fn visit_byte_buf(self, v: Vec) -> Result where E: serde::de::Error, @@ -97,10 +98,13 @@ impl<'de> Deserialize<'de> for Julid { /// } /// ``` pub mod julid_as_str { - use serde::{Deserialize, Deserializer, Serialize, Serializer}; + #[cfg(feature = "std")] + use serde::{Deserialize, Deserializer}; + use serde::{Serialize, Serializer}; use crate::Julid; + /// Serialize a Julid into a String pub fn serialize(value: &Julid, serializer: S) -> Result where S: Serializer, @@ -109,6 +113,8 @@ pub mod julid_as_str { text.serialize(serializer) } + #[cfg(feature = "std")] + /// Deserialize a String into a Julid (feature `std` only) pub fn deserialize<'de, D>(deserializer: D) -> Result where D: Deserializer<'de>,