Documentation
¶
Overview ¶
Package uuidpb provides the "well-known" UUID type for representing RFC 9562 (and formerly RFC 4122) UUIDs as Protocol Buffers messages.
Index ¶
- Variables
- func AsByteArray[T ~[16]B, B ~byte](x *UUID) T
- func CopyBytes[T ~[]B, B byte](x *UUID, dst T) int
- func MustParseAsByteArray(str string) [16]byte
- func MustParseAsBytes(str string) []byte
- func MustParseIntoBytes(str string, dst []byte)
- func ParseAsByteArray(str string) ([16]byte, error)
- func ParseAsBytes(str string) ([]byte, error)
- func ParseIntoBytes(str string, dst []byte) error
- type Map
- func (m *Map[T]) All() iter.Seq2[*UUID, T]
- func (m *Map[T]) Clear()
- func (m *Map[T]) Clone() *Map[T]
- func (m *Map[T]) Delete(k *UUID)
- func (m *Map[T]) Get(k *UUID) (T, bool)
- func (m *Map[T]) Has(k *UUID) bool
- func (m *Map[T]) Keys() iter.Seq[*UUID]
- func (m *Map[T]) Len() int
- func (m *Map[T]) Set(k *UUID, v T)
- func (m *Map[T]) Values() iter.Seq[T]
- type Set
- type UUID
- func (x *UUID) AsByteArray() [16]byte
- func (x *UUID) AsBytes() []byte
- func (x *UUID) AsString() string
- func (x *UUID) Compare(id *UUID) int
- func (x *UUID) DapperString() string
- func (*UUID) Descriptor() ([]byte, []int)deprecated
- func (x *UUID) Equal(id *UUID) bool
- func (x *UUID) Format(f fmt.State, verb rune)
- func (x *UUID) GetLower() uint64
- func (x *UUID) GetUpper() uint64
- func (x *UUID) Less(id *UUID) bool
- func (x *UUID) MarshalBinary() ([]byte, error)
- func (*UUID) ProtoMessage()
- func (x *UUID) ProtoReflect() protoreflect.Message
- func (x *UUID) Reset()
- func (x *UUID) SetLower(v uint64)
- func (x *UUID) SetUpper(v uint64)
- func (x *UUID) String() string
- func (x *UUID) UnmarshalBinary(data []byte) error
- func (x *UUID) Validate() error
- type UUIDBuilder
Constants ¶
This section is empty.
Variables ¶
var File_github_com_dogmatiq_enginekit_protobuf_uuidpb_uuid_proto protoreflect.FileDescriptor
Functions ¶
func AsByteArray ¶
AsByteArray returns the UUID as a byte array.
func CopyBytes ¶ added in v0.17.0
CopyBytes copies the binary representation of x into dst.
It returns the number of elements copied, which will be the minimum of 16 and len(dst).
func MustParseAsByteArray ¶ added in v0.19.7
MustParseAsByteArray parses an RFC 9562 "hex-and-dash" UUID string directly to its byte array representation, or panics if unable to do so.
This is equivalent to calling MustParse(str).AsByteArray(), but avoids all allocations.
func MustParseAsBytes ¶ added in v0.19.7
MustParseAsBytes parses an RFC 9562 "hex-and-dash" UUID string directly to its byte slice representation, or panics if unable to do so.
This is equivalent to calling MustParse(str).AsBytes(), but avoids allocation of the intermediate UUID struct.
func MustParseIntoBytes ¶ added in v0.19.7
MustParseIntoBytes parses an RFC 9562 "hex-and-dash" UUID string into the given byte slice, or panics if unable to do so.
This is equivalent to calling CopyBytes on the result of MustParse, but avoids all allocations.
func ParseAsByteArray ¶ added in v0.19.7
ParseAsByteArray parses an RFC 9562 "hex-and-dash" UUID string directly to its byte array representation.
This is equivalent to calling AsByteArray() on the result of Parse(str), but avoids all allocations.
func ParseAsBytes ¶ added in v0.19.7
ParseAsBytes parses an RFC 9562 "hex-and-dash" UUID string directly to its byte slice representation.
This is equivalent to calling AsBytes() on the result of Parse(str), but avoids allocation of the intermediate UUID struct.
Types ¶
type Map ¶
type Map[T any] struct { // contains filtered or unexported fields }
Map is a map from UUID to values of type T.
func (*Map[T]) Clear ¶ added in v0.19.18
func (m *Map[T]) Clear()
Clear removes all elements from the map.
func (*Map[T]) Has ¶ added in v0.10.2
Has reports whether the map contains a value for the given key.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a collection of UUID values.
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 Derive ¶ added in v0.17.0
Derive returns a new SHA-1 derived (v5) UUID from the given namespace and names.
func FromByteArray ¶
FromByteArray returns a UUID from a byte array.
func FromBytes ¶ added in v0.19.12
FromBytes returns a UUID from a byte slice.
It returns an error if the length of the slice is not exactly 16 bytes.
func MustParse ¶ added in v0.12.0
MustParse parses an RFC 9562 "hex-and-dash" UUID string, or panics if unable to do so.
func (*UUID) AsByteArray ¶ added in v0.19.12
AsByteArray returns the UUID as a byte array.
func (*UUID) DapperString ¶
DapperString implements github.com/dogmatiq/dapper.Stringer.
func (*UUID) Descriptor
deprecated
func (*UUID) Format ¶
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) MarshalBinary ¶ added in v0.18.0
MarshalBinary returns the binary representation of the message, equivalent to calling proto.Marshal(x).
It allows *UUID to implement encoding.BinaryMarshaler.
func (*UUID) ProtoMessage ¶
func (*UUID) ProtoMessage()
func (*UUID) ProtoReflect ¶
func (x *UUID) ProtoReflect() protoreflect.Message
func (*UUID) UnmarshalBinary ¶ added in v0.18.0
UnmarshalBinary populates x from its binary representation, equivalent to calling proto.Unmarshal(data, x).
It allows *UUID to implement encoding.BinaryUnmarshaler.
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.