byteutils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: LGPL-3.0 Imports: 4 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(data []byte, dec Decoder) (interface{}, error)

Decode decodes []byte from Decoder.

func Encode

func Encode(s interface{}, enc Encoder) ([]byte, error)

Encode encodes object to Encoder.

func Equal

func Equal(a []byte, b []byte) bool

Equal checks whether byte slice a and b are equal.

func FromHex

func FromHex(data string) ([]byte, error)

FromHex decodes string from Hex.

func FromInt16

func FromInt16(v int16) []byte

FromInt16 decodes int16 v.

func FromInt32

func FromInt32(v int32) []byte

FromInt32 decodes int32 v.

func FromInt64

func FromInt64(v int64) []byte

FromInt64 decodes int64 v.

func FromUint16

func FromUint16(v uint16) []byte

FromUint16 decodes uint16.

func FromUint32

func FromUint32(v uint32) []byte

FromUint32 decodes uint32.

func FromUint64

func FromUint64(v uint64) []byte

FromUint64 decodes unit64 value.

func Hex

func Hex(data []byte) string

Hex encodes []byte to Hex.

func Int16

func Int16(data []byte) int16

Int16 encode []byte.

func Int32

func Int32(data []byte) int32

Int32 encodes []byte.

func Int64

func Int64(data []byte) int64

Int64 encodes []byte.

func Uint16

func Uint16(data []byte) uint16

Uint16 encodes []byte.

func Uint32

func Uint32(data []byte) uint32

Uint32 encodes []byte.

func Uint64

func Uint64(data []byte) uint64

Uint64 encodes []byte.

func ZeroBytes

func ZeroBytes(bytes []byte)

ZeroBytes clears byte slice.

Types

type Decoder

type Decoder interface {
	DecodeFromBytes(data []byte) (interface{}, error)
}

Decoder is decoder for bytes.Decode().

type Encoder

type Encoder interface {
	EncodeToBytes(s interface{}) ([]byte, error)
}

Encoder is encoder for bytes.Encode().

type JSONSerializer

type JSONSerializer struct{}

JSONSerializer implements conversion between bytes and json string.

func (*JSONSerializer) Deserialize

func (s *JSONSerializer) Deserialize(val []byte, res interface{}) error

Deserialize converts json string into struct or array.

func (*JSONSerializer) Serialize

func (s *JSONSerializer) Serialize(val interface{}) ([]byte, error)

Serialize converts struct or array into json string.

type ProtoSerializer

type ProtoSerializer struct{}

ProtoSerializer implements conversion between bytes and proto message.

func (*ProtoSerializer) Deserialize

func (s *ProtoSerializer) Deserialize(val []byte, res proto.Message) error

Deserialize converts byte into proto message.

func (*ProtoSerializer) Serialize

func (s *ProtoSerializer) Serialize(val proto.Message) ([]byte, error)

Serialize converts proto message to bytes.

type Serializable

type Serializable interface {
	Serialize(s interface{}) ([]byte, error)
	Deserialize(data []byte, res interface{}) error
}

Serializable implements serializer.

Jump to

Keyboard shortcuts

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