data.verasure #
verasure - Jerasure made simple in V
This is a V implementation of Jerasure2, with a custom wrapper. In V, there is a wrapper to make call pure-v style.
Example
module main
import freeflowuniverse.crystallib.data.verasure
fn main() {
mut e := verasure.new(16, 4)
shards := e.encode('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer consectetur accumsan augue, at pharetra'.bytes())
println(shards)
data := e.decode(shards)
println(data.len)
println(data.bytestr())
}
- Create a new Verasure object, with data and parity amount
- Encode any bytes data
- Decode shards to get bytes back
Disclamer
This is still in progress, memory management is not yet there. There is still a bug on parity missing.
fn new #
fn new(segments int, spare int) Verasure
fn test #
fn test()
struct Shards #
struct Shards {
blocksize int
data [][]u8
parity [][]u8
}
struct Verasure #
struct Verasure {
kntxt &Erasure_t
}
v wrapper
fn (Verasure) encode #
fn (mut v Verasure) encode(data []u8) Shards
fn (Verasure) decode #
fn (mut v Verasure) decode(shards Shards) []u8