GithubHelp home page GithubHelp logo

salespaulo / cbor-erlang Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yjh0502/cbor-erlang

0.0 1.0 0.0 148 KB

cbor encoder/decoder in Erlang

License: BSD 3-Clause "New" or "Revised" License

Erlang 100.00%

cbor-erlang's Introduction

Erlang CBOR encoder/decoder

Requirements

  • Erlang 17.0 or higher: cbor-erlang uses erlang maps to represent map, which introduced from 17.0.

Highlights

  • Optimized: no sub-binary is created while decoding, hot code path is built with single jump table built by pattern matching.
  • Tested: contains all testcases on standard documents.
  • Correct floating-point implemntation: can decode floating points that are not supported by language: half-presition floating points, NaN, (+-)Infinity.

Decoder mappings

Genral

  • Both byte string and UTF-8 string is mapped to binary.
  • All numbers(integers, bignums, floating points) are mapped to number.
  • Lists are mapped to plain lists, maps are mapped to maps.

Tags

  • Bignums are decoded to numbers.
  • Date/time string (tag 0) is mapped to {timetext, Binary}
  • Epoch-based date/time (tag 1) is mapped to {timeepoch, Number}
  • Other tags are mapped to {tag, TagId, Value}

Encoder mappings

Encoder encodes erlang terms to CBOR-encoded iolist. iolist_to_binary could be used if you need single binary output.

  • Numbers (fixed-size numbers, big numbers, floating-point numbers) are supported.
  • All binaries are encoded to byte strings.
  • Atoms true, false, null, undefined are suported.
  • All lists/maps are encoded to break-terminating format.

TODO

  • cbor-erlang does not distingiush byte string and UTF-8 string while decoding. Some invalid CBOR tagged values could be decoded without problem, for example date/time string (tag 0) with byte string data items. The bug should be fixed later.
  • No error reporting on encoding/decoding: no detailed error information is provided to caller, for example why encoding/decoding is failed or which byte decoder failed to decode.
  • Decimal fraction (tag 3) and bigfloat (tag 4) is not supported.
  • Add faster encoder which generates non-canonical CBOR data.

cbor-erlang's People

Contributors

yjh0502 avatar

Watchers

James Cloos 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.