ras

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BOOLEAN       TypeInterface = 1
	BYTE                        = 2
	SHORT                       = 3
	INT                         = 4
	LONG                        = 5
	FLOAT                       = 6
	DOUBLE                      = 7
	SIZE                        = 8
	NULLABLE_SIZE               = 9
	STRING                      = 10
	UUID                        = 11
	TYPE                        = 12
	ENDPOINT_ID                 = 13
)
View Source
const (
	UTF8_CHARSET   = "UTF-8"
	SIZEOF_SHORT   = 2
	SIZEOF_INT     = 4
	SIZEOF_LONG    = 8
	NULL_BYTE      = 0x80
	TRUE_BYTE      = 1
	FALSE_BYTE     = 0
	MAX_SHIFT      = 7
	NULL_SHIFT     = 6
	BYTE_MASK      = 255
	NEXT_MASK      = -128
	NULL_NEXT_MASK = 64
	LAST_MASK      = 0
	NULL_LSB_MASK  = 63
	LSB_MASK       = 127
	TEMP_CAPACITY  = 256
)
View Source
const AgeDelta = 621355968000000
View Source
const TagNamespace = "rac"

Variables

This section is empty.

Functions

func Decode

func Decode(data []byte, v interface{}, version int) (int, error)

func Encode

func Encode(v interface{}, version int) ([]byte, error)

func EncodeUuid

func EncodeUuid(r io.Writer, value interface{}) (int, error)

func EncodeValue

func EncodeValue(encoder string, r io.Writer, value interface{}) (int, error)

func RegisterDecoderType

func RegisterDecoderType(name string, dec TypeDecoderFunc)

func RegisterEncoderType

func RegisterEncoderType(name string, dec TypeEncoderFunc)

Types

type Codec

type Codec interface {
	CodecWriter
	CodecReader
	Version() int
}

func NewCodec

func NewCodec() Codec

type CodecField

type CodecField struct {
	Number  int
	Ignore  bool
	Version int
	// contains filtered or unexported fields
}

type CodecOptions

type CodecOptions struct {
	Reader  CodecReader
	Writer  CodecWriter
	Version int
}

type CodecReader

type CodecReader interface {
	ReadBoolPtr(val *bool, reader io.Reader) (n int, err error)
	ReadBool(reader io.Reader) (val bool, n int, err error)

	ReadBytePtr(val *byte, reader io.Reader) (n int, err error)
	ReadByte(reader io.Reader) (val byte, n int, err error)

	ReadIntPtr(val *int, reader io.Reader) (n int, err error)
	ReadInt(reader io.Reader) (val int, n int, err error)

	ReadUintPtr(val *uint, reader io.Reader) (n int, err error)
	ReadUint(reader io.Reader) (val uint, n int, err error)

	ReadUint16(reader io.Reader) (val uint16, n int, err error)
	ReadUint16Ptr(ptr *uint16, reader io.Reader) (n int, err error)

	ReadInt32Ptr(val *int32, reader io.Reader) (n int, err error)
	ReadInt32(reader io.Reader) (val int32, n int, err error)

	ReadUint32Ptr(val *uint32, reader io.Reader) (n int, err error)
	ReadUint32(reader io.Reader) (val uint32, n int, err error)

	ReadInt64Ptr(val *int64, reader io.Reader) (n int, err error)
	ReadInt64(reader io.Reader) (val int64, n int, err error)

	ReadUint64Ptr(val *uint64, reader io.Reader) (n int, err error)
	ReadUint64(reader io.Reader) (val uint64, n int, err error)

	ReadFloat32Ptr(val *float32, reader io.Reader) (n int, err error)
	ReadFloat32(reader io.Reader) (val float32, n int, err error)

	ReadFloat64Ptr(val *float64, reader io.Reader) (n int, err error)
	ReadFloat64(reader io.Reader) (val float64, n int, err error)

	ReadStringPtr(val *string, reader io.Reader) (n int, err error)
	ReadString(reader io.Reader) (val string, n int, err error)

	ReadUuidPtr(val interface{}, reader io.Reader) (n int, err error)
	ReadUuid(reader io.Reader) (val uuid.UUID, n int, err error)

	ReadSizePtr(val interface{}, reader io.Reader) (n int, err error)
	ReadSize(reader io.Reader) (val int, n int, err error)

	ReadNullableSizePtr(val interface{}, reader io.Reader) (n int, err error)
	ReadNullableSize(reader io.Reader) (int, n int, err error)

	ReadTypePtr(val *byte, reader io.Reader) (n int, err error)
	ReadType(reader io.Reader) (val byte, n int, err error)

	ReadTimePtr(ptr interface{}, reader io.Reader) (n int, err error)
	ReadTime(reader io.Reader) (val time.Time, n int, err error)
}

func NewCodecReader

func NewCodecReader() CodecReader

type CodecWriter

type CodecWriter interface {
	WriteBool(val bool, writer io.Writer) (n int, err error)
	WriteByte(val byte, writer io.Writer) (n int, err error)
	WriteInt(val int, writer io.Writer) (n int, err error)
	WriteUint(val uint, writer io.Writer) (n int, err error)
	WriteInt16(val int16, writer io.Writer) (n int, err error)
	WriteUint16(val uint16, writer io.Writer) (n int, err error)
	WriteInt32(val int32, writer io.Writer) (n int, err error)
	WriteUint32(val uint32, writer io.Writer) (n int, err error)
	WriteInt64(val int64, writer io.Writer) (n int, err error)
	WriteUint64(val uint64, writer io.Writer) (n int, err error)
	WriteFloat32(val float32, writer io.Writer) (n int, err error)
	WriteFloat64(val float64, writer io.Writer) (n int, err error)

	WriteNull(writer io.Writer) (n int, err error)
	WriteString(val string, writer io.Writer) (n int, err error)

	WriteUuid(val interface{}, writer io.Writer) (n int, err error)
	WriteSize(val int, writer io.Writer) (n int, err error)
	WriteNullableSize(val int, writer io.Writer) (n int, err error)
	WriteType(val byte, writer io.Writer) (n int, err error)
	WriteTime(val interface{}, writer io.Writer) (n int, err error)
}

func NewCodecWriter

func NewCodecWriter() CodecWriter

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(b []byte) *Decoder

func NewDecoderFromReader

func NewDecoderFromReader(r io.Reader) *Decoder

NewDecoder create new encoderFunc for version

func (*Decoder) Decode

func (dec *Decoder) Decode(val interface{}, version int) (int, error)

type DecoderError

type DecoderError struct {
	// contains filtered or unexported fields
}

func (*DecoderError) Error

func (e *DecoderError) Error() string

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(r io.Writer) *Encoder

NewDecoder create new encoderFunc for version

func (*Encoder) Encode

func (dec *Encoder) Encode(val interface{}, version int) error

type EncoderWriteError

type EncoderWriteError struct {
	Mame string
	// contains filtered or unexported fields
}

func (*EncoderWriteError) Error

func (e *EncoderWriteError) Error() string

type Formatter

type Formatter interface {
	FormatRAS(version int) ([]byte, error)
}

type InvalidDecodeError

type InvalidDecodeError struct {
	Type reflect.Type
}

An InvalidEncodeError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)

func (*InvalidDecodeError) Error

func (e *InvalidDecodeError) Error() string

type InvalidEncodeError

type InvalidEncodeError struct {
	Type reflect.Type
}

An InvalidEncodeError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)

func (*InvalidEncodeError) Error

func (e *InvalidEncodeError) Error() string

type Marshaller

type Marshaller interface {
	MarshalRAS(writer io.Writer, version int) (int, error)
}

type Option

type Option func(o *CodecOptions)

func WithCodecReader

func WithCodecReader(reader CodecReader) Option

func WithCodecVersion

func WithCodecVersion(version int) Option

func WithCodecWriter

func WithCodecWriter(writer CodecWriter) Option

type Parser

type Parser interface {
	ParseRAS(data []byte, version int) (n int, err error)
}

type TypeDecodeError

type TypeDecodeError struct {
	Mame string
	Msg  string
}

func (*TypeDecodeError) Error

func (e *TypeDecodeError) Error() string

type TypeDecoderFunc

type TypeDecoderFunc func(r io.Reader, into interface{}, opts ...map[string]string) (int, error)

type TypeEncoderError

type TypeEncoderError struct {
	Mame string
	Msg  string
}

func (*TypeEncoderError) Error

func (e *TypeEncoderError) Error() string

type TypeEncoderFunc

type TypeEncoderFunc func(r io.Writer, value interface{}) (int, error)

type TypeInterface

type TypeInterface byte

func (TypeInterface) Type

func (t TypeInterface) Type() byte

type Unmarshaler

type Unmarshaler interface {
	UnmarshalRAS(reader io.Reader, version int) (n int, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL