From 8f35223b11c99d20f421b26ca14f3e11133d7823 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Fri, 6 Jun 2025 13:07:37 +0000 Subject: [PATCH] Add AbiExample for dashmap and boxcar --- Cargo.lock | 9 +++++++++ Cargo.toml | 2 ++ frozen-abi/Cargo.toml | 2 ++ frozen-abi/src/abi_example.rs | 25 +++++++++++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index acf2d6f33..bbc2a2ce0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -419,6 +419,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "boxcar" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66bb12751a83493ef4b8da1120451a262554e216a247f14b48cb5e8fe7ed8bdf" + [[package]] name = "brotli" version = "7.0.0" @@ -843,6 +849,7 @@ dependencies = [ "lock_api", "once_cell", "parking_lot_core", + "serde", ] [[package]] @@ -2956,9 +2963,11 @@ name = "solana-frozen-abi" version = "2.2.2" dependencies = [ "bitflags 2.8.0", + "boxcar", "bs58", "bv", "bytes", + "dashmap", "im", "log", "memmap2", diff --git a/Cargo.toml b/Cargo.toml index 807afed85..3e1f6a3c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -140,6 +140,7 @@ bitflags = { version = "2.8.0" } blake3 = "1.5.5" borsh = { version = "1.5.5", features = ["derive", "unstable__schema"] } borsh0-10 = { package = "borsh", version = "0.10.3" } +boxcar = "0.2.12" bs58 = { version = "0.5.1", default-features = false } bv = "0.11.1" bytemuck = "1.21.0" @@ -152,6 +153,7 @@ console_error_panic_hook = "0.1.7" console_log = "0.2.2" criterion = "0.5.1" curve25519-dalek = { version = "4.1.3", features = ["digest", "rand_core"] } +dashmap = { version = "5.5.3", features = ["serde"] } derivation-path = { version = "0.2.0", default-features = false } digest = "0.10.7" ed25519-dalek = "=1.0.1" diff --git a/frozen-abi/Cargo.toml b/frozen-abi/Cargo.toml index 72efbc459..f17aedfe4 100644 --- a/frozen-abi/Cargo.toml +++ b/frozen-abi/Cargo.toml @@ -16,9 +16,11 @@ default = [] frozen-abi = [] [dependencies] +boxcar = { workspace = true } bs58 = { workspace = true, features = ["alloc"] } bv = { workspace = true, features = ["serde"] } bytes = { workspace = true } +dashmap = { workspace = true } log = { workspace = true, features = ["std"] } serde = { workspace = true, features = ["rc"] } serde_derive = { workspace = true } diff --git a/frozen-abi/src/abi_example.rs b/frozen-abi/src/abi_example.rs index c844b3a11..d3d272692 100644 --- a/frozen-abi/src/abi_example.rs +++ b/frozen-abi/src/abi_example.rs @@ -619,3 +619,28 @@ impl AbiExample for std::sync::OnceLock { Self::from(T::example()) } } + +#[cfg(not(target_os = "solana"))] +impl< + T: std::cmp::Eq + std::hash::Hash + AbiExample, + S: AbiExample, + H: std::hash::BuildHasher + Default + std::clone::Clone, + > AbiExample for dashmap::DashMap +{ + fn example() -> Self { + info!("AbiExample for (DashMap): {}", type_name::()); + let map = dashmap::DashMap::default(); + map.insert(T::example(), S::example()); + map + } +} + +#[cfg(not(target_os = "solana"))] +impl AbiExample for boxcar::Vec { + fn example() -> Self { + info!("AbiExample for (boxcar::Vec): {}", type_name::()); + let vec = boxcar::Vec::new(); + vec.push(T::example()); + vec + } +}