Abstraction for serializing database keys
We have a whole bunch of database keys that are of the form key_a + 0xFF + key_b + 0xFF + ...
. Every single time we construct these keys we do it in the most manual way possible:
let mut roomuser_id = room_id.as_bytes().to_vec();
roomuser_id.push(0xFF);
roomuser_id.extend_from_slice(user_id.as_bytes());
let mut userroom_id = user_id.as_bytes().to_vec();
userroom_id.push(0xFF);
userroom_id.extend_from_slice(room_id.as_bytes());
This is very silly, and has caused at least one completely avoidable bug.
Instead, we should have actual type definitions for the keys, with an as_bytes
method or similar, so that all the serialization logic lives in one place.