strict

package
v0.0.0-rc6 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

strict: generic cast functions for conversion to strict types

This package contains generic cast functions enabling providers to convert the values obtained from source databases to the strictly-typed values expected in heterogenous transfers. The main purpose of these functions is to just call the cast, providing a single-line "interface" to do that in concrete providers' type switch statements.

The functions in this package are divided into two categories: Expected and Unexpected. They work the same way in regards to the type / value conversion. They differ in just one way. The Expected functions return errors different from the errors returned by the Unexpected functions when a cast error occurs. The difference depends on the type of the incoming value being casted.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expected

func Expected[ExpectedT any, ResultT any](value any, concreteCast func(any) (ResultT, error)) (any, error)

Expected is a pure wrapper over concrete cast.

func ExpectedSQL

func ExpectedSQL[ExpectedT any, ResultT any](value any, concreteCast func(any) (ResultT, error)) (any, error)

ExpectedSQL automatically extracts values from `database/sql/driver` Valuer.

func Unexpected

func Unexpected[ResultT any](value any, concreteCast func(any) (ResultT, error)) (any, error)

Unexpected is a pure wrapper over concrete cast.

func UnexpectedSQL

func UnexpectedSQL[ResultT any](value any, concreteCast func(any) (ResultT, error)) (any, error)

UnexpectedSQL automatically extracts values from `database/sql/driver` Valuer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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