aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ex_data.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2017-07-15 16:34:07 -0700
committerSteven Fackler <[email protected]>2017-07-15 16:50:36 -0700
commitfd52bbe85c1b67a5416ded43a0845be3d1c57b59 (patch)
treec0406ebe644ace5862242938f763753ecf0590c0 /openssl/src/ex_data.rs
parentMove callbacks to a submodule (diff)
downloadrust-openssl-fd52bbe85c1b67a5416ded43a0845be3d1c57b59.tar.xz
rust-openssl-fd52bbe85c1b67a5416ded43a0845be3d1c57b59.zip
Add an API to install extra data
Diffstat (limited to 'openssl/src/ex_data.rs')
-rw-r--r--openssl/src/ex_data.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/openssl/src/ex_data.rs b/openssl/src/ex_data.rs
new file mode 100644
index 00000000..450dd113
--- /dev/null
+++ b/openssl/src/ex_data.rs
@@ -0,0 +1,26 @@
+use libc::c_int;
+use std::marker::PhantomData;
+
+/// A slot in a type's "extra data" structure.
+///
+/// It is parameterized over the type containing the extra data as well as the
+/// type of the data in the slot.
+pub struct Index<T, U>(c_int, PhantomData<(T, U)>);
+
+impl<T, U> Copy for Index<T, U> {}
+
+impl<T, U> Clone for Index<T, U> {
+ fn clone(&self) -> Index<T, U> {
+ *self
+ }
+}
+
+impl<T, U> Index<T, U> {
+ pub unsafe fn from_raw(idx: c_int) -> Index<T, U> {
+ Index(idx, PhantomData)
+ }
+
+ pub fn as_raw(&self) -> c_int {
+ self.0
+ }
+}