From fa17f132e23118dd88f4726613e8722c8a38f464 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Mon, 18 Mar 2019 16:58:28 +0200 Subject: Prepare for naive decoding implementation --- Cargo.toml | 1 - src/lib.rs | 20 +++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 73f3293..19ded13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,4 +5,3 @@ authors = ["Yuval Adam <_@yuv.al>"] edition = "2018" [dependencies] -bchlib-sys = "0.1.0" diff --git a/src/lib.rs b/src/lib.rs index 0af03a6..2f49852 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,17 @@ -extern crate bchlib_sys as ffi; -pub fn init(m:i32, t:i32, poly: u32) { - unsafe { - let bch = ffi::init_bch(m, t, poly); +pub struct BCH { + n: u32, +} + +impl BCH { + pub fn new(n: u32) -> BCH { + BCH { + n + } + } + + pub fn decode(self) -> u32{ + return self.n } } @@ -12,6 +21,7 @@ mod tests { #[test] fn it_works() { - init(); + let bch = BCH::new(3); + assert_eq!(bch.decode(), 3); } } -- cgit v1.3.1