github.com/ava-labs/avalanchego@v1.11.11/codec/codec.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package codec 5 6 import ( 7 "errors" 8 9 "github.com/ava-labs/avalanchego/utils/wrappers" 10 ) 11 12 var ( 13 ErrUnsupportedType = errors.New("unsupported type") 14 ErrMaxSliceLenExceeded = errors.New("max slice length exceeded") 15 ErrDoesNotImplementInterface = errors.New("does not implement interface") 16 ErrUnexportedField = errors.New("unexported field") 17 ErrExtraSpace = errors.New("trailing buffer space") 18 ErrMarshalZeroLength = errors.New("can't marshal zero length value") 19 ErrUnmarshalZeroLength = errors.New("can't unmarshal zero length value") 20 ) 21 22 // Codec marshals and unmarshals 23 type Codec interface { 24 MarshalInto(interface{}, *wrappers.Packer) error 25 Unmarshal([]byte, interface{}) error 26 27 // Returns the size, in bytes, of [value] when it's marshaled 28 Size(value interface{}) (int, error) 29 }