46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
|
|
||
|
use std::{
|
||
|
marker::PhantomData,
|
||
|
io::Write,
|
||
|
fmt::{Debug, Display, Formatter}
|
||
|
};
|
||
|
|
||
|
use f4jumble;
|
||
|
|
||
|
use borsh::{BorshDeserialize, BorshSerialize};
|
||
|
use haskell_ffi::{
|
||
|
error::Result,
|
||
|
from_haskell::{marshall_from_haskell_var},
|
||
|
to_haskell::{marshall_to_haskell_var, marshall_to_haskell_fixed},
|
||
|
FromHaskell, HaskellSize, ToHaskell
|
||
|
};
|
||
|
|
||
|
use zcash_address::{
|
||
|
Network,
|
||
|
unified::{Address, Encoding}
|
||
|
};
|
||
|
|
||
|
pub enum RW {}
|
||
|
pub const RW: PhantomData<RW> = PhantomData;
|
||
|
|
||
|
|
||
|
#[no_mangle]
|
||
|
pub extern "C" fn rust_wrapper_f4jumble(
|
||
|
input: *const u8,
|
||
|
input_len: usize,
|
||
|
out: *mut u8,
|
||
|
out_len: &mut usize) {
|
||
|
let input: Vec<u8> = marshall_from_haskell_var(input, input_len, RW);
|
||
|
let result = f4jumble::f4jumble(&input).unwrap();
|
||
|
marshall_to_haskell_var(&result, out, out_len, RW);
|
||
|
}
|
||
|
|
||
|
#[no_mangle]
|
||
|
pub extern "C" fn rust_wrapper_ua_decode(
|
||
|
input: *const u8,
|
||
|
input_len: usize,) -> bool {
|
||
|
let input: String = marshall_from_haskell_var(input, input_len, RW);
|
||
|
Address::decode(&input).is_ok()
|
||
|
//marshall_to_haskell_var(&result, out, out_len, RW);
|
||
|
}
|