Generated from Manticore v1.1.5 • 201 packages. View on pkg.go.dev

uuid_v6

import "github.com/TheManticoreProject/Manticore/crypto/uuid/uuid_v6"

Index

Constants

const (
    // UUIDv6Epoch is the epoch of the UUIDv6 timestamp
    // It is the number of 100-nanosecond intervals since October 15, 1582
    UUIDv6Epoch = uint64(122192928000000000)
)

type UUIDv6

UUIDv6 represents a UUID v6 structure (time-ordered variant of v1).

UUIDv6 reorders the v1 timestamp fields to improve lexicographic ordering while retaining the same 60-bit timestamp, clock sequence and node fields.

type UUIDv6 struct {
    uuid.UUID

    Time uint64

    ClockSeq uint16

    NodeID [6]byte
}

func (*UUIDv6) FromString

func (u *UUIDv6) FromString(uuidStr string) error

FromString parses a UUID string in the format “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx” and returns a UUIDv6 structure.

Parameters:

  • uuidStr: A string containing the UUID in the format “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”

Returns:

  • An error if the UUID is invalid or the conversion fails

func (*UUIDv6) GetClockSequence

func (u *UUIDv6) GetClockSequence() uint16

GetClockSequence returns the clock sequence of the UUIDv6 structure

Returns:

  • The clock sequence of the UUIDv6 structure

func (*UUIDv6) GetNodeID

func (u *UUIDv6) GetNodeID() []byte

GetNodeID returns the node ID of the UUIDv6 structure

Returns:

  • The node ID of the UUIDv6 structure

func (*UUIDv6) GetTime

func (u *UUIDv6) GetTime() time.Time

GetTime returns the time of the UUIDv6 structure

Returns:

  • The time of the UUIDv6 structure

func (*UUIDv6) Marshal

func (u *UUIDv6) Marshal() ([]byte, error)

Marshal converts the UUIDv6 structure to a 16-byte array

Returns:

  • A byte slice containing the UUID’s 16 bytes
  • An error if the UUID is invalid or the conversion fails

func (*UUIDv6) SetClockSequence

func (u *UUIDv6) SetClockSequence(clockSeq uint16)

SetClockSequence sets the clock sequence field of the UUIDv6 structure

Parameters:

  • clockSeq: The clock sequence to set

func (*UUIDv6) SetNodeID

func (u *UUIDv6) SetNodeID(nodeID []byte) error

SetNodeID sets the node ID field of the UUIDv6 structure

Parameters:

  • nodeID: A byte slice containing the node ID (6 bytes)

Returns:

  • An error if the node ID is invalid

func (*UUIDv6) SetTime

func (u *UUIDv6) SetTime(t time.Time)

SetTime sets the time field of the UUIDv6 structure

Parameters:

  • t: The time to set

func (*UUIDv6) String

func (u *UUIDv6) String() string

String returns the string representation of the UUIDv6 structure

Returns:

  • The string representation of the UUIDv6 structure

func (*UUIDv6) Unmarshal

func (u *UUIDv6) Unmarshal(marshalledData []byte) (int, error)

Unmarshal converts a 16-byte array into a UUIDv6 structure

Returns:

  • The number of bytes read
  • An error if the UUID is invalid or the conversion fails