ffi

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ABIVersion encodes the expected native ABI as 0xMMMMmmmm (16-bit major,
	// 16-bit minor). It must match PURE_SIMDJSON_ABI_VERSION exported by the
	// Rust shim; bumping major signals a breaking C-ABI change.
	ABIVersion             uint32 = 0x00010002
	LastErrorOffsetUnknown uint64 = ^uint64(0)
)

Variables

This section is empty.

Functions

func ProbeABI added in v0.1.5

func ProbeABI(handle uintptr, lookup SymbolLookup) (uint32, error)

Types

type ArrayIter

type ArrayIter struct {
	Doc      DocHandle
	State0   uint64
	State1   uint64
	Index    uint32
	Tag      uint16
	Reserved uint16
}

type Bindings

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

func Bind

func Bind(handle uintptr, lookup SymbolLookup) (*Bindings, error)

func (*Bindings) ABI

func (b *Bindings) ABI() (uint32, int32)

func (*Bindings) ArrayIterNew

func (b *Bindings) ArrayIterNew(view *ValueView) (ArrayIter, int32)

func (*Bindings) ArrayIterNext

func (b *Bindings) ArrayIterNext(iter *ArrayIter) (ValueView, bool, int32)

func (*Bindings) BytesFree

func (b *Bindings) BytesFree(ptr *byte, length uintptr) int32

func (*Bindings) DocFree

func (b *Bindings) DocFree(doc DocHandle) int32

func (*Bindings) DocRoot

func (b *Bindings) DocRoot(doc DocHandle) (ValueView, int32)

func (*Bindings) ElementGetBigInt added in v0.1.5

func (b *Bindings) ElementGetBigInt(view *ValueView) (string, int32)

func (*Bindings) ElementGetBool

func (b *Bindings) ElementGetBool(view *ValueView) (bool, int32)

func (*Bindings) ElementGetFloat64

func (b *Bindings) ElementGetFloat64(view *ValueView) (float64, int32)

func (*Bindings) ElementGetInt64

func (b *Bindings) ElementGetInt64(view *ValueView) (int64, int32)

func (*Bindings) ElementGetString

func (b *Bindings) ElementGetString(view *ValueView) (string, int32)

func (*Bindings) ElementGetUint64

func (b *Bindings) ElementGetUint64(view *ValueView) (uint64, int32)

func (*Bindings) ElementIsNull

func (b *Bindings) ElementIsNull(view *ValueView) (bool, int32)

func (*Bindings) ElementType

func (b *Bindings) ElementType(view *ValueView) (uint32, int32)

func (*Bindings) HasInternalMaterializeBuild

func (b *Bindings) HasInternalMaterializeBuild() bool

func (*Bindings) HasNativeAllocStats

func (b *Bindings) HasNativeAllocStats() bool

func (*Bindings) ImplementationName

func (b *Bindings) ImplementationName() (string, int32)

func (*Bindings) InternalMaterializeBuild

func (b *Bindings) InternalMaterializeBuild(view *ValueView) ([]InternalFrame, int32)

InternalMaterializeBuild returns a borrowed frame span whose backing storage lives in the C++ doc (psimdjson_doc::materialize_frames). The caller must consume or copy out of the slice before the next InternalMaterializeBuild call on the same doc, which clears and reuses that buffer. Keep the owning doc alive (runtime.KeepAlive) for the full duration of any read of the returned span.

func (*Bindings) LockImplementationSelection added in v0.1.5

func (b *Bindings) LockImplementationSelection() int32

func (*Bindings) NativeAllocStatsReset

func (b *Bindings) NativeAllocStatsReset() int32

func (*Bindings) NativeAllocStatsSnapshot

func (b *Bindings) NativeAllocStatsSnapshot() (NativeAllocStats, int32)

func (*Bindings) ObjectGetField

func (b *Bindings) ObjectGetField(view *ValueView, key string) (ValueView, int32)

func (*Bindings) ObjectIterNew

func (b *Bindings) ObjectIterNew(view *ValueView) (ObjectIter, int32)

func (*Bindings) ObjectIterNext

func (b *Bindings) ObjectIterNext(iter *ObjectIter) (ValueView, ValueView, bool, int32)

func (*Bindings) ParserFree

func (b *Bindings) ParserFree(parser ParserHandle) int32

func (*Bindings) ParserLastError

func (b *Bindings) ParserLastError(parser ParserHandle) (string, int32)

func (*Bindings) ParserLastErrorHasOffset added in v0.1.5

func (b *Bindings) ParserLastErrorHasOffset(parser ParserHandle) (bool, int32)

func (*Bindings) ParserLastErrorOffset

func (b *Bindings) ParserLastErrorOffset(parser ParserHandle) (uint64, int32)

func (*Bindings) ParserNew

func (b *Bindings) ParserNew() (ParserHandle, int32)

func (*Bindings) ParserNewConfigured added in v0.1.5

func (b *Bindings) ParserNewConfigured(maxCapacity uint64, maxDepth uint32) (ParserHandle, int32)

func (*Bindings) ParserParse

func (b *Bindings) ParserParse(parser ParserHandle, data []byte) (DocHandle, int32)

func (*Bindings) SetImplementation added in v0.1.5

func (b *Bindings) SetImplementation(name string) int32

type DocHandle

type DocHandle uint64

type ErrorCode

type ErrorCode int32
const (
	// Values in this block must stay in lockstep with pure_simdjson.h and
	// src/lib.rs; they are part of the cross-ABI error contract.
	OK                 ErrorCode = 0
	ErrInvalidArg      ErrorCode = 1
	ErrInvalidHandle   ErrorCode = 2
	ErrParserBusy      ErrorCode = 3
	ErrWrongType       ErrorCode = 4
	ErrElementNotFound ErrorCode = 5
	ErrBufferTooSmall  ErrorCode = 6
	ErrNotImplemented  ErrorCode = 7
	ErrDepthLimit      ErrorCode = 8
	ErrCapacityLimit   ErrorCode = 9
	ErrKernelLocked    ErrorCode = 10

	ErrInvalidJSON      ErrorCode = 32
	ErrNumberOutOfRange ErrorCode = 33
	ErrPrecisionLoss    ErrorCode = 34

	ErrCPUUnsupported ErrorCode = 64
	ErrABIMismatch    ErrorCode = 65

	ErrPanic        ErrorCode = 96
	ErrCPPException ErrorCode = 97
	ErrInternal     ErrorCode = 127
)

type InternalFrame

type InternalFrame struct {
	Kind uint32
	// Flags carries the bool payload for ValueKindBool; unused for other kinds.
	Flags        uint32
	ChildCount   uint32
	Reserved     uint32
	KeyPtr       uintptr
	KeyLen       uintptr
	StringPtr    uintptr
	StringLen    uintptr
	Int64Value   int64
	Uint64Value  uint64
	Float64Value float64
}

type NativeAllocStats

type NativeAllocStats struct {
	Epoch              uint64
	LiveBytes          uint64
	TotalAllocBytes    uint64
	AllocCount         uint64
	FreeCount          uint64
	UntrackedFreeCount uint64
}

type ObjectIter

type ObjectIter struct {
	Doc      DocHandle
	State0   uint64
	State1   uint64
	Index    uint32
	Tag      uint16
	Reserved uint16
}

type ParserHandle

type ParserHandle uint64

type SymbolLookup

type SymbolLookup func(handle uintptr, name string) (uintptr, error)

type ValueKind

type ValueKind uint32
const (
	ValueKindInvalid ValueKind = 0
	ValueKindNull    ValueKind = 1
	ValueKindBool    ValueKind = 2
	ValueKindInt64   ValueKind = 3
	ValueKindUint64  ValueKind = 4
	ValueKindFloat64 ValueKind = 5
	ValueKindString  ValueKind = 6
	ValueKindArray   ValueKind = 7
	ValueKindObject  ValueKind = 8
	ValueKindBigInt  ValueKind = 9
)

type ValueView

type ValueView struct {
	Doc      DocHandle
	State0   uint64
	State1   uint64
	KindHint uint32
	Reserved uint32
}

Jump to

Keyboard shortcuts

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