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 ¶
- type ArrayChar8
- type ArrayU8
- type Char8
- type ReadBuffer
- type U16
- type U32
- type U64
- type U8
- type Usize
- type WriteBuffer
- func (b *WriteBuffer) AsBytes() []byte
- func (b *WriteBuffer) Cap() Usize
- func (b *WriteBuffer) Char8Pointer() *Char8
- func (b *WriteBuffer) Len() Usize
- func (b *WriteBuffer) NPointer() *Usize
- func (b *WriteBuffer) NValue() Usize
- func (b *WriteBuffer) ToString() string
- func (b *WriteBuffer) U8Pointer() *U8
- type Wstring
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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.