uuidpb

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package uuidpb provides the "well-known" UUID type for representing 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 Map

type Map[V any] map[MapKey]V

Map is a map data structure that uses a UUID as its key.

func (Map[V]) Delete

func (m Map[V]) Delete(k *UUID)

Delete removes the value associated with k.

func (Map[V]) Get

func (m Map[V]) Get(k *UUID) V

Get returns the value associated with k, or the zero-value if k is not present in the map.

func (Map[V]) Has added in v0.10.2

func (m Map[V]) Has(k *UUID) bool

Has returns true if k is present in the map.

func (Map[V]) Set

func (m Map[V]) Set(k *UUID, v V)

Set associates v with k.

func (Map[V]) TryGet

func (m Map[V]) TryGet(k *UUID) (V, bool)

TryGet returns the value associated with k, or false if k is not present in the map.

type MapKey

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

MapKey is an opaque representation of a UUID that can be used as a map key.

func (MapKey) AsUUID

func (k MapKey) AsUUID() *UUID

AsUUID returns the UUID represented by the key.

func (MapKey) DapperString added in v0.10.1

func (k MapKey) DapperString() string

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

func (MapKey) Format added in v0.10.1

func (k MapKey) Format(f fmt.State, verb rune)

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

func (MapKey) String added in v0.10.1

func (k MapKey) String() string

String returns a string representation of the UUID.

type Set

type Set []*UUID

Set is an ordered set of UUIDs.

func (*Set) Add

func (s *Set) Add(id *UUID)

Add adds id to the set.

func (*Set) Delete

func (s *Set) Delete(id *UUID)

Delete removes id from the set.

func (Set) Has

func (s Set) Has(id *UUID) bool

Has returns true if id is in the set.

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 4122 UUID.

func FromByteArray

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

FromByteArray returns a UUID from a byte array.

func FromString

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

FromString returns a UUID from an RFC 4122 string

func Generate

func Generate() *UUID

Generate returns a new randonly generated UUID.

func (*UUID) AsBytes

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

AsBytes returns the UUID as a byte slice.

func (*UUID) AsMapKey

func (x *UUID) AsMapKey() MapKey

AsMapKey returns an opaque representation of the UUID that can be used as a map key.

func (*UUID) AsString

func (x *UUID) AsString() string

AsString returns the UUID as an RFC 4122 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.

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