Coder Social home page Coder Social logo

type-metadata's Introduction

type-metadata

Compactly serialize meta information about types in your crate.

Design

Design draft

Note: The design draft is outdated partially.

Overview

Types are describes by their identification (ID) and their structure or definition. The ID stores information about the name of the type, where the type has been defined and generic types communicate their generic arguments. The definition communicates the underlying serialization and deserialization structure of the type, possibly revealing internal fields etc.

The former is important to give a mean to differentiate types easily between each other and also provide a useful hint to users. The definitions provide third party tools, such as a UI client with information about how they are able to decode types language agnostically.

Internal Overview

Information about types is provided within the so-called type registry (Registry). Type identifiers and associated definitions are registered there and are associated with unique IDs that the outside can use to refer to them providing a lightweight way to decrease overhead of using type identifiers instead.

For the purpose of communicating type ID and definition there exists the HasTypeId and HasTypeDef respectively that is to be implemented by all supported types.

All concrete TypeId and TypeDef structures have two forms: One meta form (MetaType) that acts as a bridge to other forms and a compact form that is later to be serialized. The IntoCompact trait is implemented by them in order to compact a type ID or definition using an instance of a type registry.

After compactification all type ID and definitions are stored in the type registry. Note that during serialization the type registry should be serialized during general serialization procedure.

As a minor additional compaction step non-documentation strings are also compacted by the same mechanics.

Users

Simply build up any graph of data structures and use MetaType instances to communicate type information. Also provide an IntoCompact implementation that converts those MetaType instances into their compacted forms. Upon serialization do not forget to also serialize the type registry used for compaction.

Test

Generally test the crate with cargo test.

If you additionally want to test derive utilities, do cargo test --features derive.

type-metadata's People

Contributors

robbepop avatar shaunxw avatar xlc avatar

Stargazers

 avatar

Watchers

 avatar

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.