| Crates.io | serde-scale |
| lib.rs | serde-scale |
| version | 0.2.2 |
| created_at | 2020-10-07 07:00:27.647116+00 |
| updated_at | 2020-10-15 20:58:10.523005+00 |
| description | Serde serializer and deserializer for the SCALE encoding |
| homepage | https://github.com/stephaneyfx/serde-scale |
| repository | https://github.com/stephaneyfx/serde-scale.git |
| max_upload_size | |
| id | 296856 |
| size | 52,657 |
Serializer and deserializer for the SCALE encoding
based on serde.
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, PartialEq, Serialize)]
struct Point {
x: i8,
y: i8,
}
let point = Point { x: 3, y: 4 };
let deserialized = serde_scale::from_slice(&serde_scale::to_vec(&point).unwrap()).unwrap();
assert_eq!(point, deserialized);
Option<bool> is serialized as a single byte according to the SCALE encoding.
no_std is supported by disabling default features.
std: Support for std. It is enabled by default.alloc: Support for the alloc crate.🔖 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.
Most tests live in the serde-scale-tests crate (part of the workspace) in order to avoid
dependencies enabling serde features.
cargo test --workspace
All contributions shall be licensed under the zlib license.
parity-scale-codec: Reference Rust implementation