![entity: rustc 1.46+]
![entity_macros: rustc 1.46+]
A simplistic framework based on TAO, Facebook's distributed database for Social Graph.
Requires Rust 1.46+. Without entity_macros
, may compile and run for
older versions of Rust.
Import Entity into your project by adding the following line to your
Cargo.toml. entity_macros
contains the macros needed to derive and/or
transform your data to be compatible with supported databases and queries.
toml
[dependencies]
entity = "0.1"
For most use cases, you can import all features using the full
flag, or for
a more tailored experience can import individual features:
toml
[dependencies]
entity = { version = "0.1", features = ["global", "macros", "inmemory_db"] }
```rust use entity::*;
struct User { name: String, age: u8,
#[ent(edge)]
friends: Vec<User>,
} ```
Entity provides a few feature flags:
full
- Enables all features.global
- Enables use of a database stored as a global variable,
providing shortcuts in creating and retrieving ents.macros
- Enables macros for deriving ents and exposing a cleaner
declarative API for ents. (Imports entity_macros
directly)inmemory_db
- Enables the in-memory database for use with ent objects.
This does not bring in serde-1
by default, but including that feature will
also support persisting the database to the filesystem.sled_db
- Enables the sled database for use with ent objects. Because
of the nature of sled, this will also pull in serde-1
.serde-1
- Provides serde serialization module and associated functionality for ents
through the use of typetag. This will
require that all ents implement Serialize
and Deserialize.
serde
and typetag
to be included in dependencies.