Documentation
¶
Index ¶
Constants ¶
View Source
const JSONApplicationType = "application/json"
View Source
const ProtocolBuffersApplicationType = "application/x-google-protobuf"
ProtocolBuffersApplicationType the ProtocolBuffers application type.
Variables ¶
View Source
var ErrCodecNotFound = errors.New("streams: codec not found")
ErrCodecNotFound the specified codec is not registered in streams' codec package.
View Source
var (
ErrInvalidFormat = errors.New("streams.codec: received invalid format")
)
Functions ¶
Types ¶
type Codec ¶
type Codec interface { // Encode encodes the given input into an array of bytes using an underlying serialization type. Encode(v any) ([]byte, error) // Decode decodes the given input of an array of bytes into a Go type using an underlying serialization type. // // Go type MUST be a pointer reference so serializer can append data into it. Decode(src []byte, dst any) error // ApplicationType returns the RFC application type of the underlying serializer implementation // (e.g. application/json). ApplicationType() string }
A Codec is a device or computer program that encodes or decodes a data stream or signal.
type Mock ¶
type Mock struct { EncodeBytes []byte EncodeError error DecodeError error ApplicationTypeString string }
A Mock is a dummy type of Codec ready to be used for testing purposes.
func (Mock) ApplicationType ¶
type ProtocolBuffers ¶
type ProtocolBuffers struct{}
The ProtocolBuffers codec is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs to communicate with each other over a network or for storing data.
func (ProtocolBuffers) ApplicationType ¶
func (b ProtocolBuffers) ApplicationType() string
Click to show internal directories.
Click to hide internal directories.