From 364316ba4fe56ad6ef3c2a7db5ee4f0ad5ca3d1a Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Mon, 24 Jun 2024 23:55:23 +0100 Subject: [PATCH] borsh --- Cargo.toml | 3 +++ src/buint/mod.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 02cc1bf..adea055 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ default = [] nightly = [] serde = ["dep:serde", "serde-big-array"] numtraits = ["num-integer", "num-traits"] +borsh = ["dep:borsh"] [dependencies] num-integer = { version = "0.1", optional = true, default-features = false } @@ -34,6 +35,8 @@ quickcheck = { version = "1.0", optional = true, default-features = false } valuable = { version = "0.1", optional = true, features = ["derive"], default-features = false } # lit-parser = { path = "./lit-parser/", optional = true } +borsh = { version = "^1.5", optional = true, default-features = false, features = ["rc", "std", "unstable__schema"]} + [dev-dependencies] quickcheck = "1.0" paste = "1.0" diff --git a/src/buint/mod.rs b/src/buint/mod.rs index 3d00417..7981cc1 100644 --- a/src/buint/mod.rs +++ b/src/buint/mod.rs @@ -11,6 +11,12 @@ use ::{ serde_big_array::BigArray, }; +#[cfg(feature = "borsh")] +use ::{ + alloc::string::ToString, + borsh::{BorshDeserialize, BorshSchema, BorshSerialize}, +}; + use core::default::Default; use core::iter::{Iterator, Product, Sum}; @@ -29,6 +35,7 @@ macro_rules! mod_impl { #[derive(Clone, Copy, Hash, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] + #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize, BorshSchema))] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg_attr(feature = "valuable", derive(valuable::Valuable))] #[repr(transparent)]