codec

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: Apache-2.0 Imports: 8 Imported by: 597

Documentation

Overview

Package codec provides methods allowing to encode and decode message structs to/from binary format accepted by VPP.

Index

Constants

This section is empty.

Variables

View Source
var DefaultCodec = new(MsgCodec)

Functions

func DecodeMsg added in v0.4.0

func DecodeMsg(data []byte, msg api.Message) (err error)

func DecodeMsgContext added in v0.4.0

func DecodeMsgContext(data []byte, msgType api.MessageType) (context uint32, err error)

func EncodeMsg added in v0.4.0

func EncodeMsg(msg api.Message, msgID uint16) (data []byte, err error)

Types

type Buffer added in v0.4.0

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

Buffer provides buffer for encoding and decoding data on wire.

func NewBuffer added in v0.4.0

func NewBuffer(b []byte) *Buffer

NewBuffer creates new buffer using b as data.

func (*Buffer) Bytes added in v0.4.0

func (b *Buffer) Bytes() []byte

Bytes returns buffer data up to current position.

func (*Buffer) DecodeBool added in v0.4.0

func (b *Buffer) DecodeBool() bool

func (*Buffer) DecodeBytes added in v0.4.0

func (b *Buffer) DecodeBytes(length int) []byte

func (*Buffer) DecodeFloat64 added in v0.4.0

func (b *Buffer) DecodeFloat64() float64

func (*Buffer) DecodeInt16 added in v0.4.0

func (b *Buffer) DecodeInt16() int16

func (*Buffer) DecodeInt32 added in v0.4.0

func (b *Buffer) DecodeInt32() int32

func (*Buffer) DecodeInt64 added in v0.4.0

func (b *Buffer) DecodeInt64() int64

func (*Buffer) DecodeInt8 added in v0.4.0

func (b *Buffer) DecodeInt8() int8

func (*Buffer) DecodeString added in v0.4.0

func (b *Buffer) DecodeString(length int) string

func (*Buffer) DecodeUint16 added in v0.4.0

func (b *Buffer) DecodeUint16() uint16

func (*Buffer) DecodeUint32 added in v0.4.0

func (b *Buffer) DecodeUint32() uint32

func (*Buffer) DecodeUint64 added in v0.4.0

func (b *Buffer) DecodeUint64() uint64

func (*Buffer) DecodeUint8 added in v0.4.0

func (b *Buffer) DecodeUint8() uint8

func (*Buffer) EncodeBool added in v0.4.0

func (b *Buffer) EncodeBool(v bool)

func (*Buffer) EncodeBytes added in v0.4.0

func (b *Buffer) EncodeBytes(v []byte, length int)

func (*Buffer) EncodeFloat64 added in v0.4.0

func (b *Buffer) EncodeFloat64(v float64)

func (*Buffer) EncodeInt16 added in v0.4.0

func (b *Buffer) EncodeInt16(v int16)

func (*Buffer) EncodeInt32 added in v0.4.0

func (b *Buffer) EncodeInt32(v int32)

func (*Buffer) EncodeInt64 added in v0.4.0

func (b *Buffer) EncodeInt64(v int64)

func (*Buffer) EncodeInt8 added in v0.4.0

func (b *Buffer) EncodeInt8(v int8)

func (*Buffer) EncodeString added in v0.4.0

func (b *Buffer) EncodeString(v string, length int)

func (*Buffer) EncodeUint16 added in v0.4.0

func (b *Buffer) EncodeUint16(v uint16)

func (*Buffer) EncodeUint32 added in v0.4.0

func (b *Buffer) EncodeUint32(v uint32)

func (*Buffer) EncodeUint64 added in v0.4.0

func (b *Buffer) EncodeUint64(v uint64)

func (*Buffer) EncodeUint8 added in v0.4.0

func (b *Buffer) EncodeUint8(v uint8)

type Marshaler added in v0.4.0

type Marshaler interface {
	Size() int
	Marshal([]byte) ([]byte, error)
}

Marshaler is the interface implemented by the binary API messages that can marshal itself into binary form for the wire.

type MsgCodec

type MsgCodec struct{}

MsgCodec provides encoding and decoding functionality of `api.Message` structs into/from binary format as accepted by VPP.

func (*MsgCodec) DecodeMsg

func (*MsgCodec) DecodeMsg(data []byte, msg api.Message) (err error)

func (*MsgCodec) DecodeMsgContext

func (*MsgCodec) DecodeMsgContext(data []byte, msgType api.MessageType) (context uint32, err error)

func (*MsgCodec) EncodeMsg

func (*MsgCodec) EncodeMsg(msg api.Message, msgID uint16) (data []byte, err error)

type Unmarshaler added in v0.4.0

type Unmarshaler interface {
	Unmarshal([]byte) error
}

Unmarshaler is the interface implemented by the binary API messages that can unmarshal a binary representation of itself from the wire.

type Wrapper added in v0.4.0

type Wrapper struct {
	api.Message
}

func (Wrapper) Marshal added in v0.4.0

func (w Wrapper) Marshal(b []byte) ([]byte, error)

func (Wrapper) Size added in v0.4.0

func (w Wrapper) Size() int

func (Wrapper) Unmarshal added in v0.4.0

func (w Wrapper) Unmarshal(data []byte) error

Jump to

Keyboard shortcuts

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