Documentation
¶
Overview ¶
Package dynamic contains the implementation of hyperpb's dynamic message types.
Index ¶
- func GetField[T any](m *Message, offset tdp.Offset) *T
- func LoadField[T any](m *Message, offset tdp.Offset) T
- type Cold
- type Message
- func (m *Message) Cold() *Cold
- func (m *Message) Dump() string
- func (m *Message) Get(fd protoreflect.FieldDescriptor) protoreflect.Value
- func (m *Message) GetBit(n uint32) bool
- func (m *Message) GetByIndexUnchecked(n int) protoreflect.Value
- func (m *Message) Has(fd protoreflect.FieldDescriptor) bool
- func (m *Message) MutableCold() *Cold
- func (m *Message) ProtoReflect() protoreflect.Message
- func (m *Message) Range(yield func(protoreflect.FieldDescriptor, protoreflect.Value) bool)
- func (m *Message) SetBit(n uint32, flag bool)
- func (m *Message) Type() *tdp.Type
- type Shared
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Message ¶
type Message struct { TypeOffset uint32 // Index into context.cold; negative means no cold pointer. // Exported for open-coding in the parser. ColdIndex int32 // contains filtered or unexported fields }
Message is a dynamic message value.
A *Message lives on some arena, and all of its submessages do too. Because arenas are designed such that if a pointer to any of its allocated data is reachable, the whole arena is reachable, simply holding a *Message into the arena will keep everything else alive.
This means that *Message values not being directly operated on by the application do not need to be marked by the GC, because their memory already gets marked whenever the GC sweeps a *root. As such, all of the fields of a Message are laid out in memory that follows it.
func (*Message) Cold ¶
cold returns a pointer to the cold region, or nil if it hasn't been allocated.
func (*Message) Get ¶
func (m *Message) Get(fd protoreflect.FieldDescriptor) protoreflect.Value
Get retrieves the value for a field.
func (*Message) GetByIndexUnchecked ¶
func (m *Message) GetByIndexUnchecked(n int) protoreflect.Value
GetByIndex is like Message.Get, but it takes a raw field index, performing no bounds checks.
func (*Message) Has ¶
func (m *Message) Has(fd protoreflect.FieldDescriptor) bool
Has reports whether a field is populated.
func (*Message) MutableCold ¶
MutableCold returns a pointer to the cold region, allocating one if needed.
func (*Message) ProtoReflect ¶
func (m *Message) ProtoReflect() protoreflect.Message
ProtoReflect is a callback to construct the root package's message type.
It is connected to the root package via linkname.
func (*Message) Range ¶
func (m *Message) Range(yield func(protoreflect.FieldDescriptor, protoreflect.Value) bool)
Range iterates over every populated field.
type Shared ¶
Shared is state that is shared by all messages in a particular tree of messages.
A zero Shared is ready to use.
func (*Shared) Free ¶
func (s *Shared) Free()
Free releases any resources held by this context, allowing them to be re-used.
Any messages previously parsed using this context must not be reused.