The format is based on Keep a Changelog.
- Change
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 howscale-encode
works. - Use
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 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:
- Adds a new
IntoVisitor
trait that types can implement if there is aVisitor
which can be used to decode into them. - Adds a new
DecodeAsType
trait to mirror theEncodeAsType
trait there; any type that implementsIntoVisitor
automatically implementsDecodeAsType
. - Adds a new
DecodeAsFields
trait to mirrorEncodeAsFields
, implemented for tuple and struct types. - Moves the
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 arbitraryDecodeAsType
implementations from it. - Implements
DecodeAsType
(viaVisitor
andIntoVisitor
impls) andDecodeAsFields
on common types. - Adds a
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.
- Add DecodeAsType backed by Visitor impls for standard types. (#11)
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.
- Use scale-bits to handle bit sequences (#5
This release makes the following changes:
- All
visit_
functions are now handed aTypeId
too, which is just a wrapper around au32
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 avisitor::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..).- The
Variant
type has been simplified and largely just allows access to the underlyingComposite
type to decode. - The
Composite
type now provides direct access to the (yet-to-be-decoded)fields
, and offers separatedecode_item
anddecode_item_with_name
methods to make decoding into named or unnamed shapes a little easier. Visitor
related types are now exported directly from thevisitor
module rather than avisitor::types
module.- Lifetimes have been made more precise to avoid unnecessary lifetime related errors.
- TypeIds, more info for compact encoded values and tidy up (#1)
- Remove
remaining()
functions from visitor structs; thelen()
calls now return the items left to decode. - Fix clippy and doc links.
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.