Skip to main content

Brine

Fast and efficient extensible serialiation and deserialization library for Roblox with native instance support out of the box

Functions

serialize

Brine.serialize(
dataInstance,
optionsBrineTypes.BrineOptions?
) → (
BrineTypes.Brined,
BrineTypes.References?
)

Serializes an instance into a string, with optional references

deserialize

Brine.deserialize(
dataBrineTypes.Brined,
optionsBrineTypes.BrineOptions?
) → Instance?

Deserializes a string into an instance, with optional references

observeSerialize

Brine.observeSerialize(
dataInstance,
optionsBrineTypes.BrineOptions?
) → Observable.Observable<BrineTypes.EncodedBrinePacket>

Observes changes to an instance

observeDeserialize

Brine.observeDeserialize(
observableStreamObservable.Observable<BrineTypes.EncodedBrinePacket>,
optionsBrineTypes.BrineOptions?
) → Observable.Observable<Instance>

Observes changes to an instance, returning deserialized instances

checkpoint

Brine.checkpoint(
rootInstance,
optionsBrineTypes.BrineOptions?
) → Checkpoint

Captures a baseline of root and its subtree. The returned checkpoint is what Brine.restore rewinds to, so capture it while the tree is in the state you want to be able to return to.

restore

Brine.restore(
rootInstance,
checkpointCheckpoint,
optionsRestoreOptions?
) → ()

Reconciles root back to checkpoint -- the rewind half of Brine. Survivors are patched in place (same instance, so external references stay valid); missing nodes are recreated and extra nodes removed (unless lifecycle = false). Idempotent: restoring an already-restored tree is a no-op.

Show raw api
{
    "functions": [
        {
            "name": "serialize",
            "desc": "Serializes an instance into a string, with optional references",
            "params": [
                {
                    "name": "data",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "BrineTypes.BrineOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BrineTypes.Brined"
                },
                {
                    "desc": "",
                    "lua_type": "BrineTypes.References?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 30,
                "path": "src/brine/src/Shared/Brine.lua"
            }
        },
        {
            "name": "deserialize",
            "desc": "Deserializes a string into an instance, with optional references",
            "params": [
                {
                    "name": "data",
                    "desc": "",
                    "lua_type": "BrineTypes.Brined"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "BrineTypes.BrineOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Instance?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 40,
                "path": "src/brine/src/Shared/Brine.lua"
            }
        },
        {
            "name": "observeSerialize",
            "desc": "Observes changes to an instance",
            "params": [
                {
                    "name": "data",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "BrineTypes.BrineOptions?\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable.Observable<BrineTypes.EncodedBrinePacket>\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 50,
                "path": "src/brine/src/Shared/Brine.lua"
            }
        },
        {
            "name": "observeDeserialize",
            "desc": "Observes changes to an instance, returning deserialized instances",
            "params": [
                {
                    "name": "observableStream",
                    "desc": "",
                    "lua_type": "Observable.Observable<BrineTypes.EncodedBrinePacket>"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "BrineTypes.BrineOptions?\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable.Observable<Instance>\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 234,
                "path": "src/brine/src/Shared/Brine.lua"
            }
        },
        {
            "name": "checkpoint",
            "desc": "Captures a baseline of `root` and its subtree. The returned checkpoint is what [Brine.restore]\nrewinds to, so capture it while the tree is in the state you want to be able to return to.",
            "params": [
                {
                    "name": "root",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "BrineTypes.BrineOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Checkpoint\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 381,
                "path": "src/brine/src/Shared/Brine.lua"
            }
        },
        {
            "name": "restore",
            "desc": "Reconciles `root` back to `checkpoint` -- the rewind half of Brine. Survivors are patched in\nplace (same instance, so external references stay valid); missing nodes are recreated and extra\nnodes removed (unless `lifecycle = false`). Idempotent: restoring an already-restored tree is a\nno-op.",
            "params": [
                {
                    "name": "root",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "checkpoint",
                    "desc": "",
                    "lua_type": "Checkpoint"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "RestoreOptions?"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 405,
                "path": "src/brine/src/Shared/Brine.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Brine",
    "desc": "Fast and efficient extensible serialiation and deserialization library for Roblox with native instance support out of the box",
    "source": {
        "line": 8,
        "path": "src/brine/src/Shared/Brine.lua"
    }
}