Wrapper for types implementing Serialize
/Deserialize
to implement
Encode
/Decode
automatically.
âš The Error
type exposed by this crate is meant to disappear if/when parity-scale-codec
's
Error
implements Display
unconditionally.
```rust extern crate alloc;
use alloc::string::String; use parityscalecodec::{Decode, Encode}; use serde::{Deserialize, Serialize}; use serdescalewrap::Wrap;
struct Foo { x: i32, s: String, }
let original = Foo { x: 3, s: "foo".into() };
let serialized = Wrap(&original).encode();
let Wrap(deserialized) = Wrap::
âš Option<bool>
is serialized as a single byte according to the SCALE encoding, which differs
from the result of Encode::encode
-- Encode
expects OptionBool
to be used instead.
no_std
is supported by disabling default features.
std
: Support for std
. It is enabled by default.🔖 Features enabled in build dependencies and proc-macros are also enabled for normal
dependencies, which may cause serde
to have its std
feature on when it is not desired.
Nightly cargo prevents this from happening with
-Z features=host_dep
or the following in .cargo/config
:
toml
[unstable]
features = ["host_dep"]
For example, this issue arises when depending on parity-scale-codec-derive
.
All contributions shall be licensed under the zlib license.
serde