Skip to content

Commit

Permalink
context: Improve rustdocs
Browse files Browse the repository at this point in the history
Improve the rustdocs in the `schnorr` module by doing:

- Use third person tense
- Add full stops
- Use links and code ticks
  • Loading branch information
tcharding committed Nov 24, 2022
1 parent e945751 commit ecdad39
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ pub unsafe trait Context: private::Sealed {
unsafe fn deallocate(ptr: *mut u8, size: usize);
}

/// Marker trait for indicating that an instance of `Secp256k1` can be used for signing.
/// Marker trait for indicating that an instance of [`Secp256k1`] can be used for signing.
pub trait Signing: Context {}

/// Marker trait for indicating that an instance of `Secp256k1` can be used for verification.
/// Marker trait for indicating that an instance of [`Secp256k1`] can be used for verification.
pub trait Verification: Context {}

/// Represents the set of capabilities needed for signing (preallocated memory).
Expand Down Expand Up @@ -239,8 +239,8 @@ mod alloc_only {
impl Secp256k1<VerifyOnly> {
/// Creates a new Secp256k1 context that can only be used for verification.
///
/// If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
/// If `rand-std` feature is not enabled please consider randomizing the context (see docs
/// * If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
/// * If `rand-std` feature is not enabled please consider randomizing the context (see docs
/// for `Secp256k1::gen_new()`).
pub fn verification_only() -> Secp256k1<VerifyOnly> { Secp256k1::gen_new() }
}
Expand Down Expand Up @@ -299,7 +299,7 @@ unsafe impl<'buf> Context for AllPreallocated<'buf> {
}

impl<'buf, C: Context + 'buf> Secp256k1<C> {
/// Lets you create a context with a preallocated buffer in a generic manner(sign/verify/all).
/// Lets you create a context with a preallocated buffer in a generic manner (sign/verify/all).
pub fn preallocated_gen_new(buf: &'buf mut [AlignedType]) -> Result<Secp256k1<C>, Error> {
#[cfg(target_arch = "wasm32")]
ffi::types::sanity_checks_for_wasm();
Expand All @@ -321,7 +321,7 @@ impl<'buf, C: Context + 'buf> Secp256k1<C> {
}

impl<'buf> Secp256k1<AllPreallocated<'buf>> {
/// Creates a new Secp256k1 context with all capabilities
/// Creates a new Secp256k1 context with all capabilities.
pub fn preallocated_new(
buf: &'buf mut [AlignedType],
) -> Result<Secp256k1<AllPreallocated<'buf>>, Error> {
Expand All @@ -330,7 +330,7 @@ impl<'buf> Secp256k1<AllPreallocated<'buf>> {
/// 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() }

/// Create a context from a raw context.
/// Creates a context from a raw context.
///
/// # Safety
/// This is highly unsafe, due to the number of conditions that aren't checked.
Expand Down Expand Up @@ -364,9 +364,10 @@ impl<'buf> Secp256k1<SignOnlyPreallocated<'buf>> {
#[inline]
pub fn preallocate_signing_size() -> usize { Self::preallocate_size_gen() }

/// Create a context from a raw context.
/// Creates a context from a raw context.
///
/// # Safety
///
/// This is highly unsafe, due to the number of conditions that aren't checked.
/// * `raw_ctx` needs to be a valid Secp256k1 context pointer.
/// that was generated by *exactly* the same code/version of the libsecp256k1 used here.
Expand Down Expand Up @@ -398,9 +399,10 @@ impl<'buf> Secp256k1<VerifyOnlyPreallocated<'buf>> {
#[inline]
pub fn preallocate_verification_size() -> usize { Self::preallocate_size_gen() }

/// Create a context from a raw context.
/// Creates a context from a raw context.
///
/// # Safety
///
/// This is highly unsafe, due to the number of conditions that aren't checked.
/// * `raw_ctx` needs to be a valid Secp256k1 context pointer.
/// that was generated by *exactly* the same code/version of the libsecp256k1 used here.
Expand Down

0 comments on commit ecdad39

Please sign in to comment.