Compare commits
1 commit
1.61803398
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
e333ea5263 |
4 changed files with 21 additions and 11 deletions
21
Cargo.toml
21
Cargo.toml
|
@ -1,8 +1,8 @@
|
|||
[package]
|
||||
name = "julid-rs"
|
||||
# 1.61803398874989484
|
||||
#---------------^
|
||||
version = "1.6.180339887498"
|
||||
#----------------^
|
||||
version = "1.6.1803398874989"
|
||||
authors = ["Joe Ardent <code@ardent.nebcorp.com>"]
|
||||
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"]
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.6180339887498
|
||||
1.61803398874989
|
||||
|
|
|
@ -116,6 +116,7 @@ impl Julid {
|
|||
(self.0 & bitmask!(UNIQUE_BITS)) as u64
|
||||
}
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
/// Returns the timestamp as a `chrono::DateTime<chrono::Utc>` (feature
|
||||
/// `chrono` (default))
|
||||
pub fn created_at(&self) -> chrono::DateTime<chrono::Utc> {
|
||||
|
|
|
@ -34,6 +34,7 @@ impl<'de> Visitor<'de> for JulidVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
|
||||
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<S>(value: &Julid, serializer: S) -> Result<S::Ok, S::Error>
|
||||
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<Julid, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
|
|
Loading…
Reference in a new issue