mirror of
https://github.com/logos-storage/logos-storage-proofs.git
synced 2026-01-02 21:43:09 +00:00
wip: ffi
This commit is contained in:
parent
1b5b249f59
commit
ea4a2a082e
46
src/ffi.rs
46
src/ffi.rs
@ -1,30 +1,30 @@
|
||||
// use crate::storageproofs::StorageProofs;
|
||||
// use std::str;
|
||||
use crate::storageproofs::StorageProofs;
|
||||
use std::str;
|
||||
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn init(
|
||||
// r1cs: *const u8,
|
||||
// r1cs_len: usize,
|
||||
// wasm: *const u8,
|
||||
// wasm_len: usize,
|
||||
// ) -> *mut StorageProofs {
|
||||
// let r1cs = unsafe {
|
||||
// let slice = std::slice::from_raw_parts(r1cs, r1cs_len);
|
||||
// str::from_utf8(slice).unwrap()
|
||||
// };
|
||||
#[no_mangle]
|
||||
pub extern "C" fn init(
|
||||
r1cs: *const u8,
|
||||
r1cs_len: usize,
|
||||
wasm: *const u8,
|
||||
wasm_len: usize,
|
||||
) -> *mut StorageProofs {
|
||||
let r1cs = unsafe {
|
||||
let slice = std::slice::from_raw_parts(r1cs, r1cs_len);
|
||||
str::from_utf8(slice).unwrap()
|
||||
};
|
||||
|
||||
// let wasm = unsafe {
|
||||
// let slice = std::slice::from_raw_parts(wasm, wasm_len);
|
||||
// str::from_utf8(slice).unwrap()
|
||||
// };
|
||||
let wasm = unsafe {
|
||||
let slice = std::slice::from_raw_parts(wasm, wasm_len);
|
||||
str::from_utf8(slice).unwrap()
|
||||
};
|
||||
|
||||
// let storage_proofs = Box::into_raw(Box::new(StorageProofs::new(
|
||||
// wasm.to_string(),
|
||||
// r1cs.to_string(),
|
||||
// )));
|
||||
let storage_proofs = Box::into_raw(Box::new(StorageProofs::new(
|
||||
wasm.to_string(),
|
||||
r1cs.to_string(),
|
||||
)));
|
||||
|
||||
// return storage_proofs;
|
||||
// }
|
||||
return storage_proofs;
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user