Giter Site home page Giter Site logo

strict-types / strict-encoding Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 9.0 476 KB

Protobufs for functional programming

Home Page: https://strict-encoding.org

License: Apache License 2.0

Rust 100.00%
category-theory functional-programming gadt rust serialization-format serialization-library type-safety type-theory

strict-encoding's Introduction

Strict encoding

Apache-2 licensed

Protobufs for functional programming

This is a set of libraries for deterministic binary serialization using strict types – type system made with category theory which ensures provable properties and bounds for the in-memory and serialized type representation.

The development of the libraries is performed by UBIDECO Institute.

Overview

Strict types is a formal notation for defining and serializing generalized algebraic data types (GADT) in a deterministic and confined way. It is developed with type theory in mind.

Strict Types are:

  • schema-based (with the schema being strict encoding notation),
  • semantic, i.e. defines types not just as they are layed out in memory, but also depending on their meaning,
  • deterministic, i.e. produces the same result for a given type,
  • portabile, i.e. can run on ahy hardware architecture and OS, including low-performant embedded systems,
  • confined, i.e. provides guarantees and static analysis on a maximum size of the typed data,
  • formally verifiable.

Strict Encoding is set of libraries for serializing / deserializing data types in binary formats.

strict-encoding-box

Libraries

Language Source code Package
Rust ./rust crates.io
Python Planned n/a
TypeScript Planned n/a
Swift Planned n/a
Kotlin Planned n/a

Contributing

CONTRIBUTING.md

License

The libraries are distributed on the terms of Apache 2.0 license.

strict-encoding's People

Contributors

6293 avatar crisdut avatar dr-orlovsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

strict-encoding's Issues

Add strict_check method to StrictDecode

For checking internal data consistency upon decoding operation

impl<const VERSION: u8> StrictDecode for ___ {
  fn strict_check(&self) -> Result<(), DecodeError> {
    // ...
  }
}

The method should have a default implementation which should not error.

InvalidChar may be confusing in some instances

The InvalidRString::InvalidChar error contains the character that has been found to be invalid, but it may not match the character in the original string.

As an example, trying to issue an asset using a Unicode character in the ticker or name trigger this issue.

More specifically, issuing a NIA asset with name name with ℧nicode characters throws the error:

string 'name with ℧nicode characters' contains invalid character 'â'

This probably happens because the string is parsed 1 byte at a time and the 1st byte of the Unicode character happens to correspond to the â ASCII character, and this may lead do confusion.

Since the invalid character cannot be correctly interpreted in some cases, it may be better to omit it and just report the string that failed, or report the position of the invalid character in the string (which I think should always be correct) instead of its ASCII representation.

`--no-default-features` on `strict-encoding` not taking effect

Here is the output of cargo build -p strict_encoding -v --no-default-features:

rustc --crate-name strict_encoding --edition=2021 rust/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=181 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="derive"' --cfg 'feature="strict_encoding_derive"' -C metadata=e188277cae2a4737 -C extra-filename=-e188277cae2a4737 --out-dir /Users/yudaikiyofuji/IdeaProjects/strict-encoding/target/debug/deps -C incremental=/Users/yudaikiyofuji/IdeaProjects/strict-encoding/target/debug/incremental -L dependency=/Users/yudaikiyofuji/IdeaProjects/strict-encoding/target/debug/deps --extern amplify=/Users/yudaikiyofuji/IdeaProjects/strict-encoding/target/debug/deps/libamplify-be50d4e6df4ec592.rmeta --extern strict_encoding_derive=/Users/yudaikiyofuji/IdeaProjects/strict-encoding/target/debug/deps/libstrict_encoding_derive-627116894db1dd46.dylib

You can see the feature default is unexpectedly activated. This is likely because we have a dev-dependency strict_encoding_test which is circularly dependent on strict-encoding.

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.