references

package
v0.0.0-...-fe69749 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

package references defines a datastructures and encoding/decodeing methods for references and identifiers.

TODO: scan package `github.com/jxskiss/base62` for bugs/security issues.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidEventIdentifier = errors.New("invalid eventIdentifier")
)
View Source
var (
	ErrInvalidEventReference = errors.New("invalid eventReference")
)
View Source
var (
	ErrInvalidPersonReference = errors.New("invalid personReference")
)
View Source
var (
	ErrInvalidZoneIdentifier = errors.New("invalid zoneIdentifier")
)

Functions

This section is empty.

Types

type EventIdentifier

type EventIdentifier [eventIdentifierLength]byte

EventIdentifier is a 192-bit byte array that

func EventIdentifierFromBytes

func EventIdentifierFromBytes(eventIdentifierBytes []byte) (EventIdentifier, error)

EventIdentifierFromBytes returns a EventIdentifier from a byte slice. The byte slice must have a length of 24.

TODO: Add note that this is not the same as FromString(string(eventIdentifierBytes)).

func EventIdentifierFromString

func EventIdentifierFromString(eventIdentifierString string) (EventIdentifier, error)

EventIdentifierFromBytes returns a EventIdentifier based on the human-readable string representation of a EventIdentifier.

func NewEventIdentifier

func NewEventIdentifier() (EventIdentifier, error)

NewEventIdentifier creates a new EventIdentifier. It is near-impossible for two calls to New to result in the same EventIdentifier.

TODO: Add explanation about mathimatical imposibility.

TODO: Add guide on proper random source being a requirement (system ops).

func (EventIdentifier) Bytes

func (pr EventIdentifier) Bytes() []byte

Bytes returns a byteslice for the given EventIdentifier. The slice is guaranteed to have a length of 16.

func (*EventIdentifier) Scan

func (pr *EventIdentifier) Scan(value interface{}) error

Scan implements the Scanner interface.

func (EventIdentifier) String

func (pr EventIdentifier) String() string

String returns a human-friendly, url-friendly string representation of a EventIdentifier.

TODO: Add docs on the string representation.

func (EventIdentifier) Value

func (pr EventIdentifier) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type EventReference

type EventReference [eventReferenceLength]byte

EventReference is a 256-bit reference that links to a unique event within a network.

func EventReferenceFromBytes

func EventReferenceFromBytes(eventReferenceBytes []byte) (EventReference, error)

EventReferenceFromBytes returns an eventReference from a byte slice. The byte slice must have a length of 32.

TODO: Add note that this is not the same as FromString(string(eventReferenceBytes)).

func EventReferenceFromIdentifiers

func EventReferenceFromIdentifiers(zoneIdentifier ZoneIdentifier, eventIdentifier EventIdentifier) (EventReference, error)

EventReferenceFromIdentifiers returns an eventReference from a ZoneIdentifier and an EventIdentifier.

TODO: Add note that this is not the same as FromString(string(eventReferenceBytes)).

func EventReferenceFromString

func EventReferenceFromString(eventReferenceString string) (EventReference, error)

EventReferenceFromBytes returns an eventReference based on the human-readable string representation of an eventReference.

func NewEventReference

func NewEventReference() (EventReference, error)

NewEventReference creates a new EventReference. It is near-impossible for two calls to New to result in the same EventReference.

TODO: Add explanation about mathimatical imposibility.

TODO: Add guide on proper random source being a requirement (system ops).

func (EventReference) Bytes

func (er EventReference) Bytes() []byte

Bytes returns a byteslice for the given EventReference. The slice is guaranteed to have a length of 16.

func (*EventReference) Scan

func (er *EventReference) Scan(value interface{}) error

Scan implements the Scanner interface.

func (EventReference) String

func (er EventReference) String() string

String returns a human-friendly, url-friendly string representation of a EventReference.

TODO: Add docs on the string representation.

func (EventReference) Value

func (er EventReference) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type PersonReference

type PersonReference [personReferenceLength]byte

PersonReference is a 128-bit reference that links to a unique person in the desq system.

func NewPersonReference

func NewPersonReference() (PersonReference, error)

NewPersonReference creates a new PersonReference. It is near-impossible for two calls to New to result in the same PersonReference.

TODO: Add explanation about mathimatical imposibility.

TODO: Add guide on proper random source being a requirement (system ops).

func PersonReferenceFromBytes

func PersonReferenceFromBytes(personReferenceBytes []byte) (PersonReference, error)

PersonReferenceFromBytes returns a PersonReference from a byte slice. The byte slice must have a length of 16.

TODO: Add note that this is not the same as FromString(string(personReferenceBytes)).

func PersonReferenceFromString

func PersonReferenceFromString(personReferenceString string) (PersonReference, error)

PersonReferenceFromBytes returns a PersonReference based on the human-readable string representation of a PersonReference.

func (PersonReference) Bytes

func (pr PersonReference) Bytes() []byte

Bytes returns a byteslice for the given PersonReference. The slice is guaranteed to have a length of 16.

func (*PersonReference) Scan

func (pr *PersonReference) Scan(value interface{}) error

Scan implements the Scanner interface.

func (PersonReference) String

func (pr PersonReference) String() string

String returns a human-friendly, url-friendly string representation of a PersonReference.

TODO: Add docs on the string representation.

func (PersonReference) Value

func (pr PersonReference) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type PersonReferenceArray

type PersonReferenceArray []PersonReference

func (PersonReferenceArray) BytesArray

func (pra PersonReferenceArray) BytesArray() [][]byte

func (*PersonReferenceArray) Scan

func (pra *PersonReferenceArray) Scan(value interface{}) error

Scan implements the Scanner interface.

func (PersonReferenceArray) Value

func (pra PersonReferenceArray) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type ZoneIdentifier

type ZoneIdentifier [zoneIdentifierLength]byte

ZoneIdentifier is a 128-bit identifier that links to a unique zone in the desq system.

func NewZoneIdentifier

func NewZoneIdentifier() (ZoneIdentifier, error)

NewZoneIdentifier creates a new ZoneIdentifier. It is near-impossible for two calls to New to result in the same ZoneIdentifier.

TODO: Add explanation about mathimatical imposibility.

TODO: Add guide on proper random source being a requirement (system ops).

func ZoneIdentifierFromBytes

func ZoneIdentifierFromBytes(zoneIdentifierBytes []byte) (ZoneIdentifier, error)

ZoneIdentifierFromBytes returns a ZoneIdentifier from a byte slice. The byte slice must have a length of 8.

TODO: Add note that this is not the same as FromString(string(zoneIdentifierBytes)).

func ZoneIdentifierFromString

func ZoneIdentifierFromString(zoneIdentifierString string) (ZoneIdentifier, error)

ZoneIdentifierFromBytes returns a ZoneIdentifier based on the human-readable string representation of a ZoneIdentifier.

func (ZoneIdentifier) Bytes

func (pr ZoneIdentifier) Bytes() []byte

Bytes returns a byteslice for the given ZoneIdentifier. The slice is guaranteed to have a length of 16.

func (*ZoneIdentifier) Scan

func (pr *ZoneIdentifier) Scan(value interface{}) error

Scan implements the Scanner interface.

func (ZoneIdentifier) String

func (pr ZoneIdentifier) String() string

String returns a human-friendly, url-friendly string representation of a ZoneIdentifier.

TODO: Add docs on the string representation.

func (ZoneIdentifier) Value

func (pr ZoneIdentifier) Value() (driver.Value, error)

Value implements the driver Valuer interface.

Jump to

Keyboard shortcuts

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