codecs

package
v0.0.0-...-cdca0d4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package codecs implements available encoding formats used for client<->host communication. All I/O operations and direct memory access between the client and host will be handled by a WasmCodec.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoding

type Encoding uint8
const (
	MSGP Encoding = iota + 1
	JSON
)

type RpcArgs

type RpcArgs interface {
	msgp.Unmarshaler
}

type RpcResp

type RpcResp interface {
	msgp.MarshalSizer
}

type WasmCodec

type WasmCodec interface {
	// DecodeRequest must read from the codecs buffer and return the RPC header information
	DecodeRequest() (method string, seq uint32, err error)
	// DecodeArgs must read from the codecs buffer and unmarshal arguments into args
	DecodeArgs(args RpcArgs) error
	// EncodeResp must write the encoded response to the codecs buffer.
	// If the buffer doesn't have the capacity to hold the response 0 bytes must be written.
	// Partial results are not allowed.
	EncodeResp(seq uint32, err error, resp RpcResp) (n int)
}

A WasmCodec represents a memory region allocated by the client containing encoded RPC requests/responses. This memory region should only be modified using this interface to preserve a compatible client encoding.

func ConvertMessageToCodec

func ConvertMessageToCodec(msg []byte, enc Encoding) WasmCodec

ConvertMessageToCodec prepares a client allocated memory region for processing using WasmCodec

Source Files

  • codecs.go
  • msgp.go

Jump to

Keyboard shortcuts

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