Okserializer - yet another ok schema-based buffer serializer

What’s up guys,

Recently I felt like reinventing the wheel, so I decided to bring absolutely nothing new to the table by creating yet another schema-based serializer. (atleast it’s not a signal module, okay?!)

okserializer is a low-abstraction, schema-based Luau buffer serializer, I haven’t exactly tested how well it performs, since that wasn’t really my goal for this project. I mostly just made this for myself as a sort of excercise for bit-manipulation and buffers in Luau.

You may be asking, “What makes okserializer different from all the other way faster and performant serializers out there?” and to be honest, not much. It’s just your stereotypical schema based serializer. I could try to save face and say it’s the fact that it’s incredibly modular and also insanely intuitive, buttt that’s not exactly my goal tonight.

Here’s a small example of how okserializer can be used (demonstrating the struct, string and number schemas)

local okserializer = require "path/to/okserializer"
local Schemas = okserializer.Schemas

local person_schema = Schemas.struct {
	name = Schemas.string "u8",
	last_name = Schemas.string "u8",
	age = Schemas.number "u8",
}

local example_person = {
	name = "John",
	last_name = "Doe",
	age = 19,
}

local serialized = person_schema:serialize(example_person)

print(buffer.len(serialized)) --> 10

local deserialized = person_schema:deserialize(serialized)

assert(example_person.name == deserialized.name)
assert(example_person.last_name == deserialized.last_name)
assert(example_person.age == deserialized.age)

There’s like way more Schemas available to you in okserializer, I don’t think it’s possible to showcase every single one here though…

Anyway that’s all really, what were you expecting? It’s just a simple buffer serialization module.

You can find the github repository (as well as any releases with .rbxms) here.

Feel free to contribute to okserializer by opening pull requests on the repository.
Any feedback is also appreciated, I guess :coefficients:

2 Likes

Love the honesty, and I tried making one myself but ended up forgetting about it. W module tho

1 Like