Yay, my first post! I really don't know what to put here and don't really care that much, because the intent of this blog was never to be perfect; it was to get my ideas out instead of delaying day after day, week after week, month after month, year after year. So here goes.
For the past month-ish (though most of it has been me procrastinating, or as I like to call it, "thinking about my design decisions"), I have been working on this super simple project that should have been done ages ago: Deebee, a graph database engine with no DSL written in Rust and the only dependency being the lightweight uuid crate (bring your own Serde if you really wanna store your structs in here). I originally wrote it in Python for an MVP to see if the design could work, and it seemed to be fine (but I'm still not sure), so I decided to rewrite and overhaul it in Rust. As my README says, Deebee consists of only four primitives: the Graph, storing nodes, the Node, storing values and connecting to other nodes, the Arrow, the connection to the other nodes, and the Value, dynamic data stored by the Node. I'm not gonna get too into the technical details, as you can see the repository for yourself, and besides, this is a post about my actual experience developing the project for the past week or so, not an ad.
Anyways, I'm not gonna store the database in memory forever or just put things in an unreadable binary (looking at you, Redis), so I started work on a to_json and from_json, but I decided to make it hard for myself because I pledged to keep Serde far, far away from Deebee, because do I really need it for just two methods? And no miniserde or nanoserde or whatever either. I have my one Value enum; that should be not too hard, right?
Usually you're supposed to say "no" and subvert expectations and stuff, but this isn't a fictional story with a plot and everything. So first, dumb me forgot to impl the From traits so that I could Into the data passed to new into Value super easily, so I quickly did that. I then started work on the to_json, using a simple match for all the variants of Value, until I realized that apparently JSON doesn't have NaN and Infinity for numbers, unlike Rust. Okay, not too much of a problem although annoying, and I have to do these weird format macros that seem kinda hacky to convert the data types into string representations to get a JSON string. For List and Map variants, I had to do a quick little recursive serialization thing by doing a map on the iter of the value and collecting that into a Vec and joining it comma-separated back into a String. But I also have to escape all Strings because if you just put the text back into JSON, things like the literal text "\n" would be interpreted as the special "\n" newline, so I just had Claude do the escaping stuff, because me super lazy.
This wraps up the problem of the serializer; it's not really that satisfying or anything, but treat this like a dev progress report, not a full thing. Next, I need to write the deserializer, write the search, find, and delete methods on Node, and implement Display, Iterator, and IntoIterator, all while keeping Deebee under 500 lines. Doesn't seem too hard!
Top comments (0)