1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (C) 2020 Stephane Raux. Distributed under the zlib license.
//! # Overview
//! - [📦 crates.io](https://crates.io/crates/serde-scale)
//! - [📖 Documentation](https://docs.rs/serde-scale)
//! - [âš– zlib license](https://opensource.org/licenses/Zlib)
//!
//! Serializer and deserializer for the [SCALE encoding](https://substrate.dev/docs/en/knowledgebase/advanced/codec)
//! based on [`serde`](https://docs.rs/serde).
//!
//! # Example
//! ```rust
//! # #[cfg(feature = "alloc")] {
//! 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);
//! # }
//! ```
//!
//! # Conformance
//! `Option<bool>` is serialized as a single byte according to the SCALE encoding.
//!
//! # Features
//! `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`](https://github.com/rust-lang/cargo/issues/7915#issuecomment-683294870)
//! or the following in `.cargo/config`:
//!
//! ```toml
//! [unstable]
//! features = ["host_dep"]
//! ```
//!
//! For example, this issue arises when depending on `parity-scale-codec-derive`.
//!
//! # Test
//! Most tests live in the `serde-scale-tests` crate (part of the workspace) in order to avoid
//! dependencies enabling `serde` features.
//!
//! ```sh
//! cargo test --workspace
//! ```
//!
//! # Contribute
//! All contributions shall be licensed under the [zlib license](https://opensource.org/licenses/Zlib).
//!
//! # Related projects
//! [parity-scale-codec](https://crates.io/crates/parity-scale-codec): Reference Rust implementation
extern crate alloc;
pub use ;
pub use ;
pub use ;
pub use Serializer;
pub use Write;
pub use to_vec;