package value12import (3"fmt"4)56// Capsule is a marker interface for Go values which forces a type to be7// represented as a River capsule. This is useful for types whose underlying8// value is not a capsule, such as:9//10// // Secret is a secret value. It would normally be a River string since the11// // underlying Go type is string, but it's a capsule since it implements12// // the Capsule interface.13// type Secret string14//15// func (s Secret) RiverCapsule() {}16//17// Extension interfaces are used to describe additional behaviors for Capsules.18// ConvertibleCapsule allows defining custom conversion rules to convert19// between other Go values.20type Capsule interface {21RiverCapsule()22}2324// ErrNoConversion is returned by implementations of ConvertibleCapsule to25// denote that a custom conversion from or to a specific type is unavailable.26var ErrNoConversion = fmt.Errorf("no custom capsule conversion available")2728// ConvertibleFromCapsule is a Capsule which supports custom conversion rules29// from any Go type which is not the same as the capsule type.30type ConvertibleFromCapsule interface {31Capsule3233// ConvertFrom should modify the ConvertibleCapsule value based on the value34// of src.35//36// ConvertFrom should return ErrNoConversion if no conversion is available37// from src.38ConvertFrom(src interface{}) error39}4041// ConvertibleIntoCapsule is a Capsule which supports custom conversion rules42// into any Go type which is not the same as the capsule type.43type ConvertibleIntoCapsule interface {44Capsule4546// ConvertInto should convert its value and store it into dst. dst will be a47// pointer to a value which ConvertInto is expected to update.48//49// ConvertInto should return ErrNoConversion if no conversion into dst is50// available.51ConvertInto(dst interface{}) error52}535455