gost

package module
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 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) IfErr added in v0.0.16

func (e *Error) IfErr(fn func(err *Error) *Error) *Error

func (*Error) IfNotErr added in v0.0.16

func (e *Error) IfNotErr(fn func() *Error) *Error

func (*Error) IntoStd added in v0.0.17

func (e *Error) IntoStd() error

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

func (*Error) WrapNotNilMsg added in v0.0.9

func (e *Error) WrapNotNilMsg(message string) *Error

func (*Error) WrapfNotNilMsg added in v0.0.10

func (e *Error) WrapfNotNilMsg(template string, args ...any) *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]) ErrorStd added in v0.0.18

func (r Result[V]) ErrorStd() 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]) UnwrapOr added in v0.0.7

func (r Result[V]) UnwrapOr(v V) V

func (Result[V]) UnwrapOrDefault

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

func (Result[V]) UnwrapOrElse

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

type ResultN added in v0.0.7

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

func ErrN added in v0.0.7

func ErrN(err *Error) ResultN

func (ResultN) Err added in v0.0.7

func (ResultN) Err(err *Error) ResultN

func (ResultN) ErrNew added in v0.0.7

func (ResultN) ErrNew(code, extCode int, msg string) ResultN

func (ResultN) ErrNewUnknown added in v0.0.7

func (ResultN) ErrNewUnknown(msg string) ResultN

func (ResultN) Error added in v0.0.7

func (r ResultN) Error() *Error

func (ResultN) ErrorStd added in v0.0.18

func (r ResultN) ErrorStd() error

func (ResultN) IsErr added in v0.0.7

func (r ResultN) IsErr() bool

func (ResultN) IsOk added in v0.0.7

func (r ResultN) IsOk() bool

func (ResultN) Ok added in v0.0.7

func (ResultN) Ok() ResultN

func (ResultN) Switch added in v0.0.7

func (r ResultN) Switch() switchOption

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]) SetWithLock added in v0.0.11

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

func (*RwLock[V]) WBorrow

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

func (*RwLock[V]) WRelease added in v0.0.8

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

func (*RwLock[V]) WReturn

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

func (*RwLock[V]) WTryBorrow

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

func (*RwLock[V]) WithLock added in v0.0.12

func (m *RwLock[V]) WithLock(fn func(v V) 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