Crates.io | aeon |
lib.rs | aeon |
version | 0.3.1 |
source | src |
created_at | 2020-09-22 00:55:33.213166 |
updated_at | 2022-05-18 18:01:56.764043 |
description | A configuration file format with macros for brevity. |
homepage | |
repository | https://github.com/Szune/aeon-rs |
max_upload_size | |
id | 291372 |
size | 63,438 |
⚠ Works, but isn't production ready
Awfully exciting object notation
@server(id, name, ip, port)
servers: [
server(1, "test", 127.0.0.1, 7171),
server(2, "production", 0.0.0.0, 8080),
]
/* using derive macro */
use aeon::convert_panic::*;
use aeon::*;
use aeon_derive::{Deserialize,Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct Heuristic{
pub value: String,
pub weight: i32,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct WithHeuristics {
pub something: Vec<Heuristic>,
pub else: bool,
}
// deserialize:
let heuristics = WithHeuristics::from_aeon(some aeon string here);
// serialize:
println!("{}", WithHeuristics::to_aeon(&heuristics));
// would print something similar to:
/*
@heuristic(value, weight)
something: [
heuristic("some_name", 10),
heuristic("some_other_name", 19),
]
else: false
*/
/* typing it out manually */
use aeon::*;
use aeon::convert_panic::*; // there's also aeon::convert::* if you prefer Option<T> over panics
let servers = aeon::deserialize(data).get("servers").list();
println!("{:?}", servers);
// there's also get_path("path/to/value") functions
Comments start with a '#' symbol.
# comments are allowed on their own lines
thing: "text" # and at the end of lines
Comments are not serialized when performing deserializing -> serializing, this may change in the future
Macros are parsed as HashMap<String, AeonValue>.
Macros start with an '@' symbol, followed by an identifier and a list of arguments.
E.g. @identifier(argument1, argument2, argument3)
Macros need to be defined before they are used, preferably at the start of the file, before any variables.
Macro identifiers can also be used as variable identifiers.