Forest Logo
search
package_2

bufferizer

By @bajsucks

Roblox

Mirrored from Wally

Bufferizer

Light, zero-dependency Luau SerDes library for homogeneous arrays.

Install with Wally: Add "bajsucks/bufferizer@^0.1.0" to your wally.toml and run wally install.

Install manually: Download the latest .rbxm release from Releases, or build from source via rojo build

Use cases

  • Networking and replication (especially ECS)
  • Data saves, I guess?

Usage

Bufferizer.Encode<T>(Payload: {T}, Schema: Schema<T>): buffer
Bufferizer.Decode<T>(buffer, Schema: Schema<T>): {T}
Bufferizer.schemas: {Schema<any>} -- out-of-the-box schemas
Bufferizer.primitives.types: {any} -- primitive number types (u8, i16, f32, etc.)

Out-of-the-box schemas:

  • Vector2
  • Vector3
  • CFrame
  • Color3
  • UDim
  • UDim2
  • number (f64)
  • jecs_id (i24)

Defining new schemas

If you want a custom type, you will have to create a schema. For example, Vector3 schema:

-- p = Bufferizer.primitives.types
Bufferizer.Schema(
	{ p.f32, p.f32, p.f32 }, -- `map`, maps the primitives returned by `encode`
	function(v: Vector3) -- `encode`, converts the type into primitives
		return v.X, v.Y, v.Z
	end,
	Vector3.new -- `decode` converts the primitives back into the type
)

It's as simple as that!

You can also skip encode/decode for pure primitives:

-- p = Bufferizer.primitives.types
Bufferizer.Schema( -- Luau number
	{ p.f64 },
)

Package Details

Install command (Click to copy)


Version

0.1.3

License

Apache-2.0

check_circle

Safe for commercial use

infoModified files must carry a notice of changes. If the package ships a NOTICE file, its attributions must be preserved.

infoLicense identified from the packaged LICENSE file; the manifest declared none.

Automated license review — not legal advice.