gost

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 5 Imported by: 1

README

rusty

This is an attempt to bring some of the useful features of rust to the go language.

Documentation

Index

Constants

View Source
const (
	IsOk  switchOption = true
	IsErr switchOption = false
)

Variables

View Source
var (
	ErrMutexIsLocked = NewError(0, 0, "mutex is locked")
)

Functions

func CloneArray

func CloneArray[S ~[]E, E any](s S) S

func SafeDeref

func SafeDeref[T any](t *T) T

func WithContext

func WithContext(ctx context.Context, fn func() error, onStop ...func()) (err error)

func WithContextPool

func WithContextPool(ctx context.Context, fn func() error, pool chan struct{}, onStop ...func()) (err error)

Types

type Arc

type Arc[V *X, X any] struct {
	// contains filtered or unexported fields
}

func NewArc

func NewArc[V *X, X any](v V) Arc[V, X]

func (Arc[V, X]) Read

func (a Arc[V, X]) Read() X

func (Arc[V, X]) Ref

func (a Arc[V, X]) Ref() V

type Enum

type Enum[V any] Variant[V]

func (Enum[V]) Enum

func (e Enum[V]) Enum() V

func (Enum[V]) New

func (e Enum[V]) New(Value V) Enum[V]

type Error

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

func NewError

func NewError(baseCode int, extendedCode int, message string) *Error

func NewErrorUnknown added in v0.0.6

func NewErrorUnknown(message string) *Error

func (*Error) BaseCode

func (e *Error) BaseCode() int

func (*Error) Error

func (e *Error) Error() string

func (*Error) ExtendedCode

func (e *Error) ExtendedCode() int

func (Error) MarshalJSON

func (e Error) MarshalJSON() ([]byte, error)

func (*Error) Message

func (e *Error) Message() string

func (*Error) UnmarshalJSON

func (e *Error) UnmarshalJSON(data []byte) error

type Mutex

type Mutex[V any] struct {
	// contains filtered or unexported fields
}

func NewMutex

func NewMutex[V any](v V) Mutex[V]

func (*Mutex[V]) Borrow

func (m *Mutex[V]) Borrow() Arc[*V, V]

func (*Mutex[V]) BorrowMut

func (m *Mutex[V]) BorrowMut() *V

func (*Mutex[V]) Release

func (m *Mutex[V]) Release()

func (*Mutex[V]) Return

func (m *Mutex[V]) Return(v V)

func (*Mutex[V]) SetWithLock added in v0.0.4

func (m *Mutex[V]) SetWithLock(fn func(v V) V)

func (*Mutex[V]) TryBorrow

func (m *Mutex[V]) TryBorrow() Result[V]

func (*Mutex[V]) UpdateWithLock added in v0.0.4

func (m *Mutex[V]) UpdateWithLock(fn func(v *V))

type Nothing

type Nothing struct{}

type Option

type Option[V any] struct {
	// contains filtered or unexported fields
}

func None

func None[V any]() Option[V]

func Some

func Some[V any](value V) Option[V]

func (Option[V]) IsNone

func (o Option[V]) IsNone() bool

func (Option[V]) IsSome

func (o Option[V]) IsSome() bool

func (Option[V]) None

func (Option[V]) None() Option[V]

func (Option[V]) Some

func (Option[V]) Some(value V) Option[V]

func (Option[V]) Unwrap

func (o Option[V]) Unwrap() V

func (Option[V]) UnwrapOrDefault

func (o Option[V]) UnwrapOrDefault() V

func (Option[V]) UnwrapOrElse

func (o Option[V]) UnwrapOrElse(fn func() V) V

type Pair

type Pair[L any, R any] struct {
	Left  L
	Right R
}

type Result

type Result[V any] struct {
	// contains filtered or unexported fields
}

func Err

func Err[V any](err *Error) Result[V]

func Ok

func Ok[V any](value V) Result[V]

func (Result[V]) Err

func (Result[V]) Err(err *Error) Result[V]

func (Result[V]) ErrNew added in v0.0.6

func (Result[V]) ErrNew(code, extCode int, msg string) Result[V]

func (Result[V]) ErrNewUnknown added in v0.0.6

func (Result[V]) ErrNewUnknown(msg string) Result[V]

func (Result[V]) Error

func (r Result[V]) Error() *Error

func (*Result[V]) Expect

func (r *Result[V]) Expect(msg string) V

func (Result[V]) IsErr

func (r Result[V]) IsErr() bool

func (Result[V]) IsOk

func (r Result[V]) IsOk() bool

func (Result[V]) Ok

func (Result[V]) Ok(value V) Result[V]

func (Result[V]) Switch added in v0.0.3

func (r Result[V]) Switch() switchOption

func (Result[V]) Unwrap

func (r Result[V]) Unwrap() V

func (Result[V]) UnwrapOrDefault

func (r Result[V]) UnwrapOrDefault() V

func (Result[V]) UnwrapOrElse

func (r Result[V]) UnwrapOrElse(fn func(err Error) V) V

type RwLock

type RwLock[V any] struct {
	// contains filtered or unexported fields
}

func NewRwLock

func NewRwLock[V any](v V) RwLock[V]

func (*RwLock[V]) RBorrow

func (m *RwLock[V]) RBorrow() Arc[*V, V]

func (*RwLock[V]) RTryBorrow

func (m *RwLock[V]) RTryBorrow() Result[V]

func (*RwLock[V]) Release

func (m *RwLock[V]) Release()

func (*RwLock[V]) WBorrow

func (m *RwLock[V]) WBorrow() Arc[*V, V]

func (*RwLock[V]) WReturn

func (m *RwLock[V]) WReturn(v V)

func (*RwLock[V]) WTryBorrow

func (m *RwLock[V]) WTryBorrow() Result[V]

type Scoped

type Scoped interface {
	Lock() func()
}

func NewDebugScopedLock

func NewDebugScopedLock(log ...func()) Scoped

func NewScopedLock

func NewScopedLock() Scoped

type SecureMutexLocked added in v0.0.3

type SecureMutexLocked[V any] struct {
	// contains filtered or unexported fields
}

func (SecureMutexLocked[V]) Unlock added in v0.0.3

func (m SecureMutexLocked[V]) Unlock() SecureMutexUnlocked[V]

type SecureMutexUnlocked added in v0.0.3

type SecureMutexUnlocked[V any] struct {
	// contains filtered or unexported fields
}

func NewSecureMutex added in v0.0.3

func NewSecureMutex[V any](v V) SecureMutexUnlocked[V]

func (SecureMutexUnlocked[V]) Lock added in v0.0.3

func (m SecureMutexUnlocked[V]) Lock() SecureMutexLocked[V]

type Tuple

type Tuple[V any] []V

type Variant

type Variant[V any] struct {
	Value V
}

func NewVariant

func NewVariant[V any](Value V) Variant[V]

func (Variant[V]) Enum

func (v Variant[V]) Enum() V

func (Variant[V]) New

func (v Variant[V]) New(Value V) Enum[V]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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