near / borsh

Binary Object Representation Serializer for Hashing
https://borsh.io/
487 stars 41 forks source link

Add no_std support #108

Closed snjax closed 3 years ago

snjax commented 3 years ago

Add no_std support for borsh.

Polyfill is implemented at borsh::lib::* and borsh::error (same as in serde).

For no_std borsh HashMap is imported from hashbrown and Error and Write imported from bare_io.

MaksymZavershynskyi commented 3 years ago

@ailisp , @willemneal could you take a look?

codecov-io commented 3 years ago

Codecov Report

Merging #108 (3768ab8) into master (4c2f1a0) will decrease coverage by 0.21%. The diff coverage is 89.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #108      +/-   ##
==========================================
- Coverage   93.43%   93.21%   -0.22%     
==========================================
  Files          21       21              
  Lines        1219     1224       +5     
==========================================
+ Hits         1139     1141       +2     
- Misses         80       83       +3     
Impacted Files Coverage Δ
borsh-rs/borsh/src/schema.rs 100.00% <ø> (ø)
borsh-rs/borsh/tests/test_schema_enums.rs 86.55% <ø> (ø)
borsh-rs/borsh/tests/test_schema_nested.rs 100.00% <ø> (ø)
borsh-rs/borsh/tests/test_schema_structs.rs 100.00% <ø> (ø)
borsh-rs/borsh/tests/test_simple_structs.rs 92.63% <ø> (ø)
borsh-rs/borsh/src/schema_helpers.rs 84.61% <50.00%> (ø)
borsh-rs/borsh/src/de/mod.rs 90.96% <81.03%> (-0.29%) :arrow_down:
borsh-rs/borsh-derive-internal/src/struct_ser.rs 83.67% <100.00%> (ø)
...rs/borsh-schema-derive-internal/src/enum_schema.rs 95.28% <100.00%> (ø)
...rsh-rs/borsh-schema-derive-internal/src/helpers.rs 92.00% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4c2f1a0...3768ab8. Read the comment docs.

snjax commented 3 years ago

@frol We updated the PR

snjax commented 3 years ago

Re: "Replace bare-io with semi-custom Error and Write". If the only reason for this is the support for the String error messages, I vote for dropping format! and using a static string message (&'static str). I don't want us to vendor the fork of std library.

bare-io is incomplete: there are no hashmaps and hashsets. That's why anyway we should use std polyfill (like serde).

frol commented 3 years ago

Oh, well, cargo test -Zpackage-features --workspace --no-default-features works fine if you edit benchmarks/Cargo.toml to disable the default features:

borsh = { path = "../borsh", default-features = false }
snjax commented 3 years ago

Please, resolve the merge conflict on .travis.yml (I don't have permissions to push to your PR branch to fix it myself)

@frol Done.

snjax commented 3 years ago

@frol done

frol commented 3 years ago

Thank you!