uuid
import "github.com/TheManticoreProject/Manticore/crypto/uuid"
Index
Constants
const (
UUID_VARIANT_RESERVED_NCS_BACKWARD_COMPATIBLE = 0x00
UUID_VARIANT_RESERVED_RFC_4122_NAMESPACE_DNS = 0x01
UUID_VARIANT_RESERVED_RFC_4122_NAMESPACE_URL = 0x02
UUID_VARIANT_RESERVED_RFC_4122_NAMESPACE_OID = 0x03
UUID_VARIANT_RESERVED_RFC_4122_NAMESPACE_X500 = 0x04
UUID_VARIANT_RESERVED_FUTURE_USE = 0x05
UUID_VARIANT_RESERVED_FOR_NCS_COMPATIBILITY = 0x06
UUID_VARIANT_RESERVED_FOR_FUTURE_USE = 0x07
)
type UUID
UUID represents a UUID structure
type UUID struct {
// Version is the version of the UUID
Version uint8
// Variant is the variant of the UUID
Variant uint8
// Data is the data of the UUID
Data [15]byte
}
func (*UUID) FromString
func (u *UUID) FromString(s string) error
FromString parses a UUID string in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and returns a UUID structure.
Parameters:
- s: A string representation of the UUID
Returns:
- An error if the string is not a valid UUID format
func (*UUID) Marshal
func (u *UUID) Marshal() ([]byte, error)
Marshal converts a UUID structure into 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 (*UUID) String
func (u *UUID) String() string
String returns a string representation of the UUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where x is a hexadecimal digit.
Returns:
- A string representation of the UUID
func (*UUID) Unmarshal
func (u *UUID) Unmarshal(marshalledData []byte) (int, error)
Unmarshal converts a 16-byte array into a UUID structure
Parameters:
- data: A byte slice containing the UUID’s 16 bytes
Returns:
- The number of bytes read
- An error if the UUID is invalid or the conversion fails
type UUIDInterface
UUIDInterface is an interface that defines the methods for a UUID
type UUIDInterface interface {
// Marshal converts a UUID structure into a 16-byte array
Marshal() ([]byte, error)
// Unmarshal converts a 16-byte array into a UUID structure
Unmarshal(data []byte) (int, error)
// FromString parses a UUID string in the format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
FromString(s string) error
// String returns the string representation of the UUID
String() string
}