Server.decodeV2
luastra/serverServer.decodeV2(value: string): DecodeResult
Parses the deterministic bounded envelope returned by a schema-v2 operation into a discriminated DecodeResult. The generated operation decoder then validates result version, shape, types, and exact field consumption.
Before you use it
Add luastra/server to this module's dependencies in luastra.json, then import it with require("luastra/server"). Declare rpc.call in luastra.json and configure a declared backend operation with a deployed trusted handler. Application code should prefer its generated operation function and decoder.
How it fits
Server.decodeV2 synchronously checks the matching bounded success envelope; schema-v2 domain decoding remains operation-specific and generated.
When to use it
Prefer the generated operation decoder instead of reading Server.decodeV2 fields directly. Treat failure as an incompatible or untrusted result and leave domain state unchanged.
Parameters
| Parameter | Type / values | Description |
|---|---|---|
| value | string | Successful transport payload whose schema-v2 envelope and operation result must still be validated. |
Returns
DecodeResult — a discriminated decode result; branch on success before reading decoded fields or failure data.
What happens next
A tagged result containing result.fields or a bounded decode error.
Failures and fixes
Handle transport failure, envelope decode failure, and domain validation failure separately. The static web build does not deploy trusted backend handlers, credentials, or production operations for you.
Availability
Public-source alpha API in 0.5.0-alpha; production backend deployment remains application-owned.
Focused example
-- Prefer the operation-specific generated decoder. local decoded = Server.decodeV2(payload) if not decoded.success then status = "invalid" end