Rust Object Format (.rof)

Rust object format allows rust objects to be serialized to a file in a text format very closely resembling the original object. It also allows easy transfer of objects between different programming langauges, as the objects can be created in their respective language, serialized to string, send to another language, deserialzed and used once again.

TL;DR A library that can serialize and deserialize rust objects to string which allows simple file saving and transmission of rust objects between separate programming languages.

Table of contents

Design Goals
Language
Rust Library Docs
JS Library Docs

Design Goals

Use case

Language

Structs

Encapsulated by a pair of curly brackets

js { title: string = "Ferris the crab"; }

Each object property is defined as follows, and always ended by a semicolon.

propertyname: _propertytype_ = propertyvalue_;

propertyname_ = propertyvalue_;

Simple Property Types

A simple property type only includes a base type

Boolean Types

type annotation optional, can be implied

rust is_swimming: bool = false;

Text Types

type annotation optional, can be implied

Number Types

All integer type values are written the same

All floating type values are written the same

type annotation mandatory, cannot be implied

Complex Property Types

A complex/compound property includes a base type along with x number of sub types which can be mix of simple and complex property types

Tuples and Arrays

type annotation optional if tuple parameter types are optional

type annotation optional if array object type is optional

Structs and Hashmaps

rust passwords: hashmap<u16, string> = { 739341: "abc123", 210405: "football32", 826135: "dragon97" };

type annotation optional if hashmap key and value object types are optional

rust passwords = { 739341: string = "abc123", "210405": string = "football32", 826135: enum<string> = None; };

Hashmaps and structs are not interchangeable as there are some key differences

Type annotation mandatory; If you want your data to be loaded in as a hashmap, then you must annotate the value as a hashmap, or it will be loaded in as a struct, and vice-versa.

Enums


rust enum action { IDLE, SLEEPING, JUMP(f64 /* jump power */), RUN(f64 /* x-velocity */, f64 /* y-velocity */), EAT(String /* food item */), }

Type annotation optional if enum parameter types are optional

The keyword "option" can also be used to subsitute "enum" and works exactly the same as the "enum" keyword; When using option enums you can then use the "option" keyword instead of "enum" to make it more readable. The "option" keyword will work fine for any other enum types, but is strongly discouraged.

Formatting

js { title: string = "Ferris the crab"; age: usize = 25; favourite_color: enum = ORANGE; accessories: array<enum<usize>> = [ SUNGLASSES(3), GOLDEN_SHOES(1) ]; }

Rust Library Documentation

Javascript Library Documentation