All Projects → catwell → Luajit Msgpack Pure

catwell / Luajit Msgpack Pure

Licence: mit
MessagePack for LuaJIT (using FFI, no bindings, V4 API)

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to Luajit Msgpack Pure

Msgpack Rust
MessagePack implementation for Rust / msgpack.org[Rust]
Stars: ✭ 561 (+690.14%)
Mutual labels:  messagepack
Msgp
A Go code generator and library for MessagePack - msgpack.org[Go]
Stars: ✭ 12 (-83.1%)
Mutual labels:  messagepack
Vanilla
An OpenResty Lua MVC Web Framework
Stars: ✭ 1,018 (+1333.8%)
Mutual labels:  luajit
Msgpack Javascript
MessagePack for JavaScript/TypeScript/ECMA-262 / msgpack.org[JavaScript]
Stars: ✭ 742 (+945.07%)
Mutual labels:  messagepack
Liko 12
LIKO-12 is an open source fantasy computer made using LÖVE.
Stars: ✭ 811 (+1042.25%)
Mutual labels:  luajit
Nano Nginx
Nano container with nginx preconfigured as reverse proxy
Stars: ✭ 15 (-78.87%)
Mutual labels:  luajit
Luaradio
A lightweight, embeddable software-defined radio framework built on LuaJIT
Stars: ✭ 509 (+616.9%)
Mutual labels:  luajit
Pelagia
Automatic parallelization (lock-free multithreading thread) tool developed by Surparallel Open Source.Pelagia is embedded key value database that implements a small, fast, high-reliability on ANSI C.
Stars: ✭ 1,132 (+1494.37%)
Mutual labels:  luajit
Luaty
Lua with more or less typing. You type less; we type check.
Stars: ✭ 9 (-87.32%)
Mutual labels:  luajit
Lua Resty Post
HTTP post utility for openresty
Stars: ✭ 30 (-57.75%)
Mutual labels:  luajit
Lua Nginx Redis
🌺 Redis、Lua、Nginx、OpenResty 笔记和资料
Stars: ✭ 757 (+966.2%)
Mutual labels:  luajit
Raptorjit
RaptorJIT: A dynamic language for system programming (LuaJIT fork)
Stars: ✭ 784 (+1004.23%)
Mutual labels:  luajit
Kong
🦍 The Cloud-Native API Gateway
Stars: ✭ 30,838 (+43333.8%)
Mutual labels:  luajit
Grid Sdk
The Grid SDK - Game engine for Lua
Stars: ✭ 612 (+761.97%)
Mutual labels:  luajit
Koreader
An ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats, running on Cervantes, Kindle, Kobo, PocketBook and Android devices
Stars: ✭ 9,467 (+13233.8%)
Mutual labels:  luajit
Json
JSON for Modern C++
Stars: ✭ 27,824 (+39088.73%)
Mutual labels:  messagepack
R6rs Msgpack
MessagePack for R6RS Scheme / msgpack.org[Scheme]
Stars: ✭ 14 (-80.28%)
Mutual labels:  messagepack
Lgf
Game development framework for Lua
Stars: ✭ 68 (-4.23%)
Mutual labels:  luajit
Luamqtt
luamqtt - Pure-lua MQTT v3.1.1 and v5.0 client
Stars: ✭ 58 (-18.31%)
Mutual labels:  luajit
Lqt
Lua Binding for Qt5
Stars: ✭ 30 (-57.75%)
Mutual labels:  luajit

luajit-msgpack-pure

Warning

This library implements MessagePack spec v4 with some extensions compatible with msgpack-js. It does not implement spec v5. If you need support for spec v5 (including STR8, BIN types, etc), see alternatives.

Presentation

This is yet another implementation of MessagePack for LuaJIT. However, unlike luajit-msgpack, luajit-msgpack-pure does not depend on the MessagePack C library. Everything is re-implemented in LuaJIT code (using the FFI but only to manipulate data structures).

Alternatives

If I had to pick a single MessagePack implementation, it would be lua-MessagePack. It is pure Lua, its performance is very close to luajit-msgpack-pure and it supports the latest revision of the standard. If it had existed earlier, I would not have written this one. If you start a new project, use it.

Another interesting implementation is lua-cmsgpack, written in C specifically for use in Redis.

Other implementations:

Before luajit-msgpack-pure, I had written luajit-msgpack, a FFI binding which is now deprecated.

TODO

  • Missing datatype tests
  • Comparison tests vs. other implementations

Usage

Basics

local mp = require "luajit-msgpack-pure"
local my_data = {this = {"is",4,"test"}}
local encoded = mp.pack(my_data)
local offset,decoded = mp.unpack(encoded)
assert(offset == #encoded)

Concatenating encoded data

local mp = require "luajit-msgpack-pure"
local my_data_1 = 42
local my_data_2 = "foo"
local encoded = mp.pack(my_data_1) .. mp.pack(my_data_2)
local offset_1,decoded_1 = mp.unpack(encoded)
assert(decoded_1 == 42)
local offset_2,decoded_2 = mp.unpack(encoded,offset_1)
assert(decoded_2 == "foo")
local offset_3,decoded_3 = mp.unpack(encoded,offset_2)
assert((not offset_3) and (decoded_3 == nil))

Setting floating point precision

local mp = require "luajit-msgpack-pure"
local my_data = math.pi
local encoded_1 = mp.pack(my_data) -- default is double
local offset_1,decoded_1 = mp.unpack(encoded_1)
assert(offset_1 == 9) -- 1 byte overhead + 8 bytes double
assert(decoded_1 == math.pi)
mp.set_fp_type("float")
local encoded_2 = mp.pack(my_data)
local offset_2,decoded_2 = mp.unpack(encoded_2)
assert(offset_2 == 5) -- 1 byte overhead + 5 bytes float
assert(decoded_2 ~= math.pi) -- loss of precision
mp.set_fp_type("double") -- back to double precision
local encoded_3 = mp.pack(my_data)
local offset_3,decoded_3 = mp.unpack(encoded_3)
assert((offset_3 == 9) and (decoded_3 == math.pi))

Copyright

Copyright (c) 2011-2019 Pierre Chapuis

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].