pub struct ErasureCode { /* private fields */ }Expand description
The ErasureCode struct is used to encode and decode data using erasure codes.
It is a wrapper around the Jerasure library, which provides efficient implementations of various erasure coding techniques.
Implementations§
Source§impl ErasureCode
impl ErasureCode
Sourcepub fn encode<T: AsRef<[u8]>, U: AsMut<[u8]>>(
&self,
data: impl AsRef<[T]>,
code: impl AsMut<[U]>,
) -> Result<(), Error>
pub fn encode<T: AsRef<[u8]>, U: AsMut<[u8]>>( &self, data: impl AsRef<[T]>, code: impl AsMut<[U]>, ) -> Result<(), Error>
Encode the data and generate coding parity.
§Arguments
data- The data to encode, which must be a slice ofkbuffers of the same length.code- The buffer to store the coding parity, which must be a slice ofmbuffers of the same length.
§Requires
- All the buffers must be aligned to the machine long size, and be the same length.
Sourcepub fn decode<T: AsMut<[u8]>>(
&self,
data: impl AsMut<[T]>,
code: impl AsMut<[T]>,
erased: &[i32],
) -> Result<(), Error>
pub fn decode<T: AsMut<[u8]>>( &self, data: impl AsMut<[T]>, code: impl AsMut<[T]>, erased: &[i32], ) -> Result<(), Error>
Decode the data and recover the erased data.
§Arguments
data- The data devices, which must be a slice ofkbuffers of the same length.code- The coding devices, which must be a slice ofmbuffers of the same length.erased- The indices of the erased data devices, which must be a slice of integers. Thekdata devices are indexed 0..k, and themcoding devices are indexed k..k+m.
§Requires
- All the buffers must be aligned to the machine long size, and be the same length.
- The erased indices must be in the range of 0..k+m.
- The number of erased indices must be less than or equal to
m. - The erased indices must be unique.
§Note
The erased devices may not be recovered even if the number of erased devices is less than or equal to m.
This is because the coding matrix may not be full rank with large k and m.
In this case, the function will return an error.
Auto Trait Implementations§
impl !Send for ErasureCode
impl !Sync for ErasureCode
impl Freeze for ErasureCode
impl RefUnwindSafe for ErasureCode
impl Unpin for ErasureCode
impl UnsafeUnpin for ErasureCode
impl UnwindSafe for ErasureCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more