diff options
| author | Steven Fackler <[email protected]> | 2017-02-04 08:54:25 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-02-04 08:54:25 -0800 |
| commit | 084cf3c66b7cc3d24cb23d2bb548fa0fa4ee040a (patch) | |
| tree | 6c3e0f158d3cf63e5ae8229126e3430847398ad3 /openssl/src/macros.rs | |
| parent | Merge pull request #571 from sfackler/build-script-cleanup (diff) | |
| parent | Switch to foreign_types (diff) | |
| download | rust-openssl-084cf3c66b7cc3d24cb23d2bb548fa0fa4ee040a.tar.xz rust-openssl-084cf3c66b7cc3d24cb23d2bb548fa0fa4ee040a.zip | |
Merge pull request #572 from sfackler/foreign-types
Switch to foreign_types
Diffstat (limited to 'openssl/src/macros.rs')
| -rw-r--r-- | openssl/src/macros.rs | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/openssl/src/macros.rs b/openssl/src/macros.rs index b36e8319..b2fe0c18 100644 --- a/openssl/src/macros.rs +++ b/openssl/src/macros.rs @@ -1,45 +1,4 @@ -macro_rules! type_ { - ($n:ident, $r:ident, $c:path, $d:path) => { - pub struct $n(*mut $c); - - impl ::types::OpenSslType for $n { - type CType = $c; - type Ref = $r; - - unsafe fn from_ptr(ptr: *mut $c) -> $n { - $n(ptr) - } - } - - impl Drop for $n { - fn drop(&mut self) { - unsafe { $d(self.0) } - } - } - - impl ::std::ops::Deref for $n { - type Target = $r; - - fn deref(&self) -> &$r { - unsafe { ::types::OpenSslTypeRef::from_ptr(self.0) } - } - } - - impl ::std::ops::DerefMut for $n { - fn deref_mut(&mut self) -> &mut $r { - unsafe { ::types::OpenSslTypeRef::from_ptr_mut(self.0) } - } - } - - pub struct $r(::util::Opaque); - - impl ::types::OpenSslTypeRef for $r { - type CType = $c; - } - } -} - macro_rules! private_key_from_pem { ($t:ident, $f:path) => { from_pem_inner!(/// Deserializes a PEM-formatted private key. @@ -161,9 +120,11 @@ macro_rules! to_der_inner { #[$m] pub fn $n(&self) -> Result<Vec<u8>, ::error::ErrorStack> { unsafe { - let len = try!(::cvt($f(::types::OpenSslTypeRef::as_ptr(self), ptr::null_mut()))); + let len = try!(::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), + ptr::null_mut()))); let mut buf = vec![0; len as usize]; - try!(::cvt($f(::types::OpenSslTypeRef::as_ptr(self), &mut buf.as_mut_ptr()))); + try!(::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), + &mut buf.as_mut_ptr()))); Ok(buf) } } |