Skip to content

Data Types

Current ASUN schema names are intentionally small and fixed. The only scalar schema names are:

  • int
  • float
  • str
  • bool

Scalar Types

ASUN typeExampleNotes
int42, -100, 0Any i64-range integer
float3.14, -0.5, 1e10Floating-point text form
booltrue, falseLowercase only
str (unquoted)Alice SmithOuter whitespace is trimmed
str (quoted)" spaces "Preserves whitespace and supports escapes
null / None(empty slot)Empty between commas

Composite Types

Nested Struct

asun
{id@int, address@{city@str, zip@str}}:(
  1,
  (Berlin, 10115)
)

Array / List

asun
{id@int, tags@[str]}:(1, [rust, go, wasm])

Arrays can be nested:

asun
[{matrix@[[int]]}]:
  ([[1, 2], [3, 4]]),
  ([[5, 6], [7, 8]])

Entry List

Keyed collections use an array of entry structs:

asun
{attrs@[{key@str, value@int}]}:([(age, 30), (score, 95)])

Option / Nullable

An empty slot means null / None:

asun
[{id@int, score@float}]:
  (1, 9.5),
  (2,    )

Cross-Language Type Mapping

ASUN typeRustGoPythonJava / KotlinSwiftCC++ZigC#DartJS / TSPHP
inti64int64intlong / LongInt64int64_tint64_ti64longintnumber (integer)int
floatf64float64floatdouble / DoubleDoubledoubledoublef64doubledoublenumberfloat
boolboolboolboolboolean / BooleanBoolboolboolboolboolboolbooleanbool
strString / &strstringstrStringStringchar* / buffer fieldstd::string[]const u8stringStringstringstring
null / empty slotOption<T>nil / pointer / empty slotNonenullable field / empty slotnil / optionalnullable pointer / empty slotstd::optional<T> / empty slot?Tnullable reference / nullable valuenullnull / undefinednull
[T]Vec<T>[]TlistList<T>[T]array / repeated rows with schemastd::vector<T>[]TList<T> / arrayList<T>T[]indexed array
nested structstructstructdict / object factory resultclass / data classAsunValue.object / host modelstruct + schema descriptorstruct + metadata macrosstructclass / record implementing schema interfaceclass implementing AsunSchemaplain objectassociative array / object-like array

Notes

  • ASUN schema names stay the same in every language: only int, float, bool, str.
  • A host language may use a different concrete type name for the same ASUN scalar. For example, Java uses double for float, and Zig commonly maps str to []const u8.
  • JS / TS only has one numeric runtime type, so int means “a number that is encoded as an integer”.
  • Keyed collections use entry lists such as [{key@str,value@str}].

Language Support Overview

LanguageMinimum versionImplementation styleText decode expectsBinary decode expects
RustRust 1.85+serde-based generic codectarget type Ttarget type T
GoGo 1.24+reflection + struct tagsoutput pointeroutput pointer
PythonPython 3.8+compiled C++ extension over Python dict/list valuesself-describing text, returns Python objectsexplicit schema string
Java / KotlinJava 21+, Kotlin helper layer on 1.9+ toolchainreflection + annotations + class metadatatarget Class<T> or Kotlin reified helpertarget Class<T> / Kotlin reified helper
SwiftSwift tools 5.9+native Swift value model around AsunValueself-describing text, returns AsunValueself-describing binary, returns AsunValue
CC11explicit schema descriptors / macrosschema descriptor + output bufferschema descriptor + output buffer
C++C++17template metadata macros (ASUN_FIELDS, ASUN_TYPES)target type Ttarget type T
ZigZig 0.15.2+comptime type introspectiontarget type T + allocatortarget type T + allocator
C#.NET 8+ (net8.0, net10.0)IAsunSchema + factory-based typed decodefield bag or factory functionfield names + field types + factory
DartDart 3.0+AsunSchema interface + factory-based typed decodefield bag or factory functionfield names + field types + factory
JS / TSES2020-capable runtimeruntime object inspectionself-describing text, returns plain objectsexplicit schema string
PHPPHP 8.4+native C++ extension over arrays / zvalsself-describing text, returns arraysexplicit schema argument

Reading the matrix

  • Text ASUN carries its schema in the header, so many dynamic-language implementations can decode it without an external type definition.
  • Binary ASUN is intentionally not self-describing. Most implementations therefore need either:
    • a target type,
    • a schema descriptor,
    • or an explicit schema string.
  • Swift is the main exception in the current repository: its binary API carries enough typed information to round-trip directly into AsunValue.
  • “Implementation style” explains how each language maps host-language data to the common ASUN text and binary formats. The wire format stays the same across languages.

Binary Note

ASUN-BIN may use fixed-width host-language primitives internally, but those widths are not extra schema names.

  • The public schema still only uses int, float, bool, and str.
  • Binary encoding is little-endian across the official implementations.
  • Fixed-width storage details belong to the binary codec implementation, not to the schema surface.

Released under the MIT License.