basehash

package
v0.0.0-...-3b12f0d Latest Latest
Warning

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

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

Documentation

Overview

Package basehash provides basic types to implement hash identifiers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash128

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

Hash128 represents a uint128 using two uint64s.

hi represents the most significant 64 bits and lo represents the least significant 64 bits.

func New128

func New128(hi, lo uint64) Hash128

func New128FromBytes

func New128FromBytes(b []byte) (Hash128, error)

New128FromBytes returns a Hash128 given by the bytes in b.

func New128FromString

func New128FromString(s string) (Hash128, error)

New128FromString returns a Hash128 given by the characters in s.

func (Hash128) Base64

func (h Hash128) Base64() string

Base64 returns the base64 FileID representation for inclusion into JSON payloads.

func (Hash128) Bytes

func (h Hash128) Bytes() []byte

Bytes returns a byte slice representation of a Hash128.

func (Hash128) Compare

func (h Hash128) Compare(other Hash128) int

Compare returns an integer comparing two hashes lexicographically. The result will be 0 if h == other, -1 if h < other, and +1 if h > other.

func (Hash128) Equal

func (h Hash128) Equal(other Hash128) bool

func (Hash128) Format

func (h Hash128) Format(s fmt.State, ch rune)

Format implements fmt.Formatter.

It accepts the formats 'd' (decimal), 'v' (value), 'x' (lowercase hexadecimal), and 'X' (uppercase hexadecimal).

Also supported is a subset of the package fmt's format flags, including '#' for leading zero in hexadecimal.

For any unsupported format, the value will be serialized using the gob codec.

func (Hash128) Hi

func (h Hash128) Hi() uint64

Hi returns the high 64 bits

func (Hash128) IsZero

func (h Hash128) IsZero() bool

func (Hash128) Less

func (h Hash128) Less(other Hash128) bool

Less reports whether h is less than other.

The order defined here must be the same as the one used in "SELECT ... FOR UPDATE" queries, otherwise DB deadlocks may occur on concurrent updates, hence the casts to int64.

func (Hash128) Lo

func (h Hash128) Lo() uint64

Lo returns the low 64 bits

func (Hash128) MarshalJSON

func (h Hash128) MarshalJSON() ([]byte, error)

func (Hash128) MarshalText

func (h Hash128) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface, so we can marshal (from JSON) a map using a Hash128 as a key

func (Hash128) PutBytes16

func (h Hash128) PutBytes16(b *[16]byte)

PutBytes16 writes the 16 bytes into the provided array pointer.

func (Hash128) StringNoQuotes

func (h Hash128) StringNoQuotes() string

func (Hash128) ToUUIDString

func (h Hash128) ToUUIDString() string

func (*Hash128) UnmarshalJSON

func (h *Hash128) UnmarshalJSON(b []byte) error

func (*Hash128) UnmarshalText

func (h *Hash128) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface, so we can unmarshal (from JSON) a map using a Hash128 as a key

func (Hash128) Words

func (h Hash128) Words() (hi, lo uint64)

type Hash64

type Hash64 uint64

func (*Hash64) MarshalJSON

func (h *Hash64) MarshalJSON() ([]byte, error)

func (*Hash64) String

func (h *Hash64) String() string

func (*Hash64) UnmarshalJSON

func (h *Hash64) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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