GithubHelp home page GithubHelp logo

scales's Introduction

scales - SCALE Serialization

Making use of type information this library allows conversion to/from SCALE encoded data, specially useful when conversion is for dynamic types like JSON.

From SCALE

scales::Value wraps the raw SCALE binary data and the type id within type registry giving you an object that can be serialized to any compatible format.

let value = scales::Value::new(scale_binary_data, type_id, &type_registry);
serde_json::to_string(value)?;

To SCALE

Public methods from the scales::serializer::* module(feature experimental-serializer) allow for a best effort conversion of dynamic types(e.g. serde_json::Value) to SCALE binary format. The serializer tries to be smart when interpreting the input and convert it to the desired format dictated by the provided type in the registry.

// simple conversion
let scale_data = to_vec(some_serializable_input); // or to_bytes(&mut bytes, input);

// with type info
let scale_data = to_vec_with_info(input, Some((&registry, type_id)));

// from an unordered list of properties that make an object
let input = vec![("prop_b", 123), ("prop_a", 456)];
let scale_data = to_vec_from_iter(input, (&registry, type_id));

scales's People

Contributors

olanod avatar pandres95 avatar stanly-johnson 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.