utils

package
v0.0.0-...-d49a382 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Millis2Seconds = 1_000
	Millis2Nano    = 1_000_000
)

Variables

View Source
var (
	ErrTooShort = errors.New("value is too short to be a valid JSON string")
	ErrBadFmt   = errors.New("badly formatted JSON string")
)

Functions

func BoolSize

func BoolSize(b bool) uint32

func GCD_U16

func GCD_U16(a, b uint16) uint16

func MarshalBool

func MarshalBool(v bool) (buf []byte)

func MarshalString

func MarshalString(str string) (buf []byte)

func MillisToUTCTime

func MillisToUTCTime(millis uint64) time.Time

func NullableSize

func NullableSize(o dmeta.Field) uint32

func OptionalBoolSize

func OptionalBoolSize(b *bool) uint32

func OptionalSize

func OptionalSize(o dmeta.Field) uint32

func OptionalStringSize

func OptionalStringSize(s *string) uint32

OptionalStringSize returns either 0 if the given value is nil, or len(*value) + 2 (for quotes).

func OptionalTimeSize

func OptionalTimeSize(t *time.Time) uint32

func StringSize

func StringSize(s string) uint32

StringSize returns len(string) + 2.

func TriStateStringSize

func TriStateStringSize(s *string, null bool) uint32

TriStateStringSize returns the size in bytes of the given value for the three possible states: absent, null, populated.

If the given value is nil and null is false, returns 0 (absent).

If the given value is nil and null is true, returns 4 (len("null")).

If the given value is non-nil, len(*value) + 2 (for quotes) is returned.

func UTCTimeToMillis

func UTCTimeToMillis(t *time.Time) *uint64

func UnmarshalString

func UnmarshalString(val []byte) (string, error)

deprecated

func UnmarshalStringInto

func UnmarshalStringInto(val []byte, to *string) error

Types

type OutBuilder

type OutBuilder map[serial.Key]interface{}

func (OutBuilder) NullSlice

func (o OutBuilder) NullSlice(k serial.Key, null bool, v interface{}) OutBuilder

func (OutBuilder) Nullable

func (o OutBuilder) Nullable(k serial.Key, v interface{}) OutBuilder

func (OutBuilder) OptSlice

func (o OutBuilder) OptSlice(k serial.Key, empty bool, v interface{}) OutBuilder

func (OutBuilder) Optional

func (o OutBuilder) Optional(k serial.Key, v interface{}) OutBuilder

func (OutBuilder) RawValue

func (o OutBuilder) RawValue(k serial.Key, v interface{}) OutBuilder

func (OutBuilder) TriState

func (o OutBuilder) TriState(k serial.Key, null bool, v interface{}) OutBuilder

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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