Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoConversion = value.ErrNoConversion
ErrNoConversion is returned by implementations of ConvertibleFromCapsule and ConvertibleToCapsule when a conversion with a specific type is unavailable.
Returning this error causes River to fall back to default conversion rules.
Functions ¶
This section is empty.
Types ¶
type Capsule ¶
type Capsule interface { // RiverCapsule marks the type as a Capsule. RiverCapsule is never invoked by // River. RiverCapsule() }
Capsule is an interface marker which tells River that a type should always be treated as a "capsule type" instead of the default type River would assign.
Capsule types are useful for passing around arbitrary Go values in River expressions and for declaring new synthetic types with custom conversion rules.
By default, only two capsule values of the same underlying Go type are compatible. Types which implement ConvertibleFromCapsule or ConvertibleToCapsule can provide custom logic for conversions from and to other types.
type ConvertibleFromCapsule ¶
type ConvertibleFromCapsule interface { Capsule // ConvertFrom updates the ConvertibleFromCapsule value based on the value of // src. src may be any Go value, not just other capsules. // // ConvertFrom should return ErrNoConversion if no conversion is available // from src. Other errors are treated as a River decoding error. ConvertFrom(src interface{}) error }
ConvertibleFromCapsule is a Capsule which supports custom conversion from any Go type which is not the same as the capsule type.
type ConvertibleIntoCapsule ¶
type ConvertibleIntoCapsule interface { Capsule // ConvertInto should convert its value and store it into dst. dst will be a // pointer to a Go value of any type. // // ConvertInto should return ErrNoConversion if no conversion into dst is // available. Other errors are treated as a River decoding error. ConvertInto(dst interface{}) error }
ConvertibleIntoCapsule is a Capsule which supports custom conversion into into any Go type which is not the same as the capsule type.
type Unmarshaler ¶
type Unmarshaler interface { // UnmarshalRiver is invoked when decoding a River value into a Go value. f // should be called with a pointer to a value to decode into. UnmarshalRiver(f func(v interface{}) error) error }
The Unmarshaler interface allows a type to hook into River decoding and decode into another type or provide pre-decoding logic.
Directories ¶
Path | Synopsis |
---|---|
Package ast exposes AST elements used by River.
|
Package ast exposes AST elements used by River. |
Package diag exposes error types used throughout River and a method to pretty-print them to the screen.
|
Package diag exposes error types used throughout River and a method to pretty-print them to the screen. |
internal
|
|
rivertags
Package rivertags decodes a struct type into river object and structural tags.
|
Package rivertags decodes a struct type into river object and structural tags. |
stdlib
Package stdlib contains standard library functions exposed to River configs.
|
Package stdlib contains standard library functions exposed to River configs. |
value
Package value holds the internal representation for River values.
|
Package value holds the internal representation for River values. |
Package parser implements utilities for parsing River configuration files.
|
Package parser implements utilities for parsing River configuration files. |
Package printer contains utilities for pretty-printing River ASTs.
|
Package printer contains utilities for pretty-printing River ASTs. |
Package scanner implements a lexical scanner for River source files.
|
Package scanner implements a lexical scanner for River source files. |
Package token defines the lexical elements of a River config and utilities surrounding their position.
|
Package token defines the lexical elements of a River config and utilities surrounding their position. |
builder
Package builder exposes an API to create a River configuration file by constructing a set of tokens.
|
Package builder exposes an API to create a River configuration file by constructing a set of tokens. |
Package vm provides a River expression evaluator.
|
Package vm provides a River expression evaluator. |