-
-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docstrings for 7 more Rust API modules #287
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many comments, apologies for the onslaught. :-)
rust/protocol/src/consts.rs
Outdated
pub const MAX_RECEIVER_CHAINS: usize = 5; | ||
pub const ARCHIVED_STATES_MAX_LENGTH: usize = 40; | ||
pub const MAX_SENDER_KEY_STATES: usize = 5; | ||
//! Magic numbers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think any of these types or values need to be made public. That doesn't mean it's not worth documenting them, but I'm more inclined to filter them back into the relevant files that reference them than add more structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! I have marked both of crate::consts::{types,limits}
as pub(crate)
in 2ff52da. Does that address your concern? I think that the tiny little module structure here is useful for documentation of these values. If you're not seeing it, we can totally do away with that as well though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still tend to prefer keeping types and constants close to their primary use site, but clearly the code isn't doing that today. I'll come back to this.
rust/protocol/src/storage/traits.rs
Outdated
@@ -62,6 +85,7 @@ pub trait PreKeyStore { | |||
async fn remove_pre_key(&mut self, prekey_id: PreKeyId, ctx: Context) -> Result<()>; | |||
} | |||
|
|||
/// Interface for storing signed pre-keys downloaded from a server. (TODO: ???) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll come back with an explanation of pre-keys and signed pre-keys later; for now feel free to leave this generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[marking this unresolved so I'm less likely to forget about it]
cc @gferon and @boxdot, thanks for the heads up @jrose-signal. @cosmicexplorer You may be interested in the libraries and work at https://github.com/whisperfish. Feel free to join our Matrix channel to coordinate some other work; we are planning to submit some PRs into here wrt. some crypto code. Cfr also #152. @jrose-signal would you appreciate a review from me and Gabriel on #286 and this one? I'm not sure whether we can catch any more than you already did, but I'd rather ask whether it'd be appreciated or not. |
I think it's reasonable for multiple perspectives, but I don't want to stress out @cosmicexplorer either. @cosmicexplorer, what do you think? |
5dcfd7d
to
2ff52da
Compare
I'd be wholly unstressed for people to give this a more thorough review! |
Thanks for working on this! And yes please join us in the Whisperfish Matrix room at #whisperfish:rubdos.be. I'm not sure what your goal is with using this library, but we're working towards a GUI client written in Rust and QML with the qmetaobject-rs crate. Currently Whisperfish uses Jolla's proprietary QML libraries so it only works on Sailfish OS, but I just got a PinePhone so I'll be working on adapting it to also work with KDE's Kirigami QML libraries without Sailfish OS. At the moment Whisperfish only supports text messages and GroupsV2 but we intend to make it feature complete. I presume you're probably writing a Signal client, in which case you'll probably be interested in the libsignal-service-rs library which now uses this libsignal-client library. @gferon is also working on using libsignal-service-rs for CLI clients and bots with Presage. |
54dbdd7
to
eea8618
Compare
@Be-ing I'm working on what should become a CLI tool very analogous to I can see there are already a lot of extensions in the whisperfish org you linked above, so I'm seeing whether any of those solve more problems I thought I had. |
e46ceca
to
f649b9a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already such an improvement! Thanks for taking this on ❤️
I've added 22 comments; most of them are really nit-picky. I figured, if we're doing this, let's do this the best we can already.
rust/protocol/src/storage/traits.rs
Outdated
// SPDX-License-Identifier: AGPL-3.0-only | ||
// | ||
|
||
//! Traits defining several stores used throughout the Signal Protocol. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a word about the usage of async-trait
, including the fact that it's async_trait(?Send)
. Maybe some example/dummy implementation would be really great here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly the ?Send
part has been a bit weird in practice; probably these should all require Send after all. That means newtype-ing Context but that's also a good idea.
*cough* but that's for another PR. I agree that some mention of async-trait
is a good idea if only so people know that they have to use that when implementing the traits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started to look into having the store traits require Send
, just to see how far I could go, would you mind if I open an issue so that we can discuss it in more details there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gferon That sounds great, thank you!
eeddf75
to
201a3fb
Compare
d91b9fe
to
718d70c
Compare
7b96a07
to
ab70e19
Compare
59efa3a
to
19e11fe
Compare
- requires the `unstable_internals` feature to be enabled for doctests to work
- [NON RUST/RENAME] rename "DJB_TYPE" to "CURVE_25519_TYPE" in java and swift - [1+CRYPTO CRATE] make swift/build-ffi.sh --generate-ffi work - [1+CURVE] add docs and the Keyed trait to `curve*.rs`
This is the second in a set of planned PRs to add docstrings to the Rust API, see #285.
I took care to make these changes highly orthogonal, and have split each module's changes into its own commit.
Notably, this does not depend on #286!