unpack

package
v0.0.0-...-d93761d Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind[T any](thread *starlark.Thread, dst *T, unpacker UnpackerInto[T]) starlark.Unpacker

Types

type Canonicalizer

type Canonicalizer interface {
	Canonicalize(thread *starlark.Thread, v starlark.Value) (starlark.Value, error)
	GetConcatenationOperator() syntax.Token
}

type UnpackerInto

type UnpackerInto[T any] interface {
	Canonicalizer
	UnpackInto(thread *starlark.Thread, v starlark.Value, dst *T) error
}
var Any UnpackerInto[starlark.Value] = anyUnpackerInto{}
var ApparentLabel UnpackerInto[label.ApparentLabel] = apparentLabelUnpackerInto{}
var ApparentRepo UnpackerInto[label.ApparentRepo] = apparentRepoUnpackerInto{}
var Bool UnpackerInto[bool] = boolUnpackerInto{}
var Module UnpackerInto[label.Module] = moduleUnpackerInto{}
var ModuleVersion UnpackerInto[label.ModuleVersion] = moduleVersionUnpackerInto{}
var StarlarkIdentifier UnpackerInto[label.StarlarkIdentifier] = starlarkIdentifierUnpackerInto{}
var String UnpackerInto[string] = stringUnpackerInto{}
var TargetName UnpackerInto[label.TargetName] = targetNameUnpackerInto{}
var URL UnpackerInto[*url.URL] = urlUnpackerInto{}

func Canonicalize

func Canonicalize(base Canonicalizer) UnpackerInto[starlark.Value]

func Dict

func Dict[TKey comparable, TValue any](keyUnpacker UnpackerInto[TKey], valueUnpacker UnpackerInto[TValue]) UnpackerInto[map[TKey]TValue]

func IfNonEmptyString

func IfNonEmptyString[T any](base UnpackerInto[T]) UnpackerInto[T]

IfNonEmptyString is a decorator for UnpackerInto that only calls into the underlying unpacker if the value is a non-empty string. This can be of use if the default value of an argument is a string, and the empty string is used to denote that a value is unset.

func IfNotNone

func IfNotNone[T any](base UnpackerInto[T]) UnpackerInto[T]

IfNotNone is a decorator for UnpackerInto that only calls into the underlying unpacker if the value is not None. This can be of use if None is used to denote that a value is unset.

func Int

func Int[T constraints.Integer]() UnpackerInto[T]

func List

func List[T any](base UnpackerInto[T]) UnpackerInto[[]T]

func Or

func Or[T any](unpackers []UnpackerInto[T]) UnpackerInto[T]

func PathParser

func PathParser(pathFormat path.Format) UnpackerInto[path.Parser]

func Pointer

func Pointer[T any](base UnpackerInto[T]) UnpackerInto[*T]

func Singleton

func Singleton[T any](base UnpackerInto[T]) UnpackerInto[[]T]

func Stringer

func Stringer[T fmt.Stringer](base UnpackerInto[T]) UnpackerInto[string]

Stringer calls String() on the unpacked value and preserves that instead. This is useful if labels, URLs, etc. need to be captured in string form only.

func Type

func Type[T starlark.Value](name string) UnpackerInto[T]

Jump to

Keyboard shortcuts

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