coreencoding

package
v0.0.0-...-eabde3b Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DecodeJSONFuncName is the name this function is registered as.
	DecodeJSONFuncName = "decode_json"
)
View Source
const (
	// ModuleName is the prefix given to all the functions in this module.
	ModuleName = "encoding"
)

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(ctx context.Context, input []types.Value) (types.Value, error)

Base64Decode decodes a string with the standard base64 encoding. It errors if the input is not valid base64.

func Base64Encode

func Base64Encode(ctx context.Context, input []types.Value) (types.Value, error)

Base64Encode encodes a string with the standard base64 encoding.

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

func (obj *DecodeJSONFunc) Build(typ *types.Type) (*types.Type, error)

Build takes the now known function signature and stores it so that this function can appear to be static.

func (*DecodeJSONFunc) Call

func (obj *DecodeJSONFunc) Call(ctx context.Context, args []types.Value) (types.Value, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL