2022-05-19 19:56:03 +00:00
|
|
|
## Nim-Codex
|
2022-04-05 19:12:59 +00:00
|
|
|
## Copyright (c) 2022 Status Research & Development GmbH
|
|
|
|
## Licensed under either of
|
|
|
|
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
## * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
## at your option.
|
|
|
|
## This file may not be copied, modified, or distributed except according to
|
|
|
|
## those terms.
|
|
|
|
|
|
|
|
import pkg/upraises
|
|
|
|
|
|
|
|
push: {.upraises: [].}
|
|
|
|
|
|
|
|
import ../stores
|
|
|
|
|
|
|
|
type
|
2024-02-07 20:54:57 +00:00
|
|
|
ErasureBackend* = ref object of RootObj
|
2022-04-05 19:12:59 +00:00
|
|
|
blockSize*: int # block size in bytes
|
|
|
|
buffers*: int # number of original pieces
|
|
|
|
parity*: int # number of redundancy pieces
|
|
|
|
|
2024-02-07 20:54:57 +00:00
|
|
|
EncoderBackend* = ref object of ErasureBackend
|
|
|
|
DecoderBackend* = ref object of ErasureBackend
|
2022-04-05 19:12:59 +00:00
|
|
|
|
2024-02-07 20:54:57 +00:00
|
|
|
method release*(self: ErasureBackend) {.base.} =
|
2023-06-22 15:11:18 +00:00
|
|
|
## release the backend
|
2024-02-07 20:54:57 +00:00
|
|
|
##
|
2022-04-05 19:12:59 +00:00
|
|
|
raiseAssert("not implemented!")
|
|
|
|
|
|
|
|
method encode*(
|
2023-06-22 15:11:18 +00:00
|
|
|
self: EncoderBackend,
|
|
|
|
buffers,
|
|
|
|
parity: var openArray[seq[byte]]
|
|
|
|
): Result[void, cstring] {.base.} =
|
|
|
|
## encode buffers using a backend
|
2024-02-07 20:54:57 +00:00
|
|
|
##
|
2022-04-05 19:12:59 +00:00
|
|
|
raiseAssert("not implemented!")
|
|
|
|
|
|
|
|
method decode*(
|
2023-06-22 15:11:18 +00:00
|
|
|
self: DecoderBackend,
|
|
|
|
buffers,
|
|
|
|
parity,
|
|
|
|
recovered: var openArray[seq[byte]]
|
|
|
|
): Result[void, cstring] {.base.} =
|
|
|
|
## decode buffers using a backend
|
2024-02-07 20:54:57 +00:00
|
|
|
##
|
2022-04-05 19:12:59 +00:00
|
|
|
raiseAssert("not implemented!")
|