chore(docs): update buffer.md

This commit is contained in:
khtsly 2026-02-16 17:27:07 +07:00
parent ff6a0c5cf4
commit 1200ff41f1

View file

@ -37,7 +37,8 @@ Define strict data schemas for optimized serialization and type safety.
"vector2", "vector2",
"vector3", "vector3",
"cframe", "cframe",
"color3", "color3", -- u8
"color3f16",
"instance", "instance",
-- other types -- other types
@ -48,6 +49,37 @@ Define strict data schemas for optimized serialization and type safety.
} }
``` ```
## Custom Datatypes
### `.custom_datatype`
::: code-group
```luau [Variable]
(
name: string,
object: { any },
writer: (w: Writer, v: any) -> (),
reader: (b: buffer, c: number, refs: { Instance }?) -> (buffer, number))
): Writer
```
```luau [Example]
local Buffer = Warp.Buffer()
-- # this custom datatype must be registered on both server & client side
Buffer.Schema.custom_datatype("u64", {}, function(writer, value)
-- writing u64 logics here
end, function(b, cursor, refs)
-- reading u64 logics here
return b, cursor
end)
local DataSchema = Buffer.Schema.struct({
LongInteger = Buffer.Schema.u64, -- use the custom datatype
})
```
:::
## Writer and Reader Functions ## Writer and Reader Functions
### `.createWriter` ### `.createWriter`