storj.io/uplink@v1.13.0/private/eestream/scheme.go (about) 1 // Copyright (C) 2023 Storj Labs, Inc. 2 // See LICENSE for copying information. 3 4 package eestream 5 6 import ( 7 "storj.io/infectious" 8 ) 9 10 // ErasureScheme represents the general format of any erasure scheme algorithm. 11 // If this interface can be implemented, the rest of this library will work 12 // with it. 13 type ErasureScheme interface { 14 // Encode will take 'in' and call 'out' with erasure coded pieces. 15 Encode(in []byte, out func(num int, data []byte)) error 16 17 // EncodeSingle will take 'in' with the stripe and fill 'out' with the erasure share for piece 'num'. 18 EncodeSingle(in, out []byte, num int) error 19 20 // Decode will take a mapping of available erasure coded piece num -> data, 21 // 'in', and append the combined data to 'out', returning it. 22 Decode(out []byte, in []infectious.Share) ([]byte, error) 23 24 // Rebuild is a direct call to infectious.Rebuild, which does no error 25 // detection and is faster. 26 Rebuild(in []infectious.Share, out func(infectious.Share)) error 27 28 // ErasureShareSize is the size of the erasure shares that come from Encode 29 // and are passed to Decode. 30 ErasureShareSize() int 31 32 // StripeSize is the size the stripes that are passed to Encode and come 33 // from Decode. 34 StripeSize() int 35 36 // Encode will generate this many erasure shares and therefore this many pieces. 37 TotalCount() int 38 39 // Decode requires at least this many pieces. 40 RequiredCount() int 41 }