Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[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 withscale-type-resolver
, which provides a genericTypeResolver
trait whose implementations are able to provide the information needed to encode/decode types. So now, rather than taking in ascale_info::PortableRegistry
, theEncodeAsType
andEncodeAsFields
traits take a genericR: scale_type_resolver::TypeResolver
value.scale_info::PortableRegistry
implementsTypeResolver
, 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:And now it looks like this:
One effect that this has is that
EncodeAsType
andEncodeAsFields
are no longer object safe (since the method they expose accepts a generic type now). Internally this led us to also change howscale_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 implementsEncodeAsType
:We can now have
&dyn EncodeAsTypeWithResolver<SomeConcreteResolver>
instances.The full PR is here: