SML
SML
is a simple markup language. It is designed to convert human readable information into
Rust data-structures.
Note: The API is very far from stable. In fact everything is very far from stable. I'm working on the serialization side of things now (1st April 2019). Any version that is 0.1.x can be considered pretty much unusable.
The format looks this,
hobbit:
name: "Frodo Baggins"
age: "98"
friends:
hobbit:
name: "Bilbo Baggins"
age: "176"
hobbit:
name: "Samwise Gamgee"
age: "66"
Data Format Rules
-
Indentation has meaning and is 4 spaces, relative to the top key.
-
All values must be double quoted.
-
Every key/value combination must be nested in a key. For example
hobbit: "Frodo"
by itself is invalid. It can be written:
hobbit:
name: "Frodo"
The motivation behind this is for the data format to distinguish clearly between whole data structures, which are headed by a key only, and parts of a data structure which are either key/value pairs, representing fields or variants, or other data-structures, which again are headed by a key only.
-
Separation of lines has meaning.
-
Keys may not include
:
. -
Double quotes in values must be escaped using
\"
. -
Everything after the second double quote is ignored (and can be used for commenting).
-
Empty lines or lines with whitespace only are ignored.
Basic Organization
ToSmall
trait to_string()
---> --->
------------- ----------- ----------
| data- | | Small | | String |
| structure | | | | |
------------- ----------- ----------
<--- <---
FromSmall from_str()
trait
Example
To convert from Small
to a data-structure,
use ;
and to convert from a data-structure to Small
,
use ;
println!;
// hobbit:
// name: "Frodo Baggins"
// age: "98"
// friends:
// hobbit:
// name: "Bilbo Baggins"
// age: "176"
// hobbit:
// name: "Samwise Gamgee"
// age: "66"