Documentation ¶
Index ¶
- Variables
- func BlindMap(value interface{}, mappers []*argmapper.Func, args ...argmapper.Arg) (interface{}, error)
- func CallFunc(f interface{}, expectedType interface{}, mappers []*argmapper.Func, ...) (interface{}, error)
- func DecodeAny(input *anypb.Any) (t reflect.Type, r interface{}, err error)
- func EncodeAny(input proto.Message) (*anypb.Any, error)
- func Map(value, expectedType interface{}, args ...argmapper.Arg) (interface{}, error)
- func MapFromWellKnownProto(input proto.Message) (interface{}, error)
- func MapToWellKnownProto(input interface{}) (proto.Message, error)
- func UnknownMap(value, expectedType interface{}, mappers []*argmapper.Func, ...) (interface{}, error)
- type SpecAndFunc
Constants ¶
This section is empty.
Variables ¶
var Logger hclog.Logger
var WellKnownTypeFns []*argmapper.Func
Functions ¶
func BlindMap ¶
func BlindMap( value interface{}, mappers []*argmapper.Func, args ...argmapper.Arg, ) (interface{}, error)
This converts a value to another value using the provided mappers without any required type information. It is similar to the UnknownMap function but the expected type is not required. Due to this missing information, however, this function will be slower as it iterates the entire mapper list provided and attempts to call any function who's input signature includes a matching type for the given value.
func CallFunc ¶
func CallFunc( f interface{}, expectedType interface{}, mappers []*argmapper.Func, args ...argmapper.Arg, ) (interface{}, error)
Calls the function provided and converts the result to an expected type. If no type conversion is required, a `false` value for the expectedType will return the raw interface return value.
func Map ¶
func Map( value, expectedType interface{}, args ...argmapper.Arg, ) (interface{}, error)
Convert a value to an expected type. Converter functions should be included in the args list. It is important to note that the expectedType is a pointer to the desired type (including interfaces). For example, if an `int` is wanted, the expectedType would be `(*int)(nil)`.
func MapFromWellKnownProto ¶
Map a well known proto to value
func MapToWellKnownProto ¶
Map a well known value to proto
func UnknownMap ¶
func UnknownMap( value, expectedType interface{}, mappers []*argmapper.Func, args ...argmapper.Arg, ) (interface{}, error)
Convert a value to another value using provided mappers. This can be useful for converting a received value (like a proto) into an internal value. It works by searching the list of provided mappers for a functions that support an input argument of the type that matches (or satisfies) the given value. Extra args can be provided which are used when applying the mapping to convert the value. The expected type can be useful where a generic interface may be expected (like proto.Message).
Types ¶
type SpecAndFunc ¶
type SpecAndFunc struct { Func *argmapper.Func Spec *vagrant_plugin_sdk.FuncSpec }
Wraps an argmapper Func with a FuncSpec definition to allow easy reuse with wrapped clients