PackageTrack
Sign in Get early access

scale-encode

Encode types to SCALE bytes given a desired target type

0.10.1 6.1M downloads/mo #4105 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 2025
2023 2024 2025 2026
Release Pre-release

Releases

latest 33
  1. 0.10.1 16 Dec 2025
    Release notes

    Add implementations of EncodeAsFields for Vec<T>, [T; N], &[T] and tuples, so long as the values implement EncodeAsType.

    Open source →
  2. 0.10.0 15 Nov 2024
    Release notes

    [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.

    Open source →
    Release notes

    This release updates scale-bits to 0.7.0 which is exposed in the public API of scale-encode.

    Open source →
  3. 0.9.0 13 Nov 2024
    Release notes

    [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

    Open source →
    Release notes

    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)
    Open source →
  4. 0.8.0 21 Oct 2024
    Release notes

    [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

    Open source →
    Release notes
    • 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)
    Open source →
  5. 0.7.2 21 Oct 2024
    Release notes

    [v0.7.2] - 2024-10-21

    • Update dependencies syn 2.0, darling 0.20 and proc-macro-crate 3.1 (#24)
    Open source →
    Release notes
    • Update dependencies syn 2.0, darling 0.20 and proc-macro-crate 3.1 (#24)
    Open source →
  6. 0.7.1 17 May 2024
    Release notes

    [v0.7.1] - 2024-05-17

    • Implement EncodeAsFields for pointer types like Arc and Box (#22)
    Open source →
    Release notes
    • Implement EncodeAsFields for pointer types like Arc and Box (#22)
    Open source →
  7. 0.7.0 29 Apr 2024
    Release notes

    [v0.7.0] - 2024-04-29

    Update the scale-type-resolver dependency to 0.2.0 (and bump scale-bits for the same reason).

    The main change here is that type IDs are now passed by value, rather than reference.

    Open source →
    Release notes

    Update the scale-type-resolver dependency to 0.2.0 (and bump scale-bits for the same reason).

    The main change here is that type IDs are now passed by value, rather than reference.

    Open source →
  8. 0.6.0 16 Feb 2024
    Release notes

    [v0.6.0] - 2024-02-16

    Up until now, scale-info has 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 with scale-type-resolver, which provides a generic TypeResolver trait whose implementations are able to provide the information needed to encode/decode types. So now, rather than taking in a scale_info::PortableRegistry, the EncodeAsType and EncodeAsFields traits take a generic R: scale_type_resolver::TypeResolver value. scale_info::PortableRegistry implements TypeResolver, and so it can continue to be used similarly to before (though now, type_id is passed as a reference), but now we are generic over where the type information we need comes from.

    To be more concrete, EncodeAsType used 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 EncodeAsType and EncodeAsFields are no longer object safe (since the method they expose accepts a generic type now). Internally this led us to also change how scale_encode::Composite works 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 implements EncodeAsType:

    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).
    Open source →
    Release notes

    Up until now, scale-info has 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 with scale-type-resolver, which provides a generic TypeResolver trait whose implementations are able to provide the information needed to encode/decode types. So now, rather than taking in a scale_info::PortableRegistry, the EncodeAsType and EncodeAsFields traits take a generic R: scale_type_resolver::TypeResolver value. scale_info::PortableRegistry implements TypeResolver, and so it can continue to be used similarly to before (though now, type_id is passed as a reference), but now we are generic over where the type information we need comes from.

    To be more concrete, EncodeAsType used 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 EncodeAsType and EncodeAsFields are no longer object safe (since the method they expose accepts a generic type now). Internally this led us to also change how scale_encode::Composite works 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 implements EncodeAsType:

    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).
    Open source →
  9. 0.5.0 02 Aug 2023
    Release notes

    [v0.5.0] - 2023-08-02

    • Improve custom error handling: custom errors now require Debug + Display on no_std or Error on std.
      Error::custom() now accepts anything implementing these traits rather than depending on Into<Error>
      (#13).
    • Enable using #[codec(skip)] or #[encode_as_type(skip)] to ignore fields when using the EncodeAsType macro.
      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).
    Open source →
    Release notes
    • Improve custom error handling: custom errors now require Debug + Display on no_std or Error on std. Error::custom() now accepts anything implementing these traits rather than depending on Into<Error> (#13).
    • Enable using #[codec(skip)] or #[encode_as_type(skip)] to ignore fields when using the EncodeAsType macro. 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).
    Open source →
  10. 0.4.0 12 Jul 2023
    Release notes

    Prep to release 0.4.0 (#12)

    Open source →
    Release notes
    • Add support for no_std (+alloc) builds (#11). Thankyou @haerdib!
    Open source →
  11. 0.3.0 31 May 2023
    Release notes

    Prep for 0.3.0 release, and restore object safety of EncodeAsFields t…

    Open source →
    Release notes
    • Remove the generic iterator from EncodeAsFields and ensure that it's object safe. Use a &mut dyn iterator instead.
    Open source →
  12. 0.2.0 26 May 2023
    Release notes
    • Update scale-info to latest, removing deprecated method calls.
    • Change EncodeAsFields to accept an iterator over fields, to allow more flexibility in how we provide fields to encode.
    Open source →
  13. 0.1.2 01 Mar 2023
    Release notes

    Fix a silly typo in the scale-encode-derive README.

    Open source →
  14. 0.1.1 01 Mar 2023
    Release notes

    Improve the documentation with more examples, and tweak BTreeMap encoding and Composite encoding to be more tolerant.

    Open source →
  15. 0.1.0 28 Feb 2023
    Release notes

    Initial release.

    Open source →
  16. 0.0.18 27 Feb 2023

    Nothing published for this version

  17. 0.0.17 23 Feb 2023

    Nothing published for this version

  18. 0.0.16 23 Feb 2023

    Nothing published for this version

  19. 0.0.15 16 Feb 2023

    Nothing published for this version

  20. 0.0.14 16 Feb 2023

    Nothing published for this version

  21. 0.0.13 16 Feb 2023

    Nothing published for this version

  22. 0.0.12 16 Feb 2023

    Nothing published for this version

  23. 0.0.11 14 Feb 2023

    Nothing published for this version

  24. 0.0.10 14 Feb 2023

    Nothing published for this version

  25. 0.0.9 14 Feb 2023

    Nothing published for this version

  26. 0.0.8 14 Feb 2023

    Nothing published for this version

  27. 0.0.7 13 Feb 2023

    Nothing published for this version

  28. 0.0.6 10 Feb 2023

    Nothing published for this version

  29. 0.0.5 10 Feb 2023

    Nothing published for this version

  30. 0.0.4 02 Feb 2023

    Nothing published for this version

  31. 0.0.3 31 Jan 2023

    Nothing published for this version

  32. 0.0.2 30 Jan 2023

    Nothing published for this version

  33. 0.0.1 24 Nov 2022

    Nothing published for this version

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive