Documentation ¶
Index ¶
- Constants
- func Compare(a, b XAID) int
- func GenByType(typ uint16) func() XAID
- func SetSource(src EntropySourcer)
- type EntropySourcer
- type XAID
- func Batch(typ uint16, n int) []XAID
- func FromBytes(b []byte) (XAID, error)
- func FromBytesOrNil(b []byte) XAID
- func Make(t time.Time, typ uint16) (id XAID, err error)
- func Must(id XAID, err error) XAID
- func New() (id XAID, err error)
- func NewOrNil() (id XAID)
- func NewWithType(typ uint16) (id XAID, err error)
- func Parse(s string) (XAID, error)
- func ParseOrNil(s string) XAID
- func (i XAID) Append(b []byte) []byte
- func (i XAID) Bytes() []byte
- func (i XAID) Get() any
- func (i XAID) IsNil() bool
- func (i XAID) MarshalBinary() ([]byte, error)
- func (i XAID) MarshalGQL(w io.Writer)
- func (i XAID) MarshalJSON() ([]byte, error)
- func (i XAID) MarshalText() ([]byte, error)
- func (i *XAID) Scan(src any) error
- func (i *XAID) Set(s string) error
- func (i XAID) String() string
- func (i XAID) Time() time.Time
- func (i XAID) Timestamp() uint64
- func (i XAID) Type() uint16
- func (i *XAID) UnmarshalBinary(b []byte) error
- func (i *XAID) UnmarshalGQL(v any) error
- func (i *XAID) UnmarshalJSON(v []byte) error
- func (i *XAID) UnmarshalText(b []byte) error
- func (i XAID) Value() (driver.Value, error)
- type XAIDCreateInput
- type XAIDCreateResult
Constants ¶
const (
Length = stringEncodedLength
)
const (
SQLType = "CHAR"
)
Variables ¶
This section is empty.
Functions ¶
func SetSource ¶ added in v0.0.10
func SetSource(src EntropySourcer)
Sets the global source of random bytes for XAID generation. This should probably only be set once globally. While this is technically thread-safe as in it won't cause corruption, there's no guarantee on ordering.
Types ¶
type EntropySourcer ¶ added in v0.0.10
type XAID ¶
type XAID [byteLength]byte
XAIDs are 20 bytes:
00-07 byte: uint64 timestamp 08~11 byte: uint32 type 12-19 byte: random "payload"
func FromBytesOrNil ¶
Constructs a XAID from a 20-byte binary representation. Same behavior as FromBytes, but returns a Nil XAID on error.
func NewWithType ¶ added in v0.0.3
func ParseOrNil ¶
Parse decodes a string-encoded representation of a XAID object. Same behavior as Parse, but returns a Nil XAID on error.
func (XAID) Append ¶
Append appends the string representation of i to b, returning a slice to a potentially larger memory area.
func (XAID) Get ¶
Get satisfies the flag.Getter interface, making it possible to use XAIDs as part of of the command line options of a program.
func (XAID) MarshalBinary ¶
func (XAID) MarshalGQL ¶ added in v0.0.2
MarshalGQL implements the graphql.Marshaler interface
func (XAID) MarshalJSON ¶ added in v0.0.3
func (XAID) MarshalText ¶
func (*XAID) Scan ¶
Scan implements the sql.Scanner interface. It supports converting from string, []byte, or nil into a XAID value. Attempting to convert from another type will return an error.
func (*XAID) Set ¶
Set satisfies the flag.Value interface, making it possible to use XAIDs as part of of the command line options of a program.
func (XAID) Timestamp ¶
The timestamp portion of the ID as a bare integer which is uncorrected for XAID's special epoch.
func (*XAID) UnmarshalBinary ¶
func (*XAID) UnmarshalGQL ¶ added in v0.0.2
UnmarshalGQL implements the graphql.UnMarshaler interface
func (*XAID) UnmarshalJSON ¶ added in v0.0.3
func (*XAID) UnmarshalText ¶
type XAIDCreateInput ¶ added in v0.0.10
type XAIDCreateResult ¶ added in v0.0.10
func CreateTokenN ¶ added in v0.0.10
func CreateTokenN(input XAIDCreateInput) *XAIDCreateResult