From 36c0c42461aa4ce147a5c156ed580e73eb57dabe Mon Sep 17 00:00:00 2001 From: rosebeats Date: Sun, 19 Jul 2020 15:59:16 -0400 Subject: [PATCH 1/2] added from and into raw for Context --- src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 855864a02..bca234451 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -427,6 +427,20 @@ impl Context { }), } } + + /// Create a context from a raw pointer + pub unsafe fn from_raw(raw_ctx: *mut c_void) -> Context { + Context { + raw: Arc::new(RawContext { + ctx: raw_ctx, + }), + } + } + + /// Get the raw pointer to the context + pub fn into_raw(self) -> *mut c_void { + self.raw.ctx + } /// Create a new socket. /// From d84b7e25f9d5e408f7f8342524d5b9aafc09cacc Mon Sep 17 00:00:00 2001 From: rosebeats Date: Sun, 19 Jul 2020 16:51:02 -0400 Subject: [PATCH 2/2] fixed formatting --- src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bca234451..80eab2685 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -427,16 +427,14 @@ impl Context { }), } } - + /// Create a context from a raw pointer pub unsafe fn from_raw(raw_ctx: *mut c_void) -> Context { Context { - raw: Arc::new(RawContext { - ctx: raw_ctx, - }), + raw: Arc::new(RawContext { ctx: raw_ctx }), } } - + /// Get the raw pointer to the context pub fn into_raw(self) -> *mut c_void { self.raw.ctx