Documentation
¶
Index ¶
- Constants
- func Base64Decode(ctx context.Context, input []types.Value) (types.Value, error)
- func Base64Encode(ctx context.Context, input []types.Value) (types.Value, error)
- type DecodeJSONFunc
- func (obj *DecodeJSONFunc) ArgGen(index int) (string, error)
- func (obj *DecodeJSONFunc) Build(typ *types.Type) (*types.Type, error)
- func (obj *DecodeJSONFunc) Call(ctx context.Context, args []types.Value) (types.Value, error)
- func (obj *DecodeJSONFunc) Copy() interfaces.Func
- func (obj *DecodeJSONFunc) FuncInfer(partialType *types.Type, partialValues []types.Value) (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *DecodeJSONFunc) Info() *interfaces.Info
- func (obj *DecodeJSONFunc) Init(init *interfaces.Init) error
- func (obj *DecodeJSONFunc) String() string
- func (obj *DecodeJSONFunc) Validate() error
Constants ¶
const (
// DecodeJSONFuncName is the name this function is registered as.
DecodeJSONFuncName = "decode_json"
)
const (
// ModuleName is the prefix given to all the functions in this module.
ModuleName = "encoding"
)
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶
Base64Decode decodes a string with the standard base64 encoding. It errors if the input is not valid base64.
Types ¶
type DecodeJSONFunc ¶
type DecodeJSONFunc struct {
interfaces.Textarea
// Type is the type of the type specification (2nd) arg if one is
// specified. Nil is the special undetermined value that is used before
// type is known.
Type *types.Type // type of return value
// contains filtered or unexported fields
}
DecodeJSONFunc is a static polymorphic function that accepts some json data and returns an mcl struct representing that data. You currently should pass in an mcl type representation in the second arg so that we know what type to parse the json as. There are some cases when the type can be inferred, and you don't need to specify the second arg. It's your problem if the type unification doesn't work though! The "flexible" version of this function differs in that if a struct field is present in the type, but missing from the data, then it will substitute a zero value for the data instead of erroring. This is useful for cases when you have an initial schema represented by the type in your mcl code, and you gradually expand it over time before the data has caught up and added all those new fields.
func (*DecodeJSONFunc) ArgGen ¶
func (obj *DecodeJSONFunc) ArgGen(index int) (string, error)
ArgGen returns the Nth arg name for this function.
func (*DecodeJSONFunc) Build ¶
Build takes the now known function signature and stores it so that this function can appear to be static.
func (*DecodeJSONFunc) Call ¶
Call this function with the input args and return the value if it is possible to do so at this time.
func (*DecodeJSONFunc) Copy ¶
func (obj *DecodeJSONFunc) Copy() interfaces.Func
Copy is implemented so that the obj.built value is not lost if we copy this function.
func (*DecodeJSONFunc) FuncInfer ¶
func (obj *DecodeJSONFunc) FuncInfer(partialType *types.Type, partialValues []types.Value) (*types.Type, []*interfaces.UnificationInvariant, error)
FuncInfer takes partial type and value information from the call site of this function so that it can build an appropriate type signature for it. The type signature may include unification variables.
func (*DecodeJSONFunc) Info ¶
func (obj *DecodeJSONFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*DecodeJSONFunc) Init ¶
func (obj *DecodeJSONFunc) Init(init *interfaces.Init) error
Init runs some startup code for this function.
func (*DecodeJSONFunc) String ¶
func (obj *DecodeJSONFunc) String() string
String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.
func (*DecodeJSONFunc) Validate ¶
func (obj *DecodeJSONFunc) Validate() error
Validate makes sure we've built our struct properly. It is usually unused for normal functions that users can use directly.