protoconv

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2017 License: Apache-2.0 Imports: 8 Imported by: 8 modules, 30 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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