diff --git a/leopard/leopard.nim b/leopard/leopard.nim index 615f7ad..96456f2 100644 --- a/leopard/leopard.nim +++ b/leopard/leopard.nim @@ -46,6 +46,48 @@ type LeoEncoder* = object of Leo LeoDecoder* = object of Leo +func encode*( + self: var LeoEncoder, + data,parity: ptr UncheckedArray[ptr UncheckedArray[byte]], + dataLen,parityLen: int ): Result[void, cstring] = + ## Encode a list of buffers in `data` into a number of `bufSize` sized + ## `parity` buffers + ## + ## `data` - list of original data `buffers` of size `bufSize` + ## `parity` - list of parity `buffers` of size `bufSize` + ## + + if dataLen != self.buffers: + return err("Number of data buffers should match!") + + if parityLen != self.parity: + return err("Number of parity buffers should match!") + + # zero encode work buffer to avoid corrupting with previous run + for i in 0..