From 64106c4d3d4ddba8c7bc2af75376e6d3d3d75601 Mon Sep 17 00:00:00 2001 From: Date: Mon, 29 Jun 2015 20:16:15 +0000 Subject: Update documentation --- src/openssl/asn1/mod.rs.html | 195 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 src/openssl/asn1/mod.rs.html (limited to 'src/openssl/asn1/mod.rs.html') diff --git a/src/openssl/asn1/mod.rs.html b/src/openssl/asn1/mod.rs.html new file mode 100644 index 0000000..5d7d165 --- /dev/null +++ b/src/openssl/asn1/mod.rs.html @@ -0,0 +1,195 @@ + + + + + + + + + + mod.rs.html -- source + + + + + + + + + + + + + + + +
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+
+use libc::{c_long};
+use std::ptr;
+
+use ffi;
+use ssl::error::{SslError};
+
+
+pub struct Asn1Time {
+    handle: *mut ffi::ASN1_TIME,
+    owned: bool
+}
+
+impl Asn1Time {
+    /// Wraps existing ASN1_TIME and takes ownership
+    pub fn new(handle: *mut ffi::ASN1_TIME) -> Asn1Time {
+        Asn1Time {
+            handle: handle,
+            owned: true
+        }
+    }
+
+    fn new_with_period(period: u64) -> Result<Asn1Time, SslError> {
+        ffi::init();
+
+        let handle = unsafe {
+            try_ssl_null!(ffi::X509_gmtime_adj(ptr::null_mut(),
+                                               period as c_long))
+        };
+        Ok(Asn1Time::new(handle))
+    }
+
+    /// Creates a new time on specified interval in days from now
+    pub fn days_from_now(days: u32) -> Result<Asn1Time, SslError> {
+        Asn1Time::new_with_period(days as u64 * 60 * 60 * 24)
+    }
+
+    /// Returns raw handle
+    pub unsafe fn get_handle(&self) -> *mut ffi::ASN1_TIME {
+        return self.handle
+    }
+}
+
+impl Drop for Asn1Time {
+    fn drop(&mut self) {
+        if self.owned {
+            unsafe { ffi::ASN1_TIME_free(self.handle) };
+        }
+    }
+}
+
+
+ + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3