NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #3755 most downloaded on crates.io
Decode SCALE encoded bytes into arbitrary types at runtime
Last release 10 months ago
21 Nov 2025
Release timing varies
gaps range from 2 weeks to 12 months
Nearly every release is documented
notes for 20 of 20 stable releases
1 version withdrawn
withdrawn after publishing
4 years old
21 releases · first in 2022
One column per quarter.
Implement DecodeItemIterator on &mut Ts as well, so that we can use it more easily from visitors.
DecodeItemIterator on &mut Ts as well, so that we can use it more easily from visitors.Expose paths in sequences and variants too
Expose paths in sequences and variants too
Address clippy and doc errors
Prep to release 0.16.1
This release updates scale-bits to 0.7.0 which is exposed in the public API of scale-decode.
This release updates scale-bits to 0.7.0 which is exposed in the public API of scale-decode.
This release makes scale-decode entirely no_std which is now using core::Error instead of std::Error as it was using before behind the std feature . B
This release makes scale-decode 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.
This release makes scale-decode 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.
chore(deps): bump syn from 1.0 to 2.0
chore(deps): bump syn from 1.0 to 2.0
Full Changelog: v0.13.1...v0.13.2
Yanked because primitives-types is re-exported from this crate and thus is a breaking change.
Prep for 0.13.1 release
Prep for 0.13.1 release (#59)
Useful visitor errors can be hidden in some cases when a skip_decoding error is also emitted. This patch release fixes that.
This minor release avoids a couple of panics in the case of invalid bytes being interpreted as BitVecs or strings.
This minor release avoids a couple of panics in the case of invalid bytes being interpreted as BitVecs or strings.
A small API change was made to accommodate this, such that the Str::bytes_after now returns a result rather than just the bytes.
Update the scale-type-resolver dependency to 0.2.0 (and bump scale-bits for the same reason).
Update the scale-type-resolver dependency to 0.2.0 (and bump scale-bits for the same reason).
The main changes here are:
Composite type handed back in the visitor's visit_composite() method now exposes the name and path of the composite type being decoded, if one was provided.scale-info was still being pulled in via scale-type-resolver ; this has now been fixed
scale-info was still being pulled in via scale-type-resolver; this has now been fixedUp until now, this crate depended heavily on scale_info to provide the type information that we used to drive our decoding of types. This release remo
Up until now, this crate depended heavily on scale_info to provide the type information that we used to drive our decoding of types. This release removes the explicit dependency on scale-info, and instead depends on scale-type-resolver, which offers a generic TypeResolver trait whose implementations are able to provide the information needed to decode types (see this PR for more details). So now, the traits and types in scale-decode have been made generic over which TypeResolver is used to help decode things. scale-info::PortableRegistry is one such implementation of TypeResolver, and so can continue to be used in a similar way to before.
The main breaking changes are:
The scale_decode::Visitor trait now has an additional associated type, TypeResolver.
The simplest change to recover the previous behaviour is to just continue to use scale_info::PortableRegistry for this task, as was the case implicitly before:
struct MyVisitor;
impl Visitor for MyVisitor {
// ...
type TypeResolver = scale_info::PortableRegistry;
// ...
}A better change is to make your Visitor impls generic over what is used to resolve types unless you need a specific resolver:
struct MyVisitor<R>(PhantomData<R>);
impl <R> MyVisitor<R> {
pub fn new() -> Self {
Self(PhantomData)
}
}
impl <R: TypeResolver> Visitor for MyVisitor<R> {
// ...
type TypeResolver = R;
// ...
}scale_decode::IntoVisitor is implemented on all types that have an associated Visitor that we can use to decode it. It used to look like this:
pub trait IntoVisitor {
type Visitor: for<'scale, 'resolver> visitor::Visitor<
Value<'scale, 'resolver> = Self,
Error = Error,
>;
fn into_visitor() -> Self::Visitor;
}Now it looks like this:
pub trait IntoVisitor {
type AnyVisitor<R: TypeResolver>: for<'scale, 'resolver> visitor::Visitor<
Value<'scale, 'resolver> = Self,
Error = Error,
TypeResolver = R,
>;
fn into_visitor<R: TypeResolver>() -> Self::AnyVisitor<R>;
}What this means is that if you want to implement IntoVisitor for some type, then your Visitor must be able to accept any valid TypeResolver. This allows DecodeAsType to also be generic over which TypeResolver is provided.
This trait previously was specific to scale_info::PortableRegistry and looked something like this:
pub trait DecodeAsType: Sized + IntoVisitor {
fn decode_as_type<R: TypeResolver>(
input: &mut &[u8],
type_id: u32,
types: &scale_info::PortableRegistry,
) -> Result<Self, Error> {
// ...
}Now, it is generic over which type resolver to use (and as a side effect, requires a reference to the type_id now, because it may not be Copy any more):
pub trait DecodeAsType: Sized + IntoVisitor {
fn decode_as_type<R: TypeResolver>(
input: &mut &[u8],
type_id: &R::TypeId,
types: &R,
) -> Result<Self, Error> {
// ...
}This is automatically implemented for all types which implement IntoVisitor, as before.
Mostly, the changes just exist to make things generic over the TypeResolver. One consequence of this is that Composite and Variant types no longer know their path, because currently TypeResolver doesn't provide that information (since it's not necessary to the actual encoding/decoding of types). If there is demand for this, we can consider allowing TypeResolver impls to optionally provide these extra details.
This release changes IntoVisitor to require that the corresponding Visitor implements scale_decode::Error , rather than allowing the error to be anyth
This release changes IntoVisitor to require that the corresponding Visitor implements scale_decode::Error, rather than allowing the error to be anything that can be converted into a scale_decode::Error. This has the following advantages:
DecodeAsType a proper super-trait of IntoVisitor, meaning it can be used anywhere IntoVisitor is. Previously, using DecodeAsType in some places also required that you add a bound like B: IntoVisitor, <B::Visitor as Visitor>::Error: Into<scale_decode::Error, ie the Error type needed to explicitly be declared as convertible in the way that DecodeAsType requires.DecodeAsType.The main drawback is that if your Visitor implementation doesn't have Error = scale_decode::Error, then it can no longer be used with IntoVisitor. To work around this, a new adapter type, scale_decode::visitor::VisitorWithCrateError(your_visitor) has been added; any visitor wrapped in this type whose error implements Into<scale_decode::Error> will now implement Visitor with Error = scale_decode::Error.
Change how compact encoding is handled: visit_compact_* functions are removed from the Visitor trait, and compact encoding is now handled recursively
visit_compact_* functions are removed from the Visitor trait, and
compact encoding is now handled recursively and should now work in more cases (such as nested structs with compact
encoded values inside) (#32).Debug + Display on no_std or Error on std.
Error::custom() now accepts anything implementing these traits rather than depending on Into<Error>
(#31).Add support for no_std (+alloc) builds (#26). Thankyou @haerdib!
no_std (+alloc) builds (#26). Thankyou @haerdib!Change DecodeAsFields again; remove the generic iterator parameter and use &mut dyn FieldIter instead. This Simplifies the call signatures in a bunch
DecodeAsFields again; remove the generic iterator parameter and use &mut dyn FieldIter instead. This
Simplifies the call signatures in a bunch of places and is consistent with how scale-encode works.smallvec instead of our own stack allocated vec.Change DecodeAsFields to accept an iterator of fields to decode into. This makes it more flexible in what it is able to decode. This bleeds into vario
DecodeAsFields to accept an iterator of fields to decode into. This makes it more flexible in what it
is able to decode. This bleeds into various other types, which inherit a generic parameter to represent this
iterator that is used to drive decoding.This release shifts scale-decode to being a mirror of a new scale-encode crate, and:
This release shifts scale-decode to being a mirror of a new scale-encode crate, and:
IntoVisitor trait that types can implement if there is a Visitor which can be used to decode
into them.DecodeAsType trait to mirror the EncodeAsType trait there; any type that implements IntoVisitor
automatically implements DecodeAsType.DecodeAsFields trait to mirror EncodeAsFields, implemented for tuple and struct types.Visitor trait into a sub module and re-works the interface to allow zero copy decoding, allow more
concise implementations of it, and provide a fallback escape hatch to allow for more arbitrary DecodeAsType
implementations from it.DecodeAsType (via Visitor and IntoVisitor impls) and DecodeAsFields on common types.DecodeAsType derive macro to auto-generate impls on custom struct and enum types.Any Visitor impls will need to be updated to use the refined Visitor trait; this should be fairly mechanical
(check out the examples and follow the compiler guidance to do this). Otherwise, the rest of the changes are
additive and just make it easier to implement this trait and obtain a DecodeAsType implementation, if desired.
This release removes bitvec and the 32bit feature flag needed to play nicely with it and leans on scale-bits instead to decode bit sequences. We add a
This release removes bitvec and the 32bit feature flag needed to play nicely with it and leans on scale-bits instead
to decode bit sequences. We add a CI check to ensure that it can be compiled to WASM.
This release makes the following changes:
This release makes the following changes:
visit_ functions are now handed a TypeId too, which is just a wrapper around a u32 corresponding
to the type being decoded in the given PortableRegistry. Useful if you'd like to look up more details about
the type in the registry or just store the ID somewhere.visit_compact_ functions are now handed a visitor::Compact struct which one can obtain the compact encoded
value from, or view the path to the compact encoded value via a .locations() method, in case the compact value
is actually nested within named/unnamed structs. The TypeId provided is always the outermost type of the Compact
value, and so one can also discover this information by manual traversal (but since we have to traverse anyway..).Variant type has been simplified and largely just allows access to the underlying Composite type to decode.Composite type now provides direct access to the (yet-to-be-decoded) fields, and offers separate
decode_item and decode_item_with_name methods to make decoding into named or unnamed shapes a little easier.Visitor related types are now exported directly from the visitor module rather than a visitor::types module.Remove remaining() functions from visitor structs; the len() calls now return the items left to decode.
remaining() functions from visitor structs; the len() calls now return the
items left to decode.Initial release containging a decode function, Visitor trait to implement, and an IgnoreVisitor impl to skip over SCALE bytes instead of decode them i
Initial release containging a decode function, Visitor trait to implement, and an
IgnoreVisitor impl to skip over SCALE bytes instead of decode them into some type.
Your coding agent can read these notes before it upgrades. Set up the MCP server →