Skip to content

Commit

Permalink
Add New{En,De}coder convenience functions
Browse files Browse the repository at this point in the history
They use the default factory and accept the same arguments as the New
function of the factory interface does.
  • Loading branch information
Eugene Kim committed Dec 18, 2018
1 parent 203cb90 commit 9f8e243
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/raptorq/default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package raptorq

import "github.com/harmony-one/go-raptorq/pkg/defaults"

// NewEncoder creates and returns an encoder using the default factory.
func NewEncoder(
input []byte, symbolSize uint16, minSubSymbolSize uint16,
maxSubBlockSize uint32, alignment uint8,
) (enc Encoder, err error) {
factory := defaults.DefaultEncoderFactory()
return factory.New(
input, symbolSize, minSubSymbolSize, maxSubBlockSize, alignment,
)
}

// NewDecoder creates and returns a decoder using the default factory.
func NewDecoder(commonOTI uint64, schemeSpecificOTI uint32) (
dec Decoder, err error,
) {
factory := defaults.DefaultDecoderFactory()
return factory.New(commonOTI, schemeSpecificOTI)
}

0 comments on commit 9f8e243

Please sign in to comment.