format

package
v0.0.0-...-8fcca98 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const EncodingOffset int = 2
View Source
const EnvelopeOffset int = 2

Variables

This section is empty.

Functions

func EnvelopeMetadataFromPayload

func EnvelopeMetadataFromPayload(unencodedPayload []byte) (EnvelopeFormat, Version)

func IsEnveloped

func IsEnveloped(data []byte) bool

func MarshalEnvelope

func MarshalEnvelope(format EnvelopeFormat, model Versioner) ([]byte, error)

func MarshalJSON

func MarshalJSON(v Versioner) ([]byte, error)

func MarshalProto

func MarshalProto(v ProtoVersioner) ([]byte, error)

func UnmarshalEnvelope

func UnmarshalEnvelope(logger lager.Logger, unencodedPayload []byte, model Versioner) error

func UnmarshalJSON

func UnmarshalJSON(logger lager.Logger, marshaledPayload []byte, model Versioner) error

func UnmarshalProto

func UnmarshalProto(logger lager.Logger, marshaledPayload []byte, model ProtoVersioner) error

Types

type Encoder

type Encoder interface {
	Encode(encoding Encoding, payload []byte) ([]byte, error)
	Decode(payload []byte) ([]byte, error)
}

func NewEncoder

func NewEncoder(cryptor encryption.Cryptor) Encoder

type Encoding

type Encoding [EncodingOffset]byte
var (
	LEGACY_UNENCODED Encoding = [2]byte{}
	UNENCODED        Encoding = [2]byte{'0', '0'}
	BASE64           Encoding = [2]byte{'0', '1'}
	BASE64_ENCRYPTED Encoding = [2]byte{'0', '2'}
)

type EnvelopeFormat

type EnvelopeFormat byte
const (
	LEGACY_JSON EnvelopeFormat = 0
	JSON        EnvelopeFormat = 1
	PROTO       EnvelopeFormat = 2
)

type Format

type Format struct {
	Encoding
	EnvelopeFormat
}
var (
	LEGACY_FORMATTING *Format = NewFormat(LEGACY_UNENCODED, LEGACY_JSON)
	FORMATTED_JSON    *Format = NewFormat(UNENCODED, JSON)
	ENCODED_PROTO     *Format = NewFormat(BASE64, PROTO)
	ENCRYPTED_PROTO   *Format = NewFormat(BASE64_ENCRYPTED, PROTO)
)

func NewFormat

func NewFormat(encoding Encoding, format EnvelopeFormat) *Format

type ProtoVersioner

type ProtoVersioner interface {
	proto.Message
	Versioner
}

type Serializer

type Serializer interface {
	Marshal(logger lager.Logger, format *Format, model Versioner) ([]byte, error)
	Unmarshal(logger lager.Logger, encodedPayload []byte, model Versioner) error
}

func NewSerializer

func NewSerializer(cryptor encryption.Cryptor) Serializer

type Version

type Version byte
const (
	V0 Version = 0
)

type Versioner

type Versioner interface {
	MigrateFromVersion(v Version) error
	Validate() error
	Version() Version
}

Directories

Path Synopsis
This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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