Crates.io | liberasurecode |
lib.rs | liberasurecode |
version | 1.0.3 |
source | src |
created_at | 2018-09-27 09:52:30.569279 |
updated_at | 2019-08-21 06:54:20.510766 |
description | A Rust wrapper for `openstack/liberasurecode` |
homepage | https://github.com/frugalos/liberasurecode |
repository | https://github.com/frugalos/liberasurecode |
max_upload_size | |
id | 86800 |
size | 57,167 |
A Rust wrapper for openstack/liberasurecode.
This crate requires the following packages for building openstack/liberasurecode in the build script:
gcc
)git
make
automake
autoconf
libtool
For example, on Ubuntu, you can install those by executing the following command:
$ sudo apt install gcc git make automake autoconf libtool
Basic usage:
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)
assert_eq!(Ok(&input), coder.decode(&fragments[0..]).as_ref());
assert_eq!(Ok(&input), coder.decode(&fragments[1..]).as_ref());
assert_eq!(Ok(&input), coder.decode(&fragments[2..]).as_ref());
assert_eq!(Err(Error::InsufficientFragments), coder.decode(&fragments[3..]));