Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ test-rust-stable:
stage: test
<<: *docker-env
script:
- time cargo +stable test --verbose --all --features bit-vec,generic-array,derive
- time cargo +stable test --verbose --all --features bit-vec,generic-array,derive,max-encoded-len
- sccache -s

test-rust-stable-no_derive:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "parity-scale-codec"
description = "SCALE - Simple Concatenating Aggregated Little Endians"
version = "2.2.0-rc.3"
version = "2.2.0"
authors = ["Parity Technologies <[email protected]>"]
license = "Apache-2.0"
repository = "https://github.com/paritytech/parity-scale-codec"
Expand All @@ -11,7 +11,7 @@ edition = "2018"
[dependencies]
arrayvec = { version = "0.7", default-features = false }
serde = { version = "1.0.102", optional = true }
parity-scale-codec-derive = { path = "derive", version = "2.2.0-rc.3", default-features = false, optional = true }
parity-scale-codec-derive = { path = "derive", version = "2.2.0", default-features = false, optional = true }
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"], optional = true }
byte-slice-cast = { version = "1.0.0", default-features = false }
generic-array = { version = "0.14.4", optional = true }
Expand All @@ -21,7 +21,7 @@ impl-trait-for-tuples = "0.2.1"
[dev-dependencies]
criterion = "0.3.0"
serde_derive = { version = "1.0" }
parity-scale-codec-derive = { path = "derive", version = "2.2.0-rc.1", default-features = false }
parity-scale-codec-derive = { path = "derive", default-features = false }
quickcheck = "1.0"
trybuild = "1.0.42"

Expand All @@ -39,6 +39,11 @@ std = ["serde", "bitvec/std", "byte-slice-cast/std", "chain-error"]
bit-vec = ["bitvec"]
fuzz = ["std", "arbitrary"]

# Enables the new `MaxEncodedLen` trait.
# NOTE: This is still considered experimental and is exempt from the usual
# SemVer guarantees. We do not guarantee no code breakage when using this.
max-encoded-len = ["parity-scale-codec-derive/max-encoded-len"]

# Make error fully descriptive with chaining error message.
# Should not be used in a constrained environment.
chain-error = []
Expand Down
8 changes: 7 additions & 1 deletion derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "parity-scale-codec-derive"
description = "Serialization and deserialization derive macro for Parity SCALE Codec"
version = "2.2.0-rc.3"
version = "2.2.0"
authors = ["Parity Technologies <[email protected]>"]
license = "Apache-2.0"
edition = "2018"
Expand All @@ -17,3 +17,9 @@ proc-macro-crate = "1.0.0"

[dev-dependencies]
parity-scale-codec = { path = ".." }

[features]
# Enables the new `MaxEncodedLen` trait.
# NOTE: This is still considered experimental and is exempt from the usual
# SemVer guarantees. We do not guarantee no code breakage when using this.
max-encoded-len = []
1 change: 1 addition & 0 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ pub fn compact_as_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStr
}

/// Derive `MaxEncodedLen`.
#[cfg(feature = "max-encoded-len")]
#[proc_macro_derive(MaxEncodedLen, attributes(max_encoded_len_mod))]
pub fn derive_max_encoded_len(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
max_encoded_len::derive_max_encoded_len(input)
Expand Down
2 changes: 2 additions & 0 deletions derive/src/max_encoded_len.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg(feature = "max-encoded-len")]

use crate::utils::{self, codec_crate_path, custom_mel_trait_bound};
use quote::{quote, quote_spanned};
use syn::{
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ mod depth_limit;
mod encode_append;
mod encode_like;
mod error;
#[cfg(feature = "max-encoded-len")]
mod max_encoded_len;

pub use self::error::Error;
Expand All @@ -297,6 +298,7 @@ pub use self::decode_all::DecodeAll;
pub use self::depth_limit::DecodeLimit;
pub use self::encode_append::EncodeAppend;
pub use self::encode_like::{EncodeLike, Ref};
#[cfg(feature = "max-encoded-len")]
pub use max_encoded_len::MaxEncodedLen;
/// Derive macro for [`MaxEncodedLen`][max_encoded_len::MaxEncodedLen].
///
Expand Down Expand Up @@ -341,5 +343,5 @@ pub use max_encoded_len::MaxEncodedLen;
/// #[codec(crate = $crate::codec)]
/// struct Example;
/// ```
#[cfg(feature = "derive")]
#[cfg(all(feature = "derive", feature = "max-encoded-len"))]
pub use parity_scale_codec_derive::MaxEncodedLen;