Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Rust API Guidelines compliance (#383)
* Use impl Trait for Secure Comparator * Drop outdated TODOs We already handle errors in Secure Cell in acceptable way, there is no need to panic. Similarly, Secure Comparator has good enough usage pattern with "is_complete()" so we don't have to handle completion differently. * Use impl Trait for key types * Fix typos in API docs * Reorder Secure Comparator methods for better API docs * Add Debug implementation for all public types * Remove Clone implementation from Secure Message types They do not really need to be copyable (like Secure Cells). If you need to have use Secure Messages with the same keys then construct it twice. However, this should not be necessary in the first place. * Rename getter for remote peer ID Rust generally does not use "get" prefixes for getters. Furthermore, at some distant point we may want to add a getter for our own ID so give this method a better name. While we're here, I have noticed that the documentation comment lies. This method should properly handle the case where peer ID is not known. Peer IDs can't be empty so an empty result from underlying function secure_session_get_remote_id() means that there is no peer ID stored (i.e., the connection has not been negotiated yet). * Rename getter for comparison result Similarly, rename the getter without a "get" prefix because Rust APIs prefer such naming. * Unsafe impl Send for pointer types Rust cannot automatically infer thread-safety traits for types which use raw pointers. Secure Session and Secure Comparator are actually movable across threads, but not safe for concurrent usage. Reflect this by implementing Send but not Sync. * Use ? operator instead of unwrap in API examples Code snippets from documentation tend to be copy-pasted verbatim so take care to avoid unexpected panics.
- Loading branch information
Showing
8 changed files
with
91 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.