← Server functions

Server.DecodeResult

luastra/server

Server.DecodeResult is a discriminated union covering successful output and bounded failure. Branching on success narrows the value to the correct exported record and makes error handling explicit.

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

The type describes request options, v2 limits, nullable values, public errors, or the tagged envelope-decoding result.

When to use it

Use Server.DecodeResult at the boundary where untrusted or versioned input is decoded. Branch on result.success before reading value or error so both outcomes remain explicit and type-safe.

Fields or definition

ParameterType / valuesDescription
definitionDecodeSuccess | DecodeFailureExact alias, union, or callable contract represented by Server.DecodeResult.

Error codes

This is the complete closed vocabulary emitted by the named operation in this Source SDK contract.

CodeWhen it occurs
invalid_sizeThe wire payload is empty, not a string, or larger than 4096 bytes.
invalid_versionThe wire payload does not declare protocol version v=1.
malformedA field token is missing its name/value separator.
invalid_fieldA field name, value encoding, or duplicate field is invalid.
too_many_fieldsThe wire payload contains more than 128 fields.

SDK type flow

Produced by

Server.decodeServer.decodeV2

What happens next

A checked request, result, limit, nullable-value, or public-error annotation.

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.

Exact declaration

export type DecodeResult = DecodeSuccess | DecodeFailure

Continue learning

Prerequisites

Server.DecodeSuccessServer.decode

Next steps

Server.decodeV2

Complete inventory

View all pages in Server functions
← Previous: Server.DecodeFailureNext: Server.Nullable →