lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

commit d268267afa1ed5e35ec5d1153911f831c5b1f47a
parent 9fd649fe7606fb62b71e5e7dbbe677fa441613e2
Author: triesap <tyson@radroots.org>
Date:   Sat, 18 Jul 2026 08:11:00 +0000

event: scope trade helpers to Serde builds

- Gate trade canonicalization collections and JSON helpers behind the Serde feature.
- Keep no-default-features builds free of unused imports and dead-code warnings.
- Preserve the existing default-feature protocol and canonicalization behavior.
- Verify formatting and strict Clippy across default and minimal feature sets.

Diffstat:
Mcrates/event/src/trade.rs | 16+++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/crates/event/src/trade.rs b/crates/event/src/trade.rs @@ -1,15 +1,13 @@ #![forbid(unsafe_code)] +#[cfg(all(not(feature = "std"), feature = "serde"))] +use alloc::{collections::BTreeMap, format, string::ToString}; #[cfg(not(feature = "std"))] -use alloc::{ - collections::BTreeMap, - format, - string::{String, ToString}, - vec::Vec, -}; +use alloc::{string::String, vec::Vec}; +#[cfg(all(feature = "std", feature = "serde"))] +use std::collections::BTreeMap; #[cfg(feature = "std")] use std::{ - collections::BTreeMap, string::{String, ToString}, vec::Vec, }; @@ -30,7 +28,9 @@ use serde::{ Deserialize, Deserializer, Serialize, de::{Error as _, MapAccess, SeqAccess, Visitor}, }; +#[cfg(feature = "serde")] use serde_json::{Map, Number, Value}; +#[cfg(feature = "serde")] use sha2::{Digest, Sha256}; pub const RADROOTS_TRADE_SCHEMA_VERSION: u16 = 1; @@ -795,6 +795,7 @@ fn write_canonical_jcs( Ok(()) } +#[cfg(feature = "serde")] fn canonical_number(number: &Number) -> Result<String, RadrootsTradeProtocolError> { if number.is_i64() || number.is_u64() { Ok(number.to_string()) @@ -803,6 +804,7 @@ fn canonical_number(number: &Number) -> Result<String, RadrootsTradeProtocolErro } } +#[cfg(feature = "serde")] fn digest_prefixed(domain: &[u8], bytes: &[u8]) -> String { let mut hasher = Sha256::new(); hasher.update(domain);