Crypt Configuration files
A modern readable file format.
Crypt files are similar to json with additional support for enums special tags, identifiers, and includes. Crypt is essentially a superset of json meaning any json file can parsed as if it was a crypt file. Using the beauty of Rust crypt files can be parsed directly into rust native structs and enums using the Cryptic derivation.
Why did I make Crypt
tbh idk
Example crypt file
name = "John doe",
age: 34,
"description": "An unkown patient",
Most notably : and = can both be used to show ownership. Identifiers and strings can both be used interchangeably to represent an owner. Unlike json the main {...} can be ignored but will automatically be promoted to the main body if present.
{
objects: {
"can": {
be: {
nested: ["indefinitely"]
}
}
}
}
Crypt also has special tags that can be added to a file. Tags come in two valid formats.
#format=A
"format a": {
},
#(format=B, more)
"format B": {
}
Using #(...) allows for multiple tags. If an object only expects on tag but and this syntax is used it will only consume the first item.
Loading a crypt file
To parse a crypt file a CryptParserServer is used which automatically caches opened files and reuses them when requested.
use ;
// The Crypt macro will automatically implement
// conversion from a crypt file.
let mut server = new;
let my_person: Person = server.open?;
Enum Objects
Special tags also have the benefit of being able to tell the variant of an enum. Crypt derive macro is also available for enums and require the type to be tagged with the variant and it will do the rest.
Now creating the type in crypt:
ok_result: #Ok "Perfect",
err_result: #Err { message: "Failed to to something" },
undefined_result: #Undefined[],
The object after the tag will automatically be converted into the arguments of the variant. Regardless an object must be present following the tag for it to be valid.
ok_result: #Ok 30,
err_result: #Err message: null,
undefined_result: #Undefined null,
Include other files
The !import keyword can be used to import objects from other crypt of json files.
my_obj: {
A: "something",
B: !import "path/to/other.crypt"
}
Working on:
There are a few additions that are planned for future versions.
Comments
As of right not crypt has no form of comments. It is likely that the > will be used to mark a comment.
Rust -> Crypt
Crypt can be easily converted into Rust structs but Rust structs can't be formatted into Crypt files. This will likely be implemented similar to Cryptic and will be called Cryptograph.
v0.2.2
Updated to oaken v0.2.0. This is a very crude update but it doesn't change anything about the functionality.