GitXplorerGitXplorer
s

serde-scale-wrap

public
1 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
68b61e482563a819f02dca0c7fa21cbcd53cfe0c

Bump version

sstephaneyfx committed 4 years ago
Unverified
a75c30b14679b89b73ae9b4bc0bd6a620e329364

Update parity-scale-codec

sstephaneyfx committed 4 years ago
Unverified
02845c718b41350ef7a308725765706b43fa06aa

Bump version

sstephaneyfx committed 4 years ago
Unverified
8659a3977d70d7b444f168a6324fe9f62ce74766

Explain how to stop proc-macro features from affecting normal dependency features

sstephaneyfx committed 4 years ago
Unverified
d236ada21d528215f1f1e3cd224a93e10bc4aa59

Bump versions

sstephaneyfx committed 4 years ago
Unverified
1da3761522a89989b16b75f508c3ad64f868c618

Fix missing `EncodeLike` trait

SSushisource committed 4 years ago

README

The README file for this repository.

Overview

Wrapper for types implementing Serialize/Deserialize to implement Encode/Decode automatically.

Example

extern crate alloc;

use alloc::string::String;
use parity_scale_codec::{Decode, Encode};
use serde::{Deserialize, Serialize};
use serde_scale_wrap::Wrap;

#[derive(Debug, Deserialize, PartialEq, Serialize)]
struct Foo {
    x: i32,
    s: String,
}

let original = Foo { x: 3, s: "foo".into() };
let serialized = Wrap(&original).encode();
let Wrap(deserialized) = Wrap::<Foo>::decode(&mut &*serialized).unwrap();
assert_eq!(original, deserialized);

Conformance

âš  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.

Features

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:

[unstable]
features = ["host_dep"]

For example, this issue arises when depending on parity-scale-codec-derive.

Contribute

All contributions shall be licensed under the zlib license.

Related projects