repeated

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package repeated contains shared layouts for repeated field implementations, for sharing between the tdp packages and the gencode packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bools

type Bools struct {
	Raw slice.Untyped
	// contains filtered or unexported fields
}

Bools is a repeated field containing bools.

func (Bools) All

func (b Bools) All() iter.Seq2[int, bool]

All returns an iterator over the indices and elements of s.

func (Bools) Copy

func (b Bools) Copy(out []bool) []bool

Copy copies these bools to a slice, appending to out.

To get a fresh slice, pass nil to this function.

func (Bools) Get

func (b Bools) Get(n int) bool

Get extracts a value at the given index.

Panics if the index is out-of-bounds.

func (Bools) Len

func (b Bools) Len() int

Len returns the length of this repeated field.

func (*Bools) ProtoReflect

func (b *Bools) ProtoReflect() protoreflect.List

ProtoReflect returns a reflection value for this list.

func (Bools) Values

func (b Bools) Values() iter.Seq[bool]

Values returns an iterator over the elements of s.

type Bytes

type Bytes struct {
	Src *byte
	Raw slice.Slice[zc.Range]
	// contains filtered or unexported fields
}

Bytes is a repeated field containing bytes.

func (Bytes) All

func (b Bytes) All() iter.Seq2[int, []byte]

All returns an iterator over the indices and elements of b.

func (Bytes) Copy

func (b Bytes) Copy(out [][]byte, copy bool) [][]byte

Copy copies these bytes to a slice, appending to out.

If copy is true, this will make defensive copies of the returned strings.

To get a fresh slice, pass nil to this function.

func (Bytes) Get

func (b Bytes) Get(n int) []byte

Get extracts a value at the given index.

Panics if the index is out-of-bounds.

func (Bytes) Len

func (b Bytes) Len() int

Len returns the length of this repeated field.

func (*Bytes) ProtoReflect

func (b *Bytes) ProtoReflect() protoreflect.List

ProtoReflect returns a reflection value for this list.

func (Bytes) Values

func (b Bytes) Values() iter.Seq[[]byte]

Values returns an iterator over the elements of b.

type Messages

type Messages[M any] struct {
	// Slice[byte] if stride is nonzero, Slice[*Message] otherwise.
	Raw slice.Untyped
	// The array stride for when raw is an inlined message list.
	Stride uint32
}

Messages is a repeated message field.

Repeated messages use two different layouts, and the stride is used to differentiate them. The messages can either be packed into an arena slice, or the arena slice can contain *message pointers. These are called inlined and outlined modes; the stride is zero in the latter case. We switch to the outlined mode to avoid needing to copy parsed messages on slice resize.

M *must* be some type which wraps a dynamic.Message.

func (Messages[M]) All

func (m Messages[M]) All() iter.Seq2[int, *M]

All returns an iterator over the indices and elements of m.

func (Messages[M]) Copy

func (m Messages[M]) Copy(out []*M) []*M

Copy copies these scalars to a slice, appending to out.

To get a fresh slice, pass nil to this function.

func (Messages[M]) Get

func (m Messages[M]) Get(n int) *M

Get extracts a value at the given index.

Panics if the index is out-of-bounds.

func (Messages[_]) Len

func (m Messages[_]) Len() int

Len returns the length of this repeated field.

func (*Messages[M]) ProtoReflect

func (m *Messages[M]) ProtoReflect() protoreflect.List

ProtoReflect returns a reflection value for this list.

func (Messages[M]) Values

func (m Messages[M]) Values() iter.Seq[*M]

Values returns an iterator over the elements of m.

type Scalars

type Scalars[ZC, E tdp.Number] struct {
	Raw slice.Untyped
	// contains filtered or unexported fields
}

Scalars is a repeated field containing some varint-encoded type.

A Scalars can be either in zero-copy mode, in which case Raw is a slice of ZC, or in on-arena mode, in which case it is a slice of E. These can be distinct in the case of varint fields, which are only zero-copy when they are filled with byte-sized values.

func (Scalars[ZC, E]) All

func (s Scalars[ZC, E]) All() iter.Seq2[int, E]

All returns an iterator over the indices and elements of s.

func (Scalars[ZC, E]) Copy

func (s Scalars[ZC, E]) Copy(out []E) []E

Copy copies these scalars to a slice, appending to out.

To get a fresh slice, pass nil to this function.

func (Scalars[ZC, E]) Get

func (s Scalars[ZC, E]) Get(n int) E

Get extracts a value at the given index.

Panics if the index is out-of-bounds.

func (Scalars[ZC, E]) IsZC

func (s Scalars[ZC, E]) IsZC() bool

IsZC returns whether this Scalars is in zero-copy mode.

func (Scalars[ZC, E]) Len

func (s Scalars[ZC, E]) Len() int

Len returns the length of this repeated field.

func (*Scalars[ZC, E]) ProtoReflect

func (s *Scalars[ZC, E]) ProtoReflect() protoreflect.List

ProtoReflect returns a reflection value for this list.

func (Scalars[ZC, E]) Values

func (s Scalars[ZC, E]) Values() iter.Seq[E]

Values returns an iterator over the elements of s.

type Strings

type Strings struct {
	Src *byte
	Raw slice.Slice[zc.Range]
	// contains filtered or unexported fields
}

Strings is a repeated field containing strings.

The elements are zero-copy ranges relative to a source pointer.

func (Strings) All

func (s Strings) All() iter.Seq2[int, string]

All returns an iterator over the indices and elements of s.

func (Strings) Copy

func (s Strings) Copy(out []string, copy bool) []string

Copy copies these strings to a slice, appending to out.

If copy is true, this will make defensive copies of the returned strings.

To get a fresh slice, pass nil to this function.

func (Strings) Get

func (s Strings) Get(n int) string

Get extracts a value at the given index.

Panics if the index is out-of-bounds.

func (Strings) Len

func (s Strings) Len() int

Len returns the length of this repeated field.

func (*Strings) ProtoReflect

func (s *Strings) ProtoReflect() protoreflect.List

ProtoReflect returns a reflection value for this list.

func (Strings) Values

func (s Strings) Values() iter.Seq[string]

Values returns an iterator over the elements of s.

type Zigzags

type Zigzags[ZC, E tdp.Number] struct {
	Raw slice.Untyped
	// contains filtered or unexported fields
}

Zigzags is like Scalars, btu the elements are zigzag-encoded.

func (Zigzags[ZC, E]) All

func (z Zigzags[ZC, E]) All() iter.Seq2[int, E]

All returns an iterator over the indices and elements of s.

func (Zigzags[ZC, E]) Copy

func (z Zigzags[ZC, E]) Copy(out []E) []E

Copy copies these scalars to a slice, appending to out.

To get a fresh slice, pass nil to this function.

func (Zigzags[ZC, E]) Get

func (z Zigzags[ZC, E]) Get(n int) E

Get extracts a value at the given index.

Panics if the index is out-of-bounds.

func (Zigzags[ZC, E]) IsZC

func (z Zigzags[ZC, E]) IsZC() bool

IsZC returns whether this Scalars is in zero-copy mode.

func (Zigzags[ZC, E]) Len

func (z Zigzags[ZC, E]) Len() int

Len returns the length of this repeated field.

func (*Zigzags[ZC, E]) ProtoReflect

func (s *Zigzags[ZC, E]) ProtoReflect() protoreflect.List

ProtoReflect returns a reflection value for this list.

func (Zigzags[ZC, E]) Values

func (z Zigzags[ZC, E]) Values() iter.Seq[E]

Values returns an iterator over the elements of s.

Jump to

Keyboard shortcuts

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