Skip to content

Commit

Permalink
Switch from derivative to educe
Browse files Browse the repository at this point in the history
Zero improvement for users, it's just that `educe` hasn't been
abandoned yet.
  • Loading branch information
jedisct1 committed Nov 12, 2024
1 parent 9114000 commit 4765315
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 68 deletions.
90 changes: 50 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ clap = { version = "3.2.25", default-features = false, features = [
] }
coarsetime = "0.1.34"
daemonize-simple = "0.1.5"
derivative = "2.2.0"
dnsstamps = "0.1.9"
educe = { version = "0.6.0", features = ["full"] }
env_logger = { version = "0.11.5", default-features = false, features = [
"humantime",
] }
Expand All @@ -35,24 +35,24 @@ ipext = "0.1.0"
libsodium-sys-stable = "1.22.1"
log = { version = "0.4.22", features = ["std", "release_max_level_debug"] }
mimalloc = { version = "0.1.43", default-features = false }
socket2 = "0.5.7"
parking_lot = "0.12.3"
rand = "0.8.5"
rlimit = "0.10.2"
rustc-hash = "2.0.0"
serde = "1.0.214"
serde_derive = "1.0.214"
serde = "1.0.215"
serde_derive = "1.0.215"
serde-big-array = "0.5.1"
sieve-cache = "0.2.1"
siphasher = "1.0.1"
slabigator = "0.9.2"
socket2 = "0.5.7"
tokio = { version = "1.41.1", features = [
"net",
"io-std",
"io-util",
"fs",
"time",
"rt-multi-thread"
"rt-multi-thread",
] }
toml = "0.8.19"

Expand Down
6 changes: 3 additions & 3 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ impl CachedResponse {
}
}

#[derive(Clone, Derivative)]
#[derivative(Debug)]
#[derive(Clone, Educe)]
#[educe(Debug)]
pub struct Cache {
#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
cache: Arc<Mutex<SieveCache<u128, CachedResponse>>>,
pub ttl_min: u32,
pub ttl_max: u32,
Expand Down
19 changes: 9 additions & 10 deletions src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ use siphasher::sip::SipHasher13;

use crate::errors::*;

#[derive(Derivative)]
#[derivative(Default)]
#[derive(Educe)]
#[educe(Default)]
pub struct Signature(
#[derivative(Default(value = "[0u8; crypto_sign_BYTES as usize]"))]
[u8; crypto_sign_BYTES as usize],
#[educe(Default = [0u8; crypto_sign_BYTES as usize])] [u8; crypto_sign_BYTES as usize],
);

impl Signature {
Expand All @@ -25,11 +24,11 @@ impl Signature {
}
}

#[derive(Serialize, Deserialize, Derivative, Clone)]
#[derivative(Default)]
#[derive(Serialize, Deserialize, Educe, Clone)]
#[educe(Default)]
pub struct SignSK(
#[serde(with = "BigArray")]
#[derivative(Default(value = "[0u8; crypto_sign_SECRETKEYBYTES as usize]"))]
#[educe(Default = [0u8; crypto_sign_SECRETKEYBYTES as usize])]
[u8; crypto_sign_SECRETKEYBYTES as usize],
);

Expand Down Expand Up @@ -75,10 +74,10 @@ impl SignPK {
}
}

#[derive(Derivative, Serialize, Deserialize, Clone)]
#[derivative(Debug, Default)]
#[derive(Educe, Serialize, Deserialize, Clone)]
#[educe(Debug, Default)]
pub struct SignKeyPair {
#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
pub sk: SignSK,
pub pk: SignPK,
}
Expand Down
12 changes: 6 additions & 6 deletions src/dnscrypt_certs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ impl DNSCryptCertInner {
}
}

#[derive(Derivative, Serialize, Deserialize)]
#[derivative(Debug, Default, Clone)]
#[derive(Educe, Serialize, Deserialize)]
#[educe(Debug, Default, Clone)]
#[repr(C, packed)]
pub struct DNSCryptCert {
cert_magic: [u8; 4],
es_version: [u8; 2],
minor_version: [u8; 2],
#[derivative(Debug = "ignore", Default(value = "[0u8; 64]"))]
#[educe(Debug(ignore), Default = [0u8; 64])]
#[serde(with = "BigArray")]
signature: [u8; 64],
inner: DNSCryptCertInner,
Expand Down Expand Up @@ -101,13 +101,13 @@ impl DNSCryptCert {
}
}

#[derive(Serialize, Deserialize, Clone, Derivative)]
#[derivative(Debug)]
#[derive(Serialize, Deserialize, Clone, Educe)]
#[educe(Debug)]
pub struct DNSCryptEncryptionParams {
dnscrypt_cert: DNSCryptCert,
resolver_kp: CryptKeyPair,
#[serde(skip)]
#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
pub key_cache: Option<Arc<Mutex<SieveCache<[u8; DNSCRYPT_QUERY_PK_SIZE], SharedKey>>>>,
}

Expand Down
6 changes: 3 additions & 3 deletions src/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use crate::dnscrypt_certs::*;
#[cfg(feature = "metrics")]
use crate::varz::*;

#[derive(Clone, Derivative)]
#[derivative(Debug)]
#[derive(Clone, Educe)]
#[educe(Debug)]
pub struct Globals {
pub runtime_handle: Handle,
pub state_file: PathBuf,
Expand Down Expand Up @@ -53,6 +53,6 @@ pub struct Globals {
pub client_ttl_holdon: u32,
pub my_ip: Option<Vec<u8>>,
#[cfg(feature = "metrics")]
#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
pub varz: Varz,
}
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;

#[macro_use]
extern crate derivative;
extern crate educe;
#[macro_use]
extern crate log;
#[macro_use]
Expand Down

0 comments on commit 4765315

Please sign in to comment.