This repository has been archived on 2025-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
szun-old/README.md
2024-06-21 00:57:33 -07:00

2.6 KiB

Suzu Runtime / Notation

Szun is a library for defining, manipulating, and formatting structured, dynamic data.

Runtime

The Szun runtime provides an interface for constructing and modfying data objects.

Encoding

Szun uses a tag-prefixed, hierarchical, binary encoding with variable-sized values to produce serializations of reduced size.

Language

Szun notation provides a human-readable format for structures and data to be defined.
The notation may be parsed and loaded at runtime or compiled directly into encoded format.

Runtime Documentation

Data Types

Status Type Code Parameters Description
x None x00 -- No data
x Boolean x01 -- True or false
x Byte x04 -- 0-255
x Char x05 -- Unicode codepoint
x Natural x08 -- Non-negative integers
x Integer x09 -- Positive and negative whole numbers
x Decimal x0A mantissa Fixed-maginutide rational numbers
x Significant x0B -- Variable-magnitude rational numbers
x Complex x0C -- Complex number
x Range x0F min, max ...
x Block x10 size Constant-sized series of bytes
x Sequence x11 -- Variable-sized series of bytes
x Varying x20 -- Any data
x Optional x21 -- Data or None
x Array x21 size, type Constant-sized, indexed collection
x List x23 type Variable-sized, indexed collection
x Bag x24 type Variable-sized, indexed collection with repetition count
x Sparse x25 type Variable-sized, discontinuously indexed collection
x Trie x26 type Mapping of sequences onto data
x Map x26 key_type, data_type Mapping of data onto data
x Tree x26 type Collection of directed nodes
x Graph x26 data_type, edge_type Collection of nodes and edges
x Enum x7d schema Indexed enuemration of values
x Record x7e schema Instance of a schema
x Schema x7f -- Definition of abstract structure

Type Building

Global Functions

Binary Encoding

Encoding converts data between runtime memory and binary serialization.

encode(refer:Reference) -> Vec<u8>
encode_raw(refer:Reference) -> Vec<u8>
encode_tag(type_id:usize) -> Vec<u8>

Serializes an object into binary encoding.
The raw variant does not produce a tag prefix for the root object.
The tag variant only produces a tag prefix.


decode(data:&Vec<u8>, index:&mut usize) -> Result<Type,()>
decode_raw(data:&Vec<u8>, type_id:usize, index:&mut usize) -> Result<Type,()>
decode_tag(data:&Vec<u8>, index:&mut usize) -> Result<usize,()>

Parses a valid binary encoding and produces the represented object.
The raw variant does not decode a tag prefix on the root object.
The tag variant only decodes a tag prefix.