summaryrefslogtreecommitdiff
path: root/openssl/src/nid.rs
diff options
context:
space:
mode:
authorjohnthagen <johnthagen@gmail.com>2017-09-28 14:25:39 -0400
committerjohnthagen <johnthagen@gmail.com>2017-09-28 14:25:39 -0400
commitb65540709fce62edbc07b87e71310367a5acefb7 (patch)
tree25f863b01f3e40bbe305ae9eca1b084f98b4f0ca /openssl/src/nid.rs
parent67ca96a0b8707295de53c598f30c2e300ba17e30 (diff)
downloadrust-openssl-b65540709fce62edbc07b87e71310367a5acefb7.zip
Document nid module
Diffstat (limited to 'openssl/src/nid.rs')
-rw-r--r--openssl/src/nid.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/openssl/src/nid.rs b/openssl/src/nid.rs
index afbd60a5..df1090c1 100644
--- a/openssl/src/nid.rs
+++ b/openssl/src/nid.rs
@@ -1,15 +1,43 @@
+//! A collection of numerical identifiers for OpenSSL objects.
use ffi;
use libc::c_int;
+/// A numerical identifier for an OpenSSL object.
+///
+/// Objects in OpenSSL can have a short name, a long name, and
+/// a numerical identifier (NID). For convenience, objects
+/// are usually represented in source code using these numeric
+/// identifiers.
+///
+/// Users should generally not need to create new `Nid`s.
+///
+/// # Examples
+///
+/// To view the integer representation of a `Nid`:
+///
+/// ```
+/// use openssl::nid;
+///
+/// assert!(nid::AES_256_GCM.as_raw() == 901);
+/// ```
+///
+/// # External Documentation
+///
+/// The following documentation provides context about `Nid`s and their usage
+/// in OpenSSL.
+///
+/// - [Obj_nid2obj](https://www.openssl.org/docs/man1.1.0/crypto/OBJ_create.html)
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Nid(c_int);
#[allow(non_snake_case)]
impl Nid {
+ /// Create a `Nid` from an integer representation.
pub fn from_raw(raw: c_int) -> Nid {
Nid(raw)
}
+ /// Return the integer representation of a `Nid`.
pub fn as_raw(&self) -> c_int {
self.0
}