scale-encode-derive
Derive macro for scale-encode
0.10.1
6.0M downloads/mo
#4122 most downloaded on crates.io
paritytech/scale-encode
What this package is like to depend on
Last release 8 months ago
16 Dec 2025
Release timing varies
gaps range from 1 weeks to 13 months
Some releases are documented
notes for 15 of 33 stable releases
Nothing withdrawn
no release was ever pulled
4 years old
33 releases · first in 2022
1 release in the last 12 months
see the full history below
Release timeline
33 releases · Nov 2022 to Dec 2025Releases
latest 33-
0.10.116 Dec 2025Release notes
Open source →Add implementations of
EncodeAsFieldsforVec<T>,[T; N],&[T]and tuples, so long as the values implementEncodeAsType. -
0.10.015 Nov 2024Release notes
Open source →[0.10.0] - 2024-11-15
This release updates scale-bits to 0.7.0 which is exposed in the public API of scale-encode.
Release notes
Open source →This release updates scale-bits to 0.7.0 which is exposed in the public API of scale-encode.
-
0.9.013 Nov 2024Release notes
Open source →[v0.9.0] - 2024-11-13
This release makes scale-encode entirely no_std which is now using core::error::Error instead of std::error::Error as it was using before behind the std feature. Because of that the std feature is now removed and the MSRV is bumped to 1.81.0.
Changed
- chore(deps): use core::error::Error and make no_std (#30)
Full Changelog: v0.8.0...v0.9.0
Release notes
Open source →This release makes scale-encode entirely no_std which is now using core::error::Error instead of std::error::Error as it was using before behind the std feature. Because of that the std feature is now removed and the MSRV is bumped to 1.81.0.
Changed
- chore(deps): use core::error::Error and make no_std (#30)
-
0.8.021 Oct 2024Release notes
Open source →[v0.8.0] - 2024-10-21
- chore(deps): bump derive_more from 0.99 to 1.0 (#26)
- chore(deps): bump primitive-types from 0.12.0 to 0.13.1 (#27)
Full Changelog: v0.7.2...v0.8.0
-
0.7.221 Oct 2024Release notes
Open source →[v0.7.2] - 2024-10-21
- Update dependencies
syn 2.0,darling 0.20andproc-macro-crate 3.1(#24)
Release notes
Open source →- Update dependencies
syn 2.0,darling 0.20andproc-macro-crate 3.1(#24)
- Update dependencies
-
0.7.117 May 2024Release notes
Open source →[v0.7.1] - 2024-05-17
- Implement EncodeAsFields for pointer types like Arc and Box (#22)
-
0.7.029 Apr 2024Release notes
Open source →[v0.7.0] - 2024-04-29
Update the
scale-type-resolverdependency to 0.2.0 (and bumpscale-bitsfor the same reason).The main change here is that type IDs are now passed by value, rather than reference.
Release notes
Open source →Update the
scale-type-resolverdependency to 0.2.0 (and bumpscale-bitsfor the same reason).The main change here is that type IDs are now passed by value, rather than reference.
-
0.6.016 Feb 2024Release notes
Open source →[v0.6.0] - 2024-02-16
Up until now,
scale-infohas been the library that gives us the information needed to know how to SCALE encode values to the correct shape. In this release, we remove it from our dependency tree and replace it withscale-type-resolver, which provides a genericTypeResolvertrait whose implementations are able to provide the information needed to encode/decode types. So now, rather than taking in ascale_info::PortableRegistry, theEncodeAsTypeandEncodeAsFieldstraits take a genericR: scale_type_resolver::TypeResolvervalue.scale_info::PortableRegistryimplementsTypeResolver, and so it can continue to be used similarly to before (though now,type_idis passed as a reference), but now we are generic over where the type information we need comes from.To be more concrete,
EncodeAsTypeused to look roughly like this:pub trait EncodeAsType { fn encode_as_type_to( &self, type_id: u32, types: scale_info::PortableRegistry, out: &mut Vec<u8>, ) -> Result<(), Error>; }
And now it looks like this:
pub trait EncodeAsType { fn encode_as_type_to<R: TypeResolver>( &self, type_id: &R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>; }
One effect that this has is that
EncodeAsTypeandEncodeAsFieldsare no longer object safe (since the method they expose accepts a generic type now). Internally this led us to also change howscale_encode::Compositeworks slightly (see the docs for that for more information). if you need object safety, and know the type resolver that you want to use, then you can make a trait + blanket impl like this which is object safe and is implemented for anything which implementsEncodeAsType:trait EncodeAsTypeWithResolver<R: TypeResolver> { fn encode_as_type_with_resolver_to( &self, type_id: &R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>; } impl<T: EncodeAsType, R: TypeResolver> EncodeAsTypeWithResolver<R> for T { fn encode_as_type_with_resolver_to( &self, type_id: &R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error> { self.encode_as_type_to(type_id, types, out) } }
We can now have
&dyn EncodeAsTypeWithResolver<SomeConcreteResolver>instances.The full PR is here:
- Enable generic type encoding via TypeResolver and remove dependency on scale-info (#19).
Release notes
Open source →Up until now,
scale-infohas been the library that gives us the information needed to know how to SCALE encode values to the correct shape. In this release, we remove it from our dependency tree and replace it withscale-type-resolver, which provides a genericTypeResolvertrait whose implementations are able to provide the information needed to encode/decode types. So now, rather than taking in ascale_info::PortableRegistry, theEncodeAsTypeandEncodeAsFieldstraits take a genericR: scale_type_resolver::TypeResolvervalue.scale_info::PortableRegistryimplementsTypeResolver, and so it can continue to be used similarly to before (though now,type_idis passed as a reference), but now we are generic over where the type information we need comes from.To be more concrete,
EncodeAsTypeused to look roughly like this:pub trait EncodeAsType { fn encode_as_type_to( &self, type_id: u32, types: scale_info::PortableRegistry, out: &mut Vec<u8>, ) -> Result<(), Error>; }And now it looks like this:
pub trait EncodeAsType { fn encode_as_type_to<R: TypeResolver>( &self, type_id: &R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>; }One effect that this has is that
EncodeAsTypeandEncodeAsFieldsare no longer object safe (since the method they expose accepts a generic type now). Internally this led us to also change howscale_encode::Compositeworks slightly (see the docs for that for more information). if you need object safety, and know the type resolver that you want to use, then you can make a trait + blanket impl like this which is object safe and is implemented for anything which implementsEncodeAsType:trait EncodeAsTypeWithResolver<R: TypeResolver> { fn encode_as_type_with_resolver_to( &self, type_id: &R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>; } impl<T: EncodeAsType, R: TypeResolver> EncodeAsTypeWithResolver<R> for T { fn encode_as_type_with_resolver_to( &self, type_id: &R::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error> { self.encode_as_type_to(type_id, types, out) } }We can now have
&dyn EncodeAsTypeWithResolver<SomeConcreteResolver>instances.The full PR is here:
- Enable generic type encoding via TypeResolver and remove dependency on scale-info (#19).
-
0.5.002 Aug 2023Release notes
Open source →[v0.5.0] - 2023-08-02
- Improve custom error handling: custom errors now require
Debug + Displayonno_stdorErroronstd.
Error::custom()now accepts anything implementing these traits rather than depending onInto<Error>
(#13). - Enable using
#[codec(skip)]or#[encode_as_type(skip)]to ignore fields when using theEncodeAsTypemacro.
Skipping isn't generally necessary, but can be useful in edge cases (such as allowing a multi-field struct to be
encoded to a number if all but one numeric field is skipped) (#16).
Release notes
Open source →- Improve custom error handling: custom errors now require
Debug + Displayonno_stdorErroronstd.Error::custom()now accepts anything implementing these traits rather than depending onInto<Error>(#13). - Enable using
#[codec(skip)]or#[encode_as_type(skip)]to ignore fields when using theEncodeAsTypemacro. Skipping isn't generally necessary, but can be useful in edge cases (such as allowing a multi-field struct to be encoded to a number if all but one numeric field is skipped) (#16).
- Improve custom error handling: custom errors now require
-
0.4.012 Jul 2023 -
0.3.031 May 2023Release notes
Open source →- Remove the generic iterator from
EncodeAsFieldsand ensure that it's object safe. Use a&mut dyniterator instead.
- Remove the generic iterator from
-
0.2.026 May 2023Release notes
Open source →- Update
scale-infoto latest, removing deprecated method calls. - Change
EncodeAsFieldsto accept an iterator over fields, to allow more flexibility in how we provide fields to encode.
- Update
-
0.1.201 Mar 2023 -
0.1.101 Mar 2023Release notes
Open source →Improve the documentation with more examples, and tweak BTreeMap encoding and Composite encoding to be more tolerant.
-
0.1.028 Feb 2023 -
0.0.1827 Feb 2023Nothing published for this version
-
0.0.1723 Feb 2023Nothing published for this version
-
0.0.1623 Feb 2023Nothing published for this version
-
0.0.1516 Feb 2023Nothing published for this version
-
0.0.1416 Feb 2023Nothing published for this version
-
0.0.1316 Feb 2023Nothing published for this version
-
0.0.1216 Feb 2023Nothing published for this version
-
0.0.1114 Feb 2023Nothing published for this version
-
0.0.1014 Feb 2023Nothing published for this version
-
0.0.914 Feb 2023Nothing published for this version
-
0.0.814 Feb 2023Nothing published for this version
-
0.0.713 Feb 2023Nothing published for this version
-
0.0.610 Feb 2023Nothing published for this version
-
0.0.510 Feb 2023Nothing published for this version
-
0.0.402 Feb 2023Nothing published for this version
-
0.0.331 Jan 2023Nothing published for this version
-
0.0.230 Jan 2023Nothing published for this version
-
0.0.130 Nov 2022Nothing published for this version