From 3c88eaa60220f7498d96b562b0aa9563352a4379 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Fri, 25 Oct 2019 14:15:47 -0400
Subject: [PATCH] rust: add from_slice

---
 rust/src/crypto.rs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/rust/src/crypto.rs b/rust/src/crypto.rs
index 54adfb3b..c0d53cd2 100644
--- a/rust/src/crypto.rs
+++ b/rust/src/crypto.rs
@@ -131,6 +131,12 @@ impl DhtCertificate {
         }
     }
 
+    pub fn from_slice(buffer: &str) -> Box<DhtCertificate> {
+        unsafe {
+            Box::from_raw(dht_certificate_import((&*buffer).as_ptr(), buffer.len()))
+        }
+    }
+
     pub fn id(&self) -> InfoHash {
         unsafe {
             dht_certificate_get_id(&*self)
-- 
GitLab