protoconv

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2017 License: Apache-2.0 Imports: 8 Imported by: 30

Documentation

Overview

Package protoconv provides a mechanism to register functions to convert objects to and from proto messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(toProto, toObject interface{})

Register registers the converters toProto and toObject. toProto must be a function with the signature:

func(context.Context, O) (P, error)

toObject must be a function with the signature:

func(context.Context, P) (O, error)

Where P is the proto message type and O is the object type.

func ToObject

func ToObject(ctx context.Context, msg proto.Message) (interface{}, error)

ToObject converts obj to a proto message using the converter registered with Register.

func ToProto

func ToProto(ctx context.Context, obj interface{}) (proto.Message, error)

ToProto converts obj to a proto message using the converter registered with Register.

Types

type ErrNoConverterRegistered

type ErrNoConverterRegistered struct {
	Object interface{}
}

ErrNoConverterRegistered is the error returned from ToProto or ToObject when the object's type is not registered for conversion.

func (ErrNoConverterRegistered) Error

func (e ErrNoConverterRegistered) Error() string

Jump to

Keyboard shortcuts

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