-
Notifications
You must be signed in to change notification settings - Fork 10
Deduplicate the logic behind PreKeyStore and SignedPreKeyStore #5
Comments
Maybe using a macro to generate the code for both? gen_key_store!(PreKeyStore);
gen_key_store!(SignedPreKeyStore); What do you think about this? |
I'm not sure how it'd work out. The |
In fact, i don't love the notion of as we are working on that implementation, we need to provide a high-level ergonomic rust-ish api for that lib, because eventually i would love to see it written in pure rust, see (shekohex/libsignal-protocol-rs#1), but as i'm working, i had realized that it's hard to achieve that from the start, so making a So Here i would suggest to make this api something like: pub trait PreKeyStore {
fn load(&self, pre_key_id: u32) -> Result<&PreKeyRecord, InternalError>;
fn store(&mut self, pre_key_id: u32, record: &PreKeyRecord) -> Result<(), InternalError>;
fn contain(&self, pre_key_id: u32) -> bool;
fn remove(&mut self, pre_key_id: u32) -> Result<(), InternalError>;
} What do you think ? |
Ooh, I didn't notice you'd already worked with
I agree that having an idiomatic API is a must-have, although we may need to do some iterating as the crate gets used in real-world scenarios to decide what exactly idiomatic looks like. In this case, even though something like The reason I originally chose to use the
The user definitely needs to be able to use a I hope it doesn't sound like I'm getting defensive here, I'm just trying to explain the logic behind doing funny-looking things like |
That's Seems fair to me, the main reason for writing these high-level api, when i was working on native and pure rust implantation was by seeing how the java implementation doing that, so java has other native implementation with very high-level api, it has the same api like the c is, but with other cool things like we did in the rust side (eg. they make all the store thing as interfaces and they using builder pattern everywhere, with getters and setters.), when i stooped working in rust implementation ( the lack of my free time), i realized that maybe it would be nice to make the ffi bindgen first, but my knowledge of c <-> rust isn't enough to make this happen, so i made a poll on twitter asking rust community about that case, that's where i found your repo :) |
These two vtables are identical, modulo the
signed_
prefix. For now I've done a straight copy/paste, but it'd be nice if we can unify the two and skip the extra effort.Note: The original FIXME for this was removed in 11d22b9
The text was updated successfully, but these errors were encountered: