util

package
v0.0.0-...-db4fafb Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 17 Imported by: 16

Documentation

Index

Constants

View Source
const MAX_FILE_SIZE = 1 << 30

Variables

This section is empty.

Functions

func ParseActionsArray

func ParseActionsArray(data []byte, position int) ([][]byte, int)

func ParseBool

func ParseBool(data []byte, position int) (bool, int)

func ParseByte

func ParseByte(data []byte, position int) (byte, int)

func ParseByteArray

func ParseByteArray(data []byte, position int) ([]byte, int)

func ParseByteArrayArray

func ParseByteArrayArray(data []byte, position int) ([][]byte, int)

func ParseHash

func ParseHash(data []byte, position int) (crypto.Hash, int)

func ParseHashArray

func ParseHashArray(data []byte, position int) ([]crypto.Hash, int)

func ParseLargeByteArray

func ParseLargeByteArray(data []byte, position int) ([]byte, int)

func ParseLongByteArray

func ParseLongByteArray(data []byte, position int) ([]byte, int)

func ParseSecret

func ParseSecret(data []byte, position int) (crypto.PrivateKey, int)

func ParseSignature

func ParseSignature(data []byte, position int) (crypto.Signature, int)

func ParseString

func ParseString(data []byte, position int) (string, int)

func ParseTime

func ParseTime(data []byte, position int) (time.Time, int)

func ParseToken

func ParseToken(data []byte, position int) (crypto.Token, int)

func ParseTokenArray

func ParseTokenArray(data []byte, position int) ([]crypto.Token, int)

func ParseTokenCipher

func ParseTokenCipher(data []byte, position int) (crypto.TokenCipher, int)

func ParseTokenCiphers

func ParseTokenCiphers(data []byte, position int) (crypto.TokenCiphers, int)

func ParseUint16

func ParseUint16(data []byte, position int) (uint16, int)

func ParseUint32

func ParseUint32(data []byte, position int) (uint32, int)

func ParseUint64

func ParseUint64(data []byte, position int) (uint64, int)

func PrintJson

func PrintJson(v any)

func PutActionsArray

func PutActionsArray(b [][]byte, data *[]byte)

func PutBool

func PutBool(b bool, data *[]byte)

func PutByte

func PutByte(b byte, data *[]byte)

func PutByteArray

func PutByteArray(b []byte, data *[]byte)

PutByteArray puts a byte array up to 2^16 bytes into a byte array

func PutHash

func PutHash(hash crypto.Hash, data *[]byte)

func PutHashArray

func PutHashArray(b []crypto.Hash, data *[]byte)

func PutLargeByteArray

func PutLargeByteArray(b []byte, data *[]byte)

func PutLongByteArray

func PutLongByteArray(b []byte, data *[]byte)

PutByteArray puts a byte array up to 2^32 bytes into a byte array

func PutSecret

func PutSecret(secret crypto.PrivateKey, data *[]byte)

func PutSignature

func PutSignature(sign crypto.Signature, data *[]byte)

func PutString

func PutString(value string, data *[]byte)

func PutTime

func PutTime(value time.Time, data *[]byte)

func PutToken

func PutToken(token crypto.Token, data *[]byte)

func PutTokenArray

func PutTokenArray(b []crypto.Token, data *[]byte)

func PutTokenCipher

func PutTokenCipher(tc crypto.TokenCipher, data *[]byte)

func PutTokenCiphers

func PutTokenCiphers(tcs crypto.TokenCiphers, data *[]byte)

func PutUint16

func PutUint16(v uint16, data *[]byte)

func PutUint32

func PutUint32(v uint32, data *[]byte)

func PutUint64

func PutUint64(v uint64, data *[]byte)

func SetFromSlice

func SetFromSlice[T comparable](slice []T) map[T]struct{}

func Uint64ToBytes

func Uint64ToBytes(v uint64) []byte

Types

type Await

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

func NewAwait

func NewAwait(ctx context.Context) *Await

func (*Await) Call

func (b *Await) Call() bool

func (*Await) Close

func (b *Await) Close()

func (*Await) Wait

func (b *Await) Wait() bool

type Chain

type Chain[T any] struct {
	Epoch uint64
	// contains filtered or unexported fields
}

Chain provides a data structure that allows order data to be pushed possibly out of order and popped ordered.

func NewChain

func NewChain[T any](ctx context.Context, start uint64) *Chain[T]

func (*Chain[T]) Close

func (b *Chain[T]) Close()

func (*Chain[T]) Pop

func (b *Chain[T]) Pop() T

func (*Chain[T]) Push

func (b *Chain[T]) Push(data T, epoch uint64)

type CookieStore

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

func OpenCokieStore

func OpenCokieStore(path string, epoch uint64) *CookieStore

func (*CookieStore) Clean

func (c *CookieStore) Clean(epoch uint64)

func (*CookieStore) Close

func (c *CookieStore) Close()

func (*CookieStore) Get

func (c *CookieStore) Get(cookie string) (crypto.Token, bool)

func (*CookieStore) Set

func (c *CookieStore) Set(token crypto.Token, cookie string, epoch uint64) bool

func (*CookieStore) Unset

func (c *CookieStore) Unset(token crypto.Token, cookie string)

type DataQueue

type DataQueue[T any] struct {
	// contains filtered or unexported fields
}

func NewDataQueueWithHashFunc

func NewDataQueueWithHashFunc[T any](ctx context.Context, hash func(T) crypto.Hash) *DataQueue[T]

func NewSimpleDataQueue

func NewSimpleDataQueue[T any](ctx context.Context) *DataQueue[T]

func (*DataQueue[T]) Close

func (b *DataQueue[T]) Close()

func (*DataQueue[T]) Pop

func (b *DataQueue[T]) Pop() T

func (*DataQueue[T]) Push

func (b *DataQueue[T]) Push(data T)

type JSONBuilder

type JSONBuilder struct {
	Encode strings.Builder
}

func (*JSONBuilder) PutBase64

func (j *JSONBuilder) PutBase64(fieldName string, value []byte)

func (*JSONBuilder) PutHex

func (j *JSONBuilder) PutHex(fieldName string, value []byte)

func (*JSONBuilder) PutJSON

func (j *JSONBuilder) PutJSON(fieldName, value string)

func (*JSONBuilder) PutString

func (j *JSONBuilder) PutString(fieldName, value string)

func (*JSONBuilder) PutTime

func (j *JSONBuilder) PutTime(fieldName string, t time.Time)

func (*JSONBuilder) PutTokenCiphers

func (j *JSONBuilder) PutTokenCiphers(fieldName string, tc crypto.TokenCiphers)

func (*JSONBuilder) PutTokenValueArray

func (j *JSONBuilder) PutTokenValueArray(fieldName string, tokens []crypto.TokenValue)

func (*JSONBuilder) PutUint64

func (j *JSONBuilder) PutUint64(fieldName string, value uint64)

func (*JSONBuilder) ToString

func (j *JSONBuilder) ToString() string

type ReadAppendMutiFileStore

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

func OpenMultiFileStore

func OpenMultiFileStore(dbpath, name string) (*ReadAppendMutiFileStore, error)

func (*ReadAppendMutiFileStore) Close

func (r *ReadAppendMutiFileStore) Close() error

func (*ReadAppendMutiFileStore) Read

func (r *ReadAppendMutiFileStore) Read(p []byte) (int, error)

func (*ReadAppendMutiFileStore) Write

func (r *ReadAppendMutiFileStore) Write(p []byte) (int, error)

type SecureVault

type SecureVault struct {
	SecretKey crypto.PrivateKey
	Entries   [][]byte
	// contains filtered or unexported fields
}

SecureVault is a file that can persists data in an encrypted format protected by a pass phrase.

func NewSecureVault

func NewSecureVault(password []byte, fileName string) (*SecureVault, error)

func OpenOrCreateVaultFromPassword

func OpenOrCreateVaultFromPassword(password []byte, fileName string) (*SecureVault, error)

func OpenVaultFromPassword

func OpenVaultFromPassword(password []byte, fileName string) (*SecureVault, error)

func (*SecureVault) Close

func (s *SecureVault) Close()

func (*SecureVault) NewEntry

func (s *SecureVault) NewEntry(data []byte) error

type Set

type Set[T comparable] map[T]struct{}

Jump to

Keyboard shortcuts

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