host

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAddrOverflow         = errors.New("addr overflow")
	ErrInstanceNotStart     = errors.New("instance has not started")
	ErrInstanceAlreadyStart = errors.New("instance has already started")
	ErrInvalidParam         = errors.New("invalid param")
	ErrRegisterNotFunc      = errors.New("register a non-func object")
	ErrRegisterArgNum       = errors.New("register func with invalid arg num")
	ErrRegisterArgType      = errors.New("register func with invalid arg type")
)

Functions

This section is empty.

Types

type HeaderMap

type HeaderMap map[string]string

HeaderMap is a simple implementation of HeaderMap.

func (HeaderMap) Add

func (h HeaderMap) Add(key string, value string)

Add value for given key. Multiple headers with the same key may be added with this function. Use Set for setting a single header for the given key.

func (HeaderMap) ByteSize

func (h HeaderMap) ByteSize() uint64

ByteSize return size of HeaderMap

func (HeaderMap) Clone

func (h HeaderMap) Clone() HeaderMap

Clone used to deep copy header's map

func (HeaderMap) Del

func (h HeaderMap) Del(key string)

Del delete pair of specified key

func (HeaderMap) Get

func (h HeaderMap) Get(key string) (value string, ok bool)

Get value of key If multiple values associated with this key, first one will be returned.

func (HeaderMap) Range

func (h HeaderMap) Range(f func(key, value string) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (HeaderMap) Set

func (h HeaderMap) Set(key string, value string)

Set key-value pair in header map, the previous pair will be replaced if exists

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

func NewWasmerInstance

func NewWasmerInstance(vm *VM, module *Module, options ...InstanceOptions) *Instance

func NewWasmerInstanceFromFile

func NewWasmerInstanceFromFile(path string) *Instance

func (*Instance) Acquire

func (w *Instance) Acquire() bool

func (*Instance) GetByte

func (w *Instance) GetByte(addr uint64) (byte, error)

func (*Instance) GetData

func (w *Instance) GetData() interface{}

func (*Instance) GetExportsFunc

func (w *Instance) GetExportsFunc(funcName string) (*wasmer.Function, error)

func (*Instance) GetExportsMem

func (w *Instance) GetExportsMem(memName string) ([]byte, error)

func (*Instance) GetMemory

func (w *Instance) GetMemory(addr uint64, size uint64) ([]byte, error)

func (*Instance) GetModule

func (w *Instance) GetModule() *Module

func (*Instance) GetUint32

func (w *Instance) GetUint32(addr uint64) (uint32, error)

func (*Instance) HandleError

func (w *Instance) HandleError(err error)

func (*Instance) Lock

func (w *Instance) Lock(data interface{})

func (*Instance) Malloc

func (w *Instance) Malloc(size int32) (uint64, error)

func (*Instance) PutByte

func (w *Instance) PutByte(addr uint64, b byte) error

func (*Instance) PutMemory

func (w *Instance) PutMemory(addr uint64, size uint64, content []byte) error

func (*Instance) PutUint32

func (w *Instance) PutUint32(addr uint64, value uint32) error

func (*Instance) RegisterFunc

func (w *Instance) RegisterFunc(namespace string, funcName string, f interface{}) error

func (*Instance) Release

func (w *Instance) Release()

func (*Instance) SetData

func (w *Instance) SetData(data interface{})

func (*Instance) Start

func (w *Instance) Start() error

func (*Instance) Stop

func (w *Instance) Stop()

func (*Instance) Unlock

func (w *Instance) Unlock()

type InstanceOptions

type InstanceOptions func(instance *Instance)

type IoBuffer

type IoBuffer struct {
	// contains filtered or unexported fields
}

IoBuffer is a simple implementation of IoBuffer.

func NewIoBufferBytes

func NewIoBufferBytes(data []byte) *IoBuffer

func (*IoBuffer) Bytes

func (c *IoBuffer) Bytes() []byte

Bytes returns all bytes from buffer, without draining any buffered data. It can be used to get fixed-length content, such as headers, body. Note: do not change content in return bytes, use write instead

func (*IoBuffer) Drain

func (c *IoBuffer) Drain(offset int)

Drain drains a offset length of bytes in buffer. It can be used with Bytes(), after consuming a fixed-length of data

func (*IoBuffer) Len

func (c *IoBuffer) Len() int

Len returns the number of bytes of the unread portion of the buffer; b.Len() == len(b.Bytes()).

func (*IoBuffer) Write

func (c *IoBuffer) Write(p []byte) (n int, err error)

Write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with ErrTooLarge.

type Module

type Module struct {
	// contains filtered or unexported fields
}

func NewWasmerModule

func NewWasmerModule(vm *VM, module *wasmer.Module, wasmBytes []byte) *Module

func (*Module) GetABINameList

func (w *Module) GetABINameList() []string

func (*Module) Init

func (w *Module) Init()

func (*Module) NewInstance

func (w *Module) NewInstance() *Instance

type VM

type VM struct {
	// contains filtered or unexported fields
}

func NewWasmerVM

func NewWasmerVM() *VM

func (*VM) Init

func (w *VM) Init()

func (*VM) Name

func (w *VM) Name() string

func (*VM) NewModule

func (w *VM) NewModule(wasmBytes []byte) *Module

Jump to

Keyboard shortcuts

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