Derive Macro for rust
Hey folks, I'm Sevki, I'm new here and I've been working on a typedb macro, I've already posted it to the forums https://forum.typedb.com/t/derive-macro-for-rust/701 , like I said, I'm super new so if anyone wants to help me out I would really apprecitate it
Discussion Forum
Derive Macro for rust
Hi folks, I’m Sevki, I’m new here. I have been searching for a more rusty™️ way to generate schemas. something like, #[derive(Relation)] enum Employment { #[role] Employee, #[role] Employer, } // Rust code #[derive(Entity)] #[abs] pub struct Person { #[key] email: String, #[owns] full_name: String, ...
9 Replies
That's super interesting and similar to what @Joshua (and @dmitrii? ) have been thinking about. We'll be happy to answer any TypeQL questions you may have in this thread.
I've struggled to wrap my head around fitting relations into rust.
I'm curious why you've not re-used the
struct Person
for struct PersonAnswer
.@krishnan That's very kind of you. I'm currently in a very exploratory state. I don't really have a nice way to map PERA concepts to rust idioms. So I'm trying a bunch of things to see what feels more natural.
Hey folks, I've got a poc for this... https://github.com/sevki/typedb-model/blob/main/tests/integration_tests.rs it's not polished or anything of the sort. still very early days and still trying to figure out what the user experience should be.
GitHub
typedb-model/tests/integration_tests.rs at main · sevki/typedb-model
TypeDB model generation from with Rust macros. Contribute to sevki/typedb-model development by creating an account on GitHub.
ok taking a look @sevki sorry been super busy!
@Joshua actually please don't. that implementation is absolute shite. and turns out I was making things super hard for my self. I rewrote the entire thing in a couple of lines of datalog. what an idiot I was two days ago.
I literally wrote a couple of fmts for the defineables to make these
into these
and it worked surprisingly well.
so now i can do write stuff like this
ah nice it even runs on the web https://dub.sh/2dIlb9L
Nemo Rule Engine - Web Browser IDE
Try Nemo online in your Web Browser: Nemo is a datalog-based rule engine for fast and scalable analytic data processing in memory.
how does this work with the rus tmacro?
super curious to see where you take it @sevki !
I thought i saw a notification you sent about how you did it but i can't find it now @sevki !!
Hey @joshua I hadn't. Almost finished my rewrite and I really like this version better. I'll publish it this week 🙂
thanks, im excited @sevki !