resource

package
v0.0.9-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package resource interfaces retrieval of bytecode, output templates and external code execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeFunc

type CodeFunc func(sym string) ([]byte, error)

type EntryFunc

type EntryFunc func(sym string, input []byte, ctx context.Context) (Result, error)

EntryFunc is a function signature for retrieving value for a key

type FsResource

type FsResource struct {
	MenuResource
	Path string
	// contains filtered or unexported fields
}

func NewFsResource

func NewFsResource(path string) FsResource

func (*FsResource) AddLocalFunc

func (fs *FsResource) AddLocalFunc(sym string, fn EntryFunc)

func (FsResource) FuncFor

func (fs FsResource) FuncFor(sym string) (EntryFunc, error)

func (FsResource) GetCode

func (fs FsResource) GetCode(sym string) ([]byte, error)

func (FsResource) GetTemplate

func (fs FsResource) GetTemplate(sym string) (string, error)

func (FsResource) String

func (fs FsResource) String() string

type FuncForFunc

type FuncForFunc func(sym string) (EntryFunc, error)
type MenuResource struct {
	// contains filtered or unexported fields
}

MenuResource contains the base definition for building Resource implementations.

TODO: Rename to BaseResource

func NewMenuResource

func NewMenuResource() *MenuResource

NewMenuResource creates a new MenuResource instance.

func (m *MenuResource) FuncFor(sym string) (EntryFunc, error)

FuncFor implements Resource interface

func (m *MenuResource) GetCode(sym string) ([]byte, error)

GetCode implements Resource interface

func (m *MenuResource) GetTemplate(sym string) (string, error)

GetTemplate implements Resource interface

func (m *MenuResource) WithCodeGetter(codeGetter CodeFunc) *MenuResource

WithCodeGetter sets the code symbol resolver method.

func (m *MenuResource) WithEntryFuncGetter(entryFuncGetter FuncForFunc) *MenuResource

WithEntryGetter sets the content symbol resolver getter method.

func (m *MenuResource) WithTemplateGetter(templateGetter TemplateFunc) *MenuResource

WithTemplateGetter sets the template symbol resolver method.

type Resource

type Resource interface {
	GetTemplate(sym string) (string, error) // Get the template for a given symbol.
	GetCode(sym string) ([]byte, error)     // Get the bytecode for the given symbol.
	FuncFor(sym string) (EntryFunc, error)  // Resolve symbol content point for.
}

Resource implementation are responsible for retrieving values and templates for symbols, and can render templates from value dictionaries.

type Result

type Result struct {
	Content   string   // content value for symbol after execution.
	FlagSet   []uint32 // request caller to set error flags at given indices.
	FlagReset []uint32 // request caller to reset error flags at given indices.
}

Result contains the results of an external code operation.

type StateResource

type StateResource struct {
	Resource
	// contains filtered or unexported fields
}

func NewStateResource

func NewStateResource(st *state.State) *StateResource

func ToStateResource

func ToStateResource(rs Resource) *StateResource

func (*StateResource) WithState

func (sr *StateResource) WithState(st *state.State) *StateResource

type TemplateFunc

type TemplateFunc func(sym string) (string, error)

Jump to

Keyboard shortcuts

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