context: Improve rustdocs

Improve the rustdocs in the `schnorr` module by doing:

- Use third person tense
- Add full stops
- Use links and code ticks
This commit is contained in:
Tobin C. Harding 2022-11-24 11:30:50 +11:00
parent e945751d85
commit ecdad39ef4
1 changed files with 11 additions and 9 deletions

View File

@ -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).
@ -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() }
}
@ -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();
@ -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> {
@ -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.
@ -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.
@ -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.