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

uuid_v1

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

Index

Constants

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

type UUIDv1

UUIDv1 represents a UUID v1 structure

UUIDv1 is a structure that represents a UUID v1. It contains a UUID, a time, a clock sequence, and a node ID.

type UUIDv1 struct {
    uuid.UUID

    Time uint64

    ClockSeq uint16

    NodeID [6]byte
}

func (*UUIDv1) FromString

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

FromString parses a UUID string in the format “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx” and returns a UUIDv1 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 (*UUIDv1) GetClockSequence

func (u *UUIDv1) GetClockSequence() uint16

GetClockSequence returns the clock sequence of the UUIDv1 structure

Returns:

  • The clock sequence of the UUIDv1 structure

func (*UUIDv1) GetNodeID

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

GetNodeID returns the node ID of the UUIDv1 structure

Returns:

  • The node ID of the UUIDv1 structure

func (*UUIDv1) GetTime

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

GetTime returns the time of the UUIDv1 structure

Returns:

  • The time of the UUIDv1 structure

func (*UUIDv1) Marshal

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

Marshal converts the UUIDv1 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 (*UUIDv1) SetClockSequence

func (u *UUIDv1) SetClockSequence(clockSeq uint16)

SetClockSequence sets the clock sequence field of the UUIDv1 structure

Parameters:

  • clockSeq: The clock sequence to set

func (*UUIDv1) SetNodeID

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

SetNodeID sets the node ID field of the UUIDv1 structure

Parameters:

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

Returns:

  • An error if the node ID is invalid

func (*UUIDv1) SetTime

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

SetTime sets the time field of the UUIDv1 structure

Parameters:

  • t: The time to set

func (*UUIDv1) String

func (u *UUIDv1) String() string

String returns the string representation of the UUIDv1 structure

Returns:

  • The string representation of the UUIDv1 structure

func (*UUIDv1) Unmarshal

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

Unmarshal converts a 16-byte array into a UUIDv1 structure

Returns:

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