Documentation
¶
Overview ¶
Package codec provides encoding and decoding utilities for message payloads.
Index ¶
- func DecodeJSON(data []byte, v any) error
- func DecodeProtobuf(data []byte, v proto.Message) error
- func EncodeJSON(v any) ([]byte, error)
- func EncodeProtobuf(v proto.Message) ([]byte, error)
- func MarshalMessage(c Codec, v any) (*core.Message, error)
- func UnmarshalMessage(c Codec, msg *core.Message, v any) error
- type Codec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeJSON ¶
DecodeJSON is a convenience function for JSON decoding.
func DecodeProtobuf ¶
DecodeProtobuf is a convenience function for protobuf decoding.
func EncodeJSON ¶
EncodeJSON is a convenience function for JSON encoding.
func EncodeProtobuf ¶
EncodeProtobuf is a convenience function for protobuf encoding.
func MarshalMessage ¶
MarshalMessage encodes a value into a weave message and sets the content type.
Types ¶
type Codec ¶
type Codec interface {
Encode(v any) ([]byte, error)
Decode(data []byte, v any) error
ContentType() string
}
Codec defines the interface for message encoding and decoding.
var JSON Codec = &jsonCodec{}
JSON is the default JSON codec.
var Protobuf Codec = &protobufCodec{}
Protobuf encodes payloads using Protocol Buffers.
Click to show internal directories.
Click to hide internal directories.