An informal Runtime Type Information crate.
#[derive(Debug)]
struct Example {
foo: Result<bool, i32>,
x: bool,
data: Vec<i32>,
map: HashMap<u8, bool>,
}
impl sir::Blade for Example {
sir::blade! {
struct Example where {},
foo: Result<bool, i32>,
x: bool,
data: Vec<i32>,
map: HashMap<u8, bool>,
}
}
There are these advantages over serde:
- Can be used with 3rd-party types: the orphan rule is not a problem.
- Interaction with different variations on a type (eg, renamed fields, older versions) can be accomodated by creating a new
Blade
. - Compile-time cost is
O(number of types)
rather thanO(number of types * number of serde clients)
. - Three speeds exposed to knights:
- Directly intepreting the RTTI for things rarely used (eg, debugging)
- Compiling to an efficient closure-VM at runtime for things that need to be faster.
- Using a traditional derive (eg of serde (or manual implementation)) for larger & more complicated types requiring bulk storage, like
Vec<Triangle>
.
Our equivalents of eg serde_json
are called Knights. The brave knights of this repository are:
- Sir Vey. Debug printing.
- Sir Mun. Deserializes rlua objects.
- Sir Mark. Serializes to lua source code.
- Sir Eel. Serializes and Deserializes using
crate:bincode
.
(crates:sir
is already taken; this will have to be renamed if it ever ends up there.)