codec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package codec provides encoding and decoding utilities for message payloads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON(data []byte, v any) error

DecodeJSON is a convenience function for JSON decoding.

func DecodeProtobuf

func DecodeProtobuf(data []byte, v proto.Message) error

DecodeProtobuf is a convenience function for protobuf decoding.

func EncodeJSON

func EncodeJSON(v any) ([]byte, error)

EncodeJSON is a convenience function for JSON encoding.

func EncodeProtobuf

func EncodeProtobuf(v proto.Message) ([]byte, error)

EncodeProtobuf is a convenience function for protobuf encoding.

func MarshalMessage

func MarshalMessage(c Codec, v any) (*core.Message, error)

MarshalMessage encodes a value into a weave message and sets the content type.

func UnmarshalMessage

func UnmarshalMessage(c Codec, msg *core.Message, v any) error

UnmarshalMessage decodes a weave message body into the provided value.

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.

Jump to

Keyboard shortcuts

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