uuidpb

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Package uuidpb provides the "well-known" UUID type for representing RFC 9562 (and formerly RFC 4122) UUIDs as Protocol Buffers messages.

Index

Constants

This section is empty.

Variables

View Source
var File_github_com_dogmatiq_enginekit_protobuf_uuidpb_uuid_proto protoreflect.FileDescriptor

Functions

func AsByteArray

func AsByteArray[T ~[16]B, B ~byte](x *UUID) T

AsByteArray returns the UUID as a byte array.

Types

type UUID

type UUID struct {
	Upper uint64 `protobuf:"varint,1,opt,name=upper,proto3" json:"upper,omitempty"`
	Lower uint64 `protobuf:"varint,2,opt,name=lower,proto3" json:"lower,omitempty"`
	// contains filtered or unexported fields
}

UUID is a size-optimized representation of an RFC 9562 UUID.

func FromByteArray

func FromByteArray[T ~[16]B, B byte](data T) *UUID

FromByteArray returns a UUID from a byte array.

func Generate

func Generate() *UUID

Generate returns a new randonly generated UUID.

func MustParse added in v0.12.0

func MustParse(str string) *UUID

MustParse parses an RFC 9562 "hex-and-dash" UUID string, or panics if unable to do so.

func Parse added in v0.12.0

func Parse(str string) (*UUID, error)

Parse parses an RFC 9562 "hex-and-dash" UUID string.

func (*UUID) AsBytes

func (x *UUID) AsBytes() []byte

AsBytes returns the UUID as a byte slice.

func (*UUID) AsString

func (x *UUID) AsString() string

AsString returns the UUID as an RFC 9562 string.

func (*UUID) Compare

func (x *UUID) Compare(id *UUID) int

Compare performs a three-way comparison between x and id.

func (*UUID) DapperString

func (x *UUID) DapperString() string

DapperString implements github.com/dogmatiq/dapper.Stringer.

func (*UUID) Descriptor deprecated

func (*UUID) Descriptor() ([]byte, []int)

Deprecated: Use UUID.ProtoReflect.Descriptor instead.

func (*UUID) Equal

func (x *UUID) Equal(id *UUID) bool

Equal returns true if x and id are equal.

func (*UUID) Format

func (x *UUID) Format(f fmt.State, verb rune)

Format implements the fmt.Formatter interface, allowing UUIDs to be formatted with functions from the fmt package.

This method takes precedence over the UUID.String method, which is generated by the Protocol Buffers compiler.

func (*UUID) GetLower

func (x *UUID) GetLower() uint64

func (*UUID) GetUpper

func (x *UUID) GetUpper() uint64

func (*UUID) Less

func (x *UUID) Less(id *UUID) bool

Less returns true if x is less than id.

func (*UUID) ProtoMessage

func (*UUID) ProtoMessage()

func (*UUID) ProtoReflect

func (x *UUID) ProtoReflect() protoreflect.Message

func (*UUID) Reset

func (x *UUID) Reset()

func (*UUID) SetLower

func (x *UUID) SetLower(v uint64)

SetLower sets the x.Lower field to v, then returns x.

func (*UUID) SetUpper

func (x *UUID) SetUpper(v uint64)

SetUpper sets the x.Upper field to v, then returns x.

func (*UUID) String

func (x *UUID) String() string

func (*UUID) Validate

func (x *UUID) Validate() error

Validate returns an error if x is not a valid Version 4 (random) UUID.

type UUIDBuilder

type UUIDBuilder struct {
	// contains filtered or unexported fields
}

func NewUUIDBuilder

func NewUUIDBuilder() *UUIDBuilder

NewUUIDBuilder returns a builder that constructs UUID messages.

func (*UUIDBuilder) Build

func (b *UUIDBuilder) Build() *UUID

Build returns a new UUID containing the values configured via the builder.

Each call returns a new message, such that future changes to the builder do not modify previously constructed messages.

func (*UUIDBuilder) From

func (b *UUIDBuilder) From(x *UUID) *UUIDBuilder

From configures the builder to use x as the prototype for new messages, then returns b.

It performs a shallow copy of x, such that any changes made via the builder do not modify x. It does not make a copy of the field values themselves.

func (*UUIDBuilder) WithLower

func (b *UUIDBuilder) WithLower(v uint64) *UUIDBuilder

WithLower configures the builder to set the Lower field to v, then returns b.

func (*UUIDBuilder) WithUpper

func (b *UUIDBuilder) WithUpper(v uint64) *UUIDBuilder

WithUpper configures the builder to set the Upper field to v, then returns b.

Jump to

Keyboard shortcuts

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