liberasurecode

Crates.io: liberasurecode Documentation Build Status License: MIT

A Rust wrapper for [openstack/liberasurecode].

Documentation

Prerequisite to Build

You need to install [openstack/liberasurecode] and its dependencies by executing the following command before building this crate: console $ sudo ./install_deps.sh

Examples

Basic usage: ```rust use liberasurecode::{ErasureCoder, Error};

let mut coder = ErasureCoder::new(4, 2)?; let input = vec![0, 1, 2, 3];

// Encodes input to data and parity fragments let fragments = coder.encode(&input)?;

// Decodes the original data from the fragments (or a part of those) asserteq!(Ok(&input), coder.decode(&fragments[0..]).asref()); asserteq!(Ok(&input), coder.decode(&fragments[1..]).asref()); asserteq!(Ok(&input), coder.decode(&fragments[2..]).asref()); assert_eq!(Err(Error::InsufficientFragments), coder.decode(&fragments[3..])); ```