prim

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0, BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package prim contains primitive types used in Wasm ABI functions. It acts as a common dependency for package wasi, which provides access to general Wasi capabilities, and package fastly, which provides access to hostcalls specific to the Compute@Edge environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayChar8

type ArrayChar8 Wstring

ArrayChar8 is a header for an array of Char8.

type ArrayU8

type ArrayU8 Wstring

ArrayU8 is a header for an array of U8.

type Char8

type Char8 uint8

Char8 is an unsigned 8 bit integer.

type ReadBuffer

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

ReadBuffer is like WriteBuffer, but only allows hostcalls to read the underlying memory via a smaller, more restricted API.

func NewReadBufferFromBytes

func NewReadBufferFromBytes(buf []byte) *ReadBuffer

NewReadBufferFromBytes creates a new ReadBuffer with the provided byte slice used as its buffer.

func NewReadBufferFromString

func NewReadBufferFromString(s string) *ReadBuffer

NewReadBufferFromString creates a ReadBuffer with its buffer based on the provided string.

func (*ReadBuffer) ArrayChar8

func (b *ReadBuffer) ArrayChar8() ArrayChar8

ArrayChar8 returns the buffers data as a ArrayChar8.

func (*ReadBuffer) ArrayU8

func (b *ReadBuffer) ArrayU8() ArrayU8

ArrayU8 returns the buffers data as a ArrayU8.

func (*ReadBuffer) Char8Pointer

func (b *ReadBuffer) Char8Pointer() *Char8

Char8Pointer returns a pointer to the buffer's data as a Char8.

func (*ReadBuffer) Len

func (b *ReadBuffer) Len() Usize

Len returns the length of data in the buffer as a Usize.

func (*ReadBuffer) U8Pointer added in v0.1.4

func (b *ReadBuffer) U8Pointer() *U8

U8Pointer returns a pointer to the buffer's data as a U8.

func (*ReadBuffer) Wstring

func (b *ReadBuffer) Wstring() Wstring

Wstring returns the buffers data as a Wstring.

type U16

type U16 uint16

U16 is an unsigned 16 bit integer.

type U32

type U32 uint32

U32 is an unsigned 32 bit integer.

type U64

type U64 uint64

U64 is an unsigned 64 bit integer.

type U8

type U8 uint8

U8 is an unsigned 8 bit integer.

type Usize

type Usize uint

Usize is an unsigned integer who's size is based on the system architecture.

type WriteBuffer

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

WriteBuffer provides some memory that hostcalls can write into.

Technically, Go's GC is permitted to move memory around whenever it wants (with a few exceptions). This is normally safe, because it updates references to that memory at the same time. But unsafe.Pointer isn't understood by the GC as a reference, which means that our usage here is technically unsafe: if the GC moved the buffer around during a hostcall, the hostcall would end up writing to an invalid location.

This works fine, though, because hostcalls only happen under +build tinygo, and all of the GC implementations provided by TinyGo don't do any of that fancy stuff. But it's definitely a risk we need to be aware of when upgrading TinyGo in the future.

func NewWriteBuffer

func NewWriteBuffer(cap int) *WriteBuffer

NewWriteBuffer creates a new WriteBuffer with the provided capacity.

func NewWriteBufferFromBytes

func NewWriteBufferFromBytes(buf []byte) *WriteBuffer

NewWriteBufferFromBytes creates a new WriteBuffer with the provided byte slice used as its buffer.

func (*WriteBuffer) AsBytes

func (b *WriteBuffer) AsBytes() []byte

AsBytes returns a copy of the buffer's data as a byte slice.

func (*WriteBuffer) Cap

func (b *WriteBuffer) Cap() Usize

Cap returns the capacity of the buffer as a Usize.

func (*WriteBuffer) Char8Pointer

func (b *WriteBuffer) Char8Pointer() *Char8

Char8Pointer returns a pointer to the buffer's data as a Char8.

func (*WriteBuffer) Len

func (b *WriteBuffer) Len() Usize

Len returns the length of data in the buffer as a Usize.

func (*WriteBuffer) NPointer

func (b *WriteBuffer) NPointer() *Usize

NPointer returns a pointer to the number of bytes written to th buffer as a Usize.

func (*WriteBuffer) NValue

func (b *WriteBuffer) NValue() Usize

NValue returns the number of bytes written to th buffer as a Usize.

func (*WriteBuffer) ToString

func (b *WriteBuffer) ToString() string

ToString returns a copy of the buffer's data as a string.

func (*WriteBuffer) U8Pointer

func (b *WriteBuffer) U8Pointer() *U8

U8Pointer returns a pointer to the buffer's data as a U8.

type Wstring

type Wstring struct {
	Data uintptr
	Len  uint
}

Wstring is a header for a string.

Jump to

Keyboard shortcuts

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