-
Notifications
You must be signed in to change notification settings - Fork 248
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
Improve documentation #340
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
269bde0
Remove unnecessary capitalisation
tcharding 5e07e75
Add period to sentences
tcharding c3be285
Fix size constant docs
tcharding d25431c
Use 3rd person tense for function docs
tcharding f5e68f3
Add ticks around code snippet
tcharding 3fa6762
Add link to referenced commit
tcharding c9e6ca1
Use rust-bitcoin module doc style
tcharding f95e91a
Use isn't instead of shouldn't
tcharding c79eb97
Remove unnecessary explanation
tcharding c73eb2f
Use 'extra' instead of 'cheap'
tcharding File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ pub use self::alloc_only::*; | |
|
||
#[cfg(all(feature = "global-context", feature = "std"))] | ||
#[cfg_attr(docsrs, doc(cfg(all(feature = "global-context", feature = "std"))))] | ||
/// Module implementing a singleton pattern for a global `Secp256k1` context | ||
/// Module implementing a singleton pattern for a global `Secp256k1` context. | ||
pub mod global { | ||
#[cfg(feature = "rand-std")] | ||
use rand; | ||
|
@@ -20,7 +20,7 @@ pub mod global { | |
use std::sync::Once; | ||
use {Secp256k1, All}; | ||
|
||
/// Proxy struct for global `SECP256K1` context | ||
/// Proxy struct for global `SECP256K1` context. | ||
#[derive(Debug, Copy, Clone)] | ||
pub struct GlobalContext { | ||
__private: (), | ||
|
@@ -60,8 +60,8 @@ pub mod global { | |
} | ||
|
||
|
||
/// A trait for all kinds of Context's that lets you define the exact flags and a function to deallocate memory. | ||
/// It shouldn't be possible to implement this for types outside this crate. | ||
/// A trait for all kinds of contexts that lets you define the exact flags and a function to | ||
/// deallocate memory. It shouldn't be possible to implement this for types outside this crate. | ||
pub unsafe trait Context : private::Sealed { | ||
/// Flags for the ffi. | ||
const FLAGS: c_uint; | ||
|
@@ -98,8 +98,8 @@ pub struct AllPreallocated<'buf> { | |
mod private { | ||
use super::*; | ||
// A trick to prevent users from implementing a trait. | ||
// on one hand this trait is public, on the other it's in a private module | ||
// so it's not visible to anyone besides it's parent (the context module) | ||
// On one hand this trait is public, on the other it's in a private module | ||
// so it's not visible to anyone besides it's parent (the context module). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In 5e07e75: Should also change the second There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also we could probably drop the exposition here; it's a pretty standard idiom now. |
||
pub trait Sealed {} | ||
|
||
impl<'buf> Sealed for AllPreallocated<'buf> {} | ||
|
@@ -289,7 +289,7 @@ unsafe impl<'buf> Context for VerifyOnlyPreallocated<'buf> { | |
const DESCRIPTION: &'static str = "verification only"; | ||
|
||
unsafe fn deallocate(_ptr: *mut u8, _size: usize) { | ||
// Allocated by the user | ||
// Allocated by the user. | ||
} | ||
} | ||
|
||
|
@@ -298,7 +298,7 @@ unsafe impl<'buf> Context for AllPreallocated<'buf> { | |
const DESCRIPTION: &'static str = "all capabilities"; | ||
|
||
unsafe fn deallocate(_ptr: *mut u8, _size: usize) { | ||
// Allocated by the user | ||
// Allocated by the user. | ||
} | ||
} | ||
|
||
|
@@ -328,7 +328,7 @@ impl<'buf> Secp256k1<AllPreallocated<'buf>> { | |
pub fn preallocated_new(buf: &'buf mut [AlignedType]) -> Result<Secp256k1<AllPreallocated<'buf>>, Error> { | ||
Secp256k1::preallocated_gen_new(buf) | ||
} | ||
/// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for a context | ||
/// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for a context. | ||
pub fn preallocate_size() -> usize { | ||
Self::preallocate_size_gen() | ||
} | ||
|
@@ -354,12 +354,12 @@ impl<'buf> Secp256k1<AllPreallocated<'buf>> { | |
} | ||
|
||
impl<'buf> Secp256k1<SignOnlyPreallocated<'buf>> { | ||
/// Creates a new Secp256k1 context that can only be used for signing | ||
/// Creates a new Secp256k1 context that can only be used for signing. | ||
pub fn preallocated_signing_only(buf: &'buf mut [AlignedType]) -> Result<Secp256k1<SignOnlyPreallocated<'buf>>, Error> { | ||
Secp256k1::preallocated_gen_new(buf) | ||
} | ||
|
||
/// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for the context | ||
/// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for the context. | ||
#[inline] | ||
pub fn preallocate_signing_size() -> usize { | ||
Self::preallocate_size_gen() | ||
|
@@ -374,7 +374,7 @@ impl<'buf> Secp256k1<SignOnlyPreallocated<'buf>> { | |
/// * The capabilities (All/SignOnly/VerifyOnly) of the context *must* match the flags passed to libsecp256k1 | ||
/// when generating the context. | ||
/// * The user must handle the freeing of the context(using the correct functions) by himself. | ||
/// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior., | ||
/// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior. | ||
/// | ||
pub unsafe fn from_raw_signining_only(raw_ctx: *mut ffi::Context) -> ManuallyDrop<Secp256k1<SignOnlyPreallocated<'buf>>> { | ||
ManuallyDrop::new(Secp256k1 { | ||
|
@@ -391,7 +391,7 @@ impl<'buf> Secp256k1<VerifyOnlyPreallocated<'buf>> { | |
Secp256k1::preallocated_gen_new(buf) | ||
} | ||
|
||
/// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for the context | ||
/// Uses the ffi `secp256k1_context_preallocated_size` to check the memory size needed for the context. | ||
#[inline] | ||
pub fn preallocate_verification_size() -> usize { | ||
Self::preallocate_size_gen() | ||
|
@@ -406,7 +406,7 @@ impl<'buf> Secp256k1<VerifyOnlyPreallocated<'buf>> { | |
/// * The capabilities (All/SignOnly/VerifyOnly) of the context *must* match the flags passed to libsecp256k1 | ||
/// when generating the context. | ||
/// * The user must handle the freeing of the context(using the correct functions) by himself. | ||
/// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior., | ||
/// * This list *is not* exhaustive, and any violation may lead to Undefined Behavior. | ||
/// | ||
pub unsafe fn from_raw_verification_only(raw_ctx: *mut ffi::Context) -> ManuallyDrop<Secp256k1<VerifyOnlyPreallocated<'buf>>> { | ||
ManuallyDrop::new(Secp256k1 { | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In 269bde0:
You could change "shouldn't be possible" to "isn't possible". I think we've come to trust rustc more than when this comment was written :)