package template

import "fmt"

// CodecType represents the type of codec used to encode/render a value
type CodecType string

const (
	CodecText     CodecType = "text"
	CodecNumber   CodecType = "number"
	CodecYaml     CodecType = "yaml"
	CodecList     CodecType = "list"
	CodecConst    CodecType = "const"
	CodecHashtags CodecType = "hashtags"
)

func parseCodecType(input string) (CodecType, error) {
	switch input {
	case "number":
		return CodecNumber, nil
	case "yaml":
		return CodecYaml, nil
	case "list":
		return CodecList, nil
	case "text":
		return CodecText, nil
	case "const":
		return CodecConst, nil
	case "hashtags":
		return CodecHashtags, nil
	}
	return CodecText, fmt.Errorf("unknown codec: '%s'", input)
}
