types

package
v0.0.0-...-bdd61b6 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package types implements encoding/decoding interfaces for generic, asn1 compatible types.

Index

Constants

View Source
const Version = int32(1000000001)

Version is this library's version.

Variables

View Source
var (
	ErrEncoding      = errors.New("types: Encoding error")
	ErrTypeUnknown   = errors.New("types: Unknown type")
	ErrTypeIDInvalid = errors.New("types: TypeID invalid")
	ErrExtraBytes    = errors.New("types: Extra bytes")
)

Functions

func FactorType

func FactorType(typeID int32) (interface{}, error)

FactorType returns a variable of type typeID.

func MakeByteSlice

func MakeByteSlice(size int, capacity ...int) []byte

func Marshal

func Marshal(i Factory) ([]byte, error)

Marshal a compatible type that implements the Factory interface.

func RegisterType

func RegisterType(f Factory)

RegisterType registers a type with this library. It must be called during the type's module init function.

func Unmarshal

func Unmarshal(d []byte) (interface{}, error)

Unmarshal a compatible type that is registered with this library.

Types

type ByteSliceMaker

type ByteSliceMaker func(size int, capacity ...int) []byte

type Factory

type Factory interface {
	TypeID() int32    // TypeID returns the _unique_ TypeID of this type. Must return a value greater than 0.
	New() interface{} // New returns a new instance of the type, as a pointer value.
}

Factory is the interface that needs to be implemented by each type handled by this library.

type RatchetPublicKey

type RatchetPublicKey struct {
	StartTime, RatchetTime int64
	Key                    [][32]byte
}

RatchetPublicKey is a public key (list) of a ratchet key.

func (*RatchetPublicKey) SelectKey

func (self *RatchetPublicKey) SelectKey(time int64) *TimeKey

func (*RatchetPublicKey) SelectKeyRange

func (self *RatchetPublicKey) SelectKeyRange(begin, end int64) []TimeKey

type TimeKey

type TimeKey struct {
	ValidFrom, ValidTo int64
	PublicKey          [32]byte
}

Jump to

Keyboard shortcuts

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