Giter Site home page Giter Site logo

scale-type-resolver's Introduction

scale-type-resolver

scale-type-resolver provides a generic TypeResolver trait which can be implemented for any type that is capable of being given a type ID and resolving that into information about how the type is SCALE encoded. This allows libraries like scale-decode to be able to decode SCALE encoded bytes using either a modern type resolver like scale_info::PortableRegistry, or using entirely custom type resolvers (which we would need in order decode blocks from pre-V14 metadata).

It's unlikely that you'd depend on this library directly; more likely you'd depend on a library like scale-decode which uses and re-exports the TypeResolver trait itself.

This crate is no_std by default and doesn't require alloc except for tests.

scale-type-resolver's People

Contributors

jsdw avatar dependabot[bot] avatar

Stargazers

Tadeo Hepperle avatar Harry Solovay avatar Tarik Gul avatar

Watchers

ddorgan avatar Niklas Adolfsson avatar  avatar

scale-type-resolver's Issues

Consider exposing optional name/path of variant/composite types

In scale_info::PortableRegistry we can obtain the path of composite and variant types. This isn't relevant for normal encoding and decoding, but may be useful in a couple of other scenarios:

  • If I make a custom type with custom encoding/decoding in order to mirror some Substrate type, I may want to be able to check in the EncodeAsType/DecodeAsType impls that the target type has the expected name (ie is likely to have led to the same custom encoding/decoding).
  • I may want to be able to return the target type name/path in errors.

This information is not mandatory and so I think it should be optional whether a TypeResolver implementation provides it or not (ie for V14 types, we can always provide it, but for older types it may be easier if the user doesn't have to provide such information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.