| Crates.io | simplerecords |
| lib.rs | simplerecords |
| version | 0.1.1 |
| created_at | 2025-03-09 16:58:59.976871+00 |
| updated_at | 2025-03-17 21:26:37.72206+00 |
| description | Strongly typed text-based format for declarative configuration with zero dependencies. |
| homepage | |
| repository | https://github.com/siriusmart/simplerecords |
| max_upload_size | |
| id | 1585639 |
| size | 101,580 |
Strongly typed text-based format for declarative configuration.
[dependencies]
simplerecords = "0.1"
Here are some reasons to use Simple Records.
Comments are ignored.
#/* */# username IP expiry
Definition define the record type.
# v--- unsigned string v--- 64 bit unsigned integer
whitelist: ustr istr u64
# ^--- signed string
Record has a type and fields.
whitelist joe 127.0.0.1 123456
whitelist bob 127.0.0.1 123457
whitelist alice 127.0.0.3 123459
Import additional rule files.
include filename
The default file extension if none specified, is
*.rules.
Definition and rules can be in any file and in any order, as long as it exists.
use simplerecords::*;
let doc = Document::read("whitelist") // reads from whitelist.rules
* '127.0.0.1' *.let filter = Filter::new("whitelist", &[None, Some("127.0.0.1"), None])
let found = doc.find(filter);
(whitelist@3) whitelist "joe" "127.0.0.1" 123456
(whitelist@4) whitelist "bob" "127.0.0.1" 123457
You can read a single document from multiple files.
let doc = Options::default()
// specify files to load from
.with("include users")
.with("include permissions")
.open();
Sections of the file can be labelled for organisation.
scope friends # joe and bob are in the 'friends' scope
whitelist joe 127.0.0.1 123456
whitelist bob 127.0.0.1 123457
scope members # alice is in the 'members' scope
whitelist alice 127.0.0.3 123459
scope # reset scopes
whitelist sirius 127.0.0.5 123451
The examples above can be found in src/examples.
| Type | Description |
|---|---|
| char | A single character |
| i8 | An integer value between -128 and 127 |
| u8 | An integer value between 0 and 255 |
| i16 | An integer value between -32k and 32k |
| u16 | An integer value between 0 and 65k |
| i32 | An integer value between -2.1B and 2.1B |
| u32 | An integer value between 0 and 4.2B |
| i64 | You get the idea |
| u64 | You get the idea |
| f32 | 32 bit floating number. |
| f64 | 64 bit floating number. |
| istr | Case sensitive string. |
| ustr | Case insensitive string. |
| bool | Boolean value. |
All current features are stable and there will be no breaking changes.
New features will be added until this becomes a text-based database. Including
doc.filter(filter![*, "127.0.0.1", *])