package encoding

import (
	
	

	
	
)

var (
	// ErrNotSupported is an error returned when the underlying encoding does
	// not support the type of values being encoded or decoded.
	//
	// This error may be wrapped with type information, applications must use
	// errors.Is rather than equality comparisons to test the error values
	// returned by encoders and decoders.
	ErrNotSupported = errors.New("encoding not supported")

	// ErrInvalidArgument is an error returned one or more arguments passed to
	// the encoding functions are incorrect.
	//
	// As with ErrNotSupported, this error may be wrapped with specific
	// information about the problem and applications are expected to use
	// errors.Is for comparisons.
	ErrInvalidArgument = errors.New("invalid argument")
)

// Error constructs an error which wraps err and indicates that it originated
// from the given encoding.
func ( Encoding,  error) error {
	return fmt.Errorf("%s: %w", , )
}

// Errorf is like Error but constructs the error message from the given format
// and arguments.
func ( Encoding,  string,  ...interface{}) error {
	return Error(, fmt.Errorf(, ...))
}

// ErrEncodeInvalidInputSize constructs an error indicating that encoding failed
// due to the size of the input.
func ( Encoding,  string,  int) error {
	return errInvalidInputSize(, "encode", , )
}

// ErrDecodeInvalidInputSize constructs an error indicating that decoding failed
// due to the size of the input.
func ( Encoding,  string,  int) error {
	return errInvalidInputSize(, "decode", , )
}

func errInvalidInputSize( Encoding, ,  string,  int) error {
	return Errorf(, "cannot %s %s from input of size %d: %w", , , , ErrInvalidArgument)
}

// CanEncodeInt8 reports whether e can encode LEVELS values.
func ( Encoding) bool {
	,  := .EncodeLevels(nil, nil)
	return !errors.Is(, ErrNotSupported)
}

// CanEncodeBoolean reports whether e can encode BOOLEAN values.
func ( Encoding) bool {
	,  := .EncodeBoolean(nil, nil)
	return !errors.Is(, ErrNotSupported)
}

// CanEncodeInt32 reports whether e can encode INT32 values.
func ( Encoding) bool {
	,  := .EncodeInt32(nil, nil)
	return !errors.Is(, ErrNotSupported)
}

// CanEncodeInt64 reports whether e can encode INT64 values.
func ( Encoding) bool {
	,  := .EncodeInt64(nil, nil)
	return !errors.Is(, ErrNotSupported)
}

// CanEncodeInt96 reports whether e can encode INT96 values.
func ( Encoding) bool {
	,  := .EncodeInt96(nil, nil)
	return !errors.Is(, ErrNotSupported)
}

// CanEncodeFloat reports whether e can encode FLOAT values.
func ( Encoding) bool {
	,  := .EncodeFloat(nil, nil)
	return !errors.Is(, ErrNotSupported)
}

// CanEncodeDouble reports whether e can encode DOUBLE values.
func ( Encoding) bool {
	,  := .EncodeDouble(nil, nil)
	return !errors.Is(, ErrNotSupported)
}

// CanEncodeByteArray reports whether e can encode BYTE_ARRAY values.
func ( Encoding) bool {
	,  := .EncodeByteArray(nil, nil, zeroOffsets[:])
	return !errors.Is(, ErrNotSupported)
}

// CanEncodeFixedLenByteArray reports whether e can encode
// FIXED_LEN_BYTE_ARRAY values.
func ( Encoding) bool {
	,  := .EncodeFixedLenByteArray(nil, nil, 1)
	return !errors.Is(, ErrNotSupported)
}

var zeroOffsets [1]uint32

// NotSupported is a type satisfying the Encoding interface which does not
// support encoding nor decoding any value types.
type NotSupported struct {
}

func (NotSupported) () string {
	return "NOT_SUPPORTED"
}

func (NotSupported) () format.Encoding {
	return -1
}

func (NotSupported) ( []byte,  []uint8) ([]byte, error) {
	return [:0], errNotSupported("LEVELS")
}

func (NotSupported) ( []byte,  []byte) ([]byte, error) {
	return [:0], errNotSupported("BOOLEAN")
}

func (NotSupported) ( []byte,  []int32) ([]byte, error) {
	return [:0], errNotSupported("INT32")
}

func (NotSupported) ( []byte,  []int64) ([]byte, error) {
	return [:0], errNotSupported("INT64")
}

func (NotSupported) ( []byte,  []deprecated.Int96) ([]byte, error) {
	return [:0], errNotSupported("INT96")
}

func (NotSupported) ( []byte,  []float32) ([]byte, error) {
	return [:0], errNotSupported("FLOAT")
}

func (NotSupported) ( []byte,  []float64) ([]byte, error) {
	return [:0], errNotSupported("DOUBLE")
}

func (NotSupported) ( []byte,  []byte,  []uint32) ([]byte, error) {
	return [:0], errNotSupported("BYTE_ARRAY")
}

func (NotSupported) ( []byte,  []byte,  int) ([]byte, error) {
	return [:0], errNotSupported("FIXED_LEN_BYTE_ARRAY")
}

func (NotSupported) ( []uint8,  []byte) ([]uint8, error) {
	return , errNotSupported("LEVELS")
}

func (NotSupported) ( []byte,  []byte) ([]byte, error) {
	return , errNotSupported("BOOLEAN")
}

func (NotSupported) ( []int32,  []byte) ([]int32, error) {
	return , errNotSupported("INT32")
}

func (NotSupported) ( []int64,  []byte) ([]int64, error) {
	return , errNotSupported("INT64")
}

func (NotSupported) ( []deprecated.Int96,  []byte) ([]deprecated.Int96, error) {
	return , errNotSupported("INT96")
}

func (NotSupported) ( []float32,  []byte) ([]float32, error) {
	return , errNotSupported("FLOAT")
}

func (NotSupported) ( []float64,  []byte) ([]float64, error) {
	return , errNotSupported("DOUBLE")
}

func (NotSupported) ( []byte,  []byte,  []uint32) ([]byte, []uint32, error) {
	return , , errNotSupported("BYTE_ARRAY")
}

func (NotSupported) ( []byte,  []byte,  int) ([]byte, error) {
	return , errNotSupported("FIXED_LEN_BYTE_ARRAY")
}

func (NotSupported) ( []byte) int {
	return 0
}

func (NotSupported) () bool {
	return false
}

func errNotSupported( string) error {
	return fmt.Errorf("%w for type %s", ErrNotSupported, )
}

var (
	_ Encoding = NotSupported{}
)