Documentation ¶
Overview ¶
Package codec is a generated GoMock package.
Index ¶
- Constants
- Variables
- type Codec
- type GeneralCodec
- type Manager
- type MockManager
- func (m *MockManager) EXPECT() *MockManagerMockRecorder
- func (m *MockManager) Marshal(arg0 uint16, arg1 any) ([]byte, error)
- func (m *MockManager) RegisterCodec(arg0 uint16, arg1 Codec) error
- func (m *MockManager) Size(arg0 uint16, arg1 any) (int, error)
- func (m *MockManager) Unmarshal(arg0 []byte, arg1 any) (uint16, error)
- type MockManagerMockRecorder
- type Registry
Constants ¶
View Source
const (
VersionSize = wrappers.ShortLen
)
Variables ¶
View Source
var ( ErrUnsupportedType = errors.New("unsupported type") ErrMaxSliceLenExceeded = errors.New("max slice length exceeded") ErrDoesNotImplementInterface = errors.New("does not implement interface") ErrUnexportedField = errors.New("unexported field") ErrExtraSpace = errors.New("trailing buffer space") ErrMarshalZeroLength = errors.New("can't marshal zero length value") ErrUnmarshalZeroLength = errors.New("can't unmarshal zero length value") )
View Source
var ( ErrUnknownVersion = errors.New("unknown codec version") ErrMarshalNil = errors.New("can't marshal nil pointer or interface") ErrUnmarshalNil = errors.New("can't unmarshal nil") ErrUnmarshalTooBig = errors.New("byte array exceeds maximum length") ErrCantPackVersion = errors.New("couldn't pack codec version") ErrCantUnpackVersion = errors.New("couldn't unpack codec version") ErrDuplicatedVersion = errors.New("duplicated codec version") )
View Source
var ErrDuplicateType = errors.New("duplicate type registration")
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec interface { MarshalInto(interface{}, *wrappers.Packer) error Unmarshal([]byte, interface{}) error // Returns the size, in bytes, of [value] when it's marshaled Size(value interface{}) (int, error) }
Codec marshals and unmarshals
type GeneralCodec ¶
GeneralCodec marshals and unmarshals structs including interfaces
type Manager ¶
type Manager interface { // Associate the given codec with the given version ID RegisterCodec(version uint16, codec Codec) error // Size returns the size, in bytes, of [value] when it's marshaled // using the codec with the given version. // RegisterCodec must have been called with that version. // If [value] is nil, returns [ErrMarshalNil] Size(version uint16, value interface{}) (int, error) // Marshal the given value using the codec with the given version. // RegisterCodec must have been called with that version. Marshal(version uint16, source interface{}) (destination []byte, err error) // Unmarshal the given bytes into the given destination. [destination] must // be a pointer or an interface. Returns the version of the codec that // produces the given bytes. Unmarshal(source []byte, destination interface{}) (version uint16, err error) }
Manager describes the functionality for managing codec versions.
func NewDefaultManager ¶
func NewDefaultManager() Manager
NewDefaultManager returns a new codec manager.
type MockManager ¶ added in v1.9.12
type MockManager struct {
// contains filtered or unexported fields
}
MockManager is a mock of Manager interface.
func NewMockManager ¶ added in v1.9.12
func NewMockManager(ctrl *gomock.Controller) *MockManager
NewMockManager creates a new mock instance.
func (*MockManager) EXPECT ¶ added in v1.9.12
func (m *MockManager) EXPECT() *MockManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockManager) Marshal ¶ added in v1.9.12
func (m *MockManager) Marshal(arg0 uint16, arg1 any) ([]byte, error)
Marshal mocks base method.
func (*MockManager) RegisterCodec ¶ added in v1.9.12
func (m *MockManager) RegisterCodec(arg0 uint16, arg1 Codec) error
RegisterCodec mocks base method.
type MockManagerMockRecorder ¶ added in v1.9.12
type MockManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockManagerMockRecorder is the mock recorder for MockManager.
func (*MockManagerMockRecorder) Marshal ¶ added in v1.9.12
func (mr *MockManagerMockRecorder) Marshal(arg0, arg1 any) *gomock.Call
Marshal indicates an expected call of Marshal.
func (*MockManagerMockRecorder) RegisterCodec ¶ added in v1.9.12
func (mr *MockManagerMockRecorder) RegisterCodec(arg0, arg1 any) *gomock.Call
RegisterCodec indicates an expected call of RegisterCodec.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package codectest provides a test suite for testing codec implementations.
|
Package codectest provides a test suite for testing codec implementations. |
Click to show internal directories.
Click to hide internal directories.