-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parity scale codec #547
base: master
Are you sure you want to change the base?
Changes from 6 commits
27c62bc
394d8f8
204d127
610096f
b896337
25f0849
031d203
deeb242
091d715
67efda9
29d3e2e
a6d5caf
951512d
03ce442
f18e57c
aacdefd
1686b69
ede308d
6cfccf3
1c80137
c3802db
c4d4d3e
829355a
f02f5ac
d323dd4
10ee2ee
80e9f08
aa2c3d3
bacc60b
999bb02
179039a
d72e787
4666555
65ec77a
e7511dc
62cf912
d778de7
bbcc77a
e1b54cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -33,11 +33,14 @@ diesel1 = { default-features = false, optional = true, package = "diesel", versi | |||||
diesel2 = { default-features = false, optional = true, package = "diesel", version = "2.0" } | ||||||
ndarray = { default-features = false, optional = true, version = "0.15.6" } | ||||||
num-traits = { default-features = false, features = ["i128"], version = "0.2" } | ||||||
parity-scale-codec = { optional = true, version = "3.1.5", features = ["max-encoded-len"], default-features = false} | ||||||
parity-scale-codec-derive = { optional = true, version = "3.1.3",default-features = false} | ||||||
postgres = { default-features = false, optional = true, version = "0.19" } | ||||||
proptest = { default-features = false, optional = true, features = ["std"], version = "1.0" } | ||||||
rand = { default-features = false, optional = true, version = "0.8" } | ||||||
rkyv = { default-features = false, features = ["size_32", "std"], optional = true, version = "0.7" } | ||||||
rocket = { default-features = false, optional = true, version = "0.5.0-rc.1" } | ||||||
scale-info = {optional=true, version = "2.1.2", features = ["derive"], default-features = false} | ||||||
serde = { default-features = false, optional = true, version = "1.0" } | ||||||
serde_json = { default-features = false, optional = true, version = "1.0" } | ||||||
tokio-postgres = { default-features = false, optional = true, version = "0.7" } | ||||||
|
@@ -78,6 +81,7 @@ rkyv = ["dep:rkyv"] | |||||
rkyv-safe = ["dep:bytecheck", "rkyv/validation"] | ||||||
rocket-traits = ["dep:rocket"] | ||||||
rust-fuzz = ["dep:arbitrary"] | ||||||
scale-codec = ["parity-scale-codec-derive","parity-scale-codec","scale-info"] | ||||||
serde = ["dep:serde"] | ||||||
serde-arbitrary-precision = ["serde-with-arbitrary-precision"] | ||||||
serde-bincode = ["serde-str"] # Backwards compatability | ||||||
|
@@ -86,7 +90,7 @@ serde-str = ["serde-with-str"] | |||||
serde-with-arbitrary-precision = ["serde", "serde_json/arbitrary_precision", "serde_json/std"] | ||||||
serde-with-float = ["serde"] | ||||||
serde-with-str = ["serde"] | ||||||
std = ["arrayvec/std", "borsh?/std", "bytecheck?/std", "byteorder?/std", "bytes?/std", "rand?/std", "rkyv?/std", "serde?/std", "serde_json?/std"] | ||||||
std = ["arrayvec/std", "borsh?/std", "bytecheck?/std", "byteorder?/std", "bytes?/std", "rand?/std", "rkyv?/std", "serde?/std", "serde_json?/std", "parity-scale-codec?/std","scale-info?/std"] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a simple reordering of inclusions:
Suggested change
|
||||||
tokio-pg = ["db-tokio-postgres"] # Backwards compatability | ||||||
|
||||||
[workspace] | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -27,6 +27,10 @@ use num_traits::float::FloatCore; | |||||||||||
use num_traits::{FromPrimitive, Num, One, Signed, ToPrimitive, Zero}; | ||||||||||||
#[cfg(feature = "rkyv")] | ||||||||||||
use rkyv::{Archive, Deserialize, Serialize}; | ||||||||||||
#[cfg(feature = "scale-codec")] | ||||||||||||
use parity_scale_codec_derive::{Decode,Encode, MaxEncodedLen}; | ||||||||||||
#[cfg(feature = "scale-codec")] | ||||||||||||
use scale_info::TypeInfo; | ||||||||||||
|
||||||||||||
/// The smallest value that can be represented by this decimal type. | ||||||||||||
const MIN: Decimal = Decimal { | ||||||||||||
|
@@ -120,6 +124,11 @@ pub struct UnpackedDecimal { | |||||||||||
archive(compare(PartialEq)), | ||||||||||||
archive_attr(derive(Clone, Copy, Debug)) | ||||||||||||
)] | ||||||||||||
#[cfg_attr(feature = "rkyv-safe", archive_attr(derive(CheckBytes)))] | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is duplicated below
Suggested change
|
||||||||||||
#[cfg_attr( | ||||||||||||
feature = "scale-codec", | ||||||||||||
derive(Decode, Encode, TypeInfo, MaxEncodedLen), | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Side note (no change required): these |
||||||||||||
)] | ||||||||||||
Comment on lines
+128
to
+131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will fix the code formatting error in the build:
Suggested change
|
||||||||||||
#[cfg_attr(feature = "rkyv-safe", archive_attr(derive(bytecheck::CheckBytes)))] | ||||||||||||
pub struct Decimal { | ||||||||||||
// Bits 0-15: unused | ||||||||||||
|
@@ -548,7 +557,7 @@ impl Decimal { | |||||||||||
} | ||||||||||||
|
||||||||||||
#[must_use] | ||||||||||||
pub(crate) const fn from_parts_raw(lo: u32, mid: u32, hi: u32, flags: u32) -> Decimal { | ||||||||||||
pub const fn from_parts_raw(lo: u32, mid: u32, hi: u32, flags: u32) -> Decimal { | ||||||||||||
Gauthamastro marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverting this line:
Suggested change
|
||||||||||||
if lo == 0 && mid == 0 && hi == 0 { | ||||||||||||
Decimal { | ||||||||||||
lo, | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're starting to use the updated format for feature dependencies: