tl

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 15 Imported by: 59

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSerializeBufferSize = 1024
View Source
var Logger = func(a ...any) {}
View Source
var MaxVectorAllocationBytes = 256 << 20

MaxVectorAllocationBytes limits memory allocated for vector slice storage. Set it to 0 or a negative value to disable the limit.

View Source
var MaxVectorElements = 1 << 20

MaxVectorElements limits vector element count accepted from untrusted TL input. Set it to 0 or a negative value to disable the limit.

Functions

func Append added in v1.18.0

func Append(dst []byte, v Serializable, boxed bool) ([]byte, error)

Append serializes v and appends the TL bytes to dst.

func AppendBytes added in v1.18.0

func AppendBytes(dst []byte, data []byte) ([]byte, error)

AppendBytes appends data as a TL bytes field.

func CRC added in v1.8.0

func CRC(schema string) uint32

func FromBytes added in v1.5.0

func FromBytes(data []byte) (loaded []byte, buffer []byte, err error)

func FromBytesNoCopy added in v1.18.0

func FromBytesNoCopy(data []byte) (loaded []byte, buffer []byte, err error)

FromBytesNoCopy reads TL bytes and returns a slice pointing into data. The caller must keep data immutable and alive while loaded is used.

func Hash added in v1.8.0

func Hash(key any) ([]byte, error)

func Parse added in v1.5.0

func Parse(v Serializable, data []byte, boxed bool) (_ []byte, err error)

func ParseNoCopy added in v1.18.0

func ParseNoCopy(v Serializable, data []byte, boxed bool) ([]byte, error)

ParseNoCopy parses TL data without copying byte payloads when possible. The caller must keep data immutable and alive while the parsed value is used.

func Register added in v1.5.0

func Register(typ any, tl string) uint32

func RegisterAllowedGroup added in v1.15.0

func RegisterAllowedGroup(name string, names ...string)

RegisterAllowedGroup - register an alias for a group of types to use in tl tags in [brackets] In case the name is already registered, types will be appended

func RegisterWithFabric added in v1.14.0

func RegisterWithFabric(typ any, tl string, fab func() reflect.Value) uint32

func RemapBufferAsSlice added in v1.11.0

func RemapBufferAsSlice(buf *bytes.Buffer, from int)

func RemapSliceAsTLBytes added in v1.18.0

func RemapSliceAsTLBytes(dst []byte, from int) []byte

func Serialize added in v1.5.0

func Serialize(v Serializable, boxed bool, bufOpt ...*bytes.Buffer) ([]byte, error)

func ToBytesToBuffer added in v1.11.0

func ToBytesToBuffer(buf *bytes.Buffer, data []byte) error

Types

type ParseableTL added in v1.11.0

type ParseableTL interface {
	Parse(data []byte) ([]byte, error)
}

type Raw added in v1.5.0

type Raw []byte

type Serializable added in v1.5.0

type Serializable interface{}

type SerializableTL added in v1.11.0

type SerializableTL interface {
	Serialize(buf *bytes.Buffer) error
}

type TL added in v1.5.0

type TL interface {
	ParseableTL
	SerializableTL
}

Jump to

Keyboard shortcuts

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