Overview

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.

Example

```rust extern crate alloc;

use alloc::string::String; use parityscalecodec::{Decode, Encode}; use serde::{Deserialize, Serialize}; use serdescalewrap::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::::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.

Contribute

All contributions shall be licensed under the zlib license.

Related projects