Skip to content

Commit f02ff65

Browse files
committed
Merge #437: Safety docs
dc1e377 Improve docs on rustsecp256k1_v0_4_1_context_create (Tobin C. Harding) ad153d8 Add safety rustdoc headings (Tobin C. Harding) Pull request description: Do some minor docs improvements. Done in an effort to clear _all_ clippy warnings from the codebase. ACKs for top commit: sanket1729: ACK dc1e377 apoelstra: ACK dc1e377 Tree-SHA512: 9b7e3ff05a6ea05bde5df49bbfcc6eb2c7097b4d9b600dedeb8fef4e3cbdd56a357fd0846ca51cb32f0957bca1335ff3b4b0d771046481ab95447af99d6a2d9c
2 parents 37f4f00 + dc1e377 commit f02ff65

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

secp256k1-sys/src/lib.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ impl_raw_debug!(PublicKey);
109109
impl PublicKey {
110110
/// Creates an "uninitialized" FFI public key which is zeroed out
111111
///
112+
/// # Safety
113+
///
112114
/// If you pass this to any FFI functions, except as an out-pointer,
113115
/// the result is likely to be an assertation failure and process
114116
/// termination.
@@ -118,6 +120,8 @@ impl PublicKey {
118120

119121
/// Create a new public key usable for the FFI interface from raw bytes
120122
///
123+
/// # Safety
124+
///
121125
/// Does not check the validity of the underlying representation. If it is
122126
/// invalid the result may be assertation failures (and process aborts) from
123127
/// the underlying library. You should not use this method except with data
@@ -145,6 +149,8 @@ impl_raw_debug!(Signature);
145149
impl Signature {
146150
/// Creates an "uninitialized" FFI signature which is zeroed out
147151
///
152+
/// # Safety
153+
///
148154
/// If you pass this to any FFI functions, except as an out-pointer,
149155
/// the result is likely to be an assertation failure and process
150156
/// termination.
@@ -154,6 +160,8 @@ impl Signature {
154160

155161
/// Create a new signature usable for the FFI interface from raw bytes
156162
///
163+
/// # Safety
164+
///
157165
/// Does not check the validity of the underlying representation. If it is
158166
/// invalid the result may be assertation failures (and process aborts) from
159167
/// the underlying library. You should not use this method except with data
@@ -180,6 +188,8 @@ impl_raw_debug!(XOnlyPublicKey);
180188
impl XOnlyPublicKey {
181189
/// Creates an "uninitialized" FFI x-only public key which is zeroed out
182190
///
191+
/// # Safety
192+
///
183193
/// If you pass this to any FFI functions, except as an out-pointer,
184194
/// the result is likely to be an assertation failure and process
185195
/// termination.
@@ -189,6 +199,8 @@ impl XOnlyPublicKey {
189199

190200
/// Create a new x-only public key usable for the FFI interface from raw bytes
191201
///
202+
/// # Safety
203+
///
192204
/// Does not check the validity of the underlying representation. If it is
193205
/// invalid the result may be assertation failures (and process aborts) from
194206
/// the underlying library. You should not use this method except with data
@@ -215,6 +227,8 @@ impl_raw_debug!(KeyPair);
215227
impl KeyPair {
216228
/// Creates an "uninitialized" FFI keypair which is zeroed out
217229
///
230+
/// # Safety
231+
///
218232
/// If you pass this to any FFI functions, except as an out-pointer,
219233
/// the result is likely to be an assertation failure and process
220234
/// termination.
@@ -224,6 +238,8 @@ impl KeyPair {
224238

225239
/// Create a new keypair usable for the FFI interface from raw bytes
226240
///
241+
/// # Safety
242+
///
227243
/// Does not check the validity of the underlying representation. If it is
228244
/// invalid the result may be assertation failures (and process aborts) from
229245
/// the underlying library. You should not use this method except with data
@@ -519,12 +535,14 @@ extern "C" {
519535

520536
/// A reimplementation of the C function `secp256k1_context_create` in rust.
521537
///
522-
/// This function allocates memory, the pointer should be deallocated using `secp256k1_context_destroy`
523-
/// A failure to do so will result in a memory leak.
538+
/// This function allocates memory, the pointer should be deallocated using
539+
/// `secp256k1_context_destroy`. Failure to do so will result in a memory leak.
540+
///
541+
/// Input `flags` control which parts of the context to initialize.
542+
///
543+
/// # Returns
524544
///
525-
/// This will create a secp256k1 raw context.
526-
// Returns: a newly created context object.
527-
// In: flags: which parts of the context to initialize.
545+
/// The newly created secp256k1 raw context.
528546
#[no_mangle]
529547
#[cfg(all(feature = "std", not(rust_secp_no_symbol_renaming)))]
530548
#[cfg_attr(docsrs, doc(cfg(all(feature = "std", not(rust_secp_no_symbol_renaming)))))]

0 commit comments

Comments
 (0)