From fd416028dc566fb21e1d5d1def12cb62138f527c Mon Sep 17 00:00:00 2001 From: munna0908 Date: Thu, 6 Feb 2025 19:36:05 +0530 Subject: [PATCH] update encode proc signature --- leopard/leopard.nim | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) 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..