pagination

package
v0.6.21 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 2 Imported by: 157 modules, 162 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoToken = fmt.Errorf("pagination token cannot be nil")

Functions

This section is empty.

Types

type Bag

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

Bag holds pagination states that can be serialized for use as page tokens. It acts as a stack that you can push and pop pagination operations from.

func (*Bag) Current

func (pb *Bag) Current() *PageState

Current returns the current page state for the bag.

func (*Bag) Marshal

func (pb *Bag) Marshal() (string, error)

Marshal returns a string encoding of the state object.

func (*Bag) Next

func (pb *Bag) Next(pageToken string) error

Next pops the current token, and pushes a copy of it with an updated page token.

func (*Bag) NextToken

func (pb *Bag) NextToken(pageToken string) (string, error)

Next pops the current token, and pushes a copy of it with an updated page token.

func (*Bag) PageToken

func (pb *Bag) PageToken() string

PageToken returns the page token for the current state.

func (*Bag) Pop

func (pb *Bag) Pop() *PageState

Pop returns the current page action, and makes the top of the stack the current.

func (*Bag) Push

func (pb *Bag) Push(state PageState)

Push pushes a new page state onto the stack.

func (*Bag) ResourceID

func (pb *Bag) ResourceID() string

ResourceID returns the resource ID for the current state.

func (*Bag) ResourceTypeID

func (pb *Bag) ResourceTypeID() string

ResourceTypeID returns the resource type id for the current state.

func (*Bag) Unmarshal

func (pb *Bag) Unmarshal(input string) error

Unmarshal takes an input string and unmarshals it onto the state object.

type GenBag added in v0.2.64

type GenBag[T any] struct {
	// contains filtered or unexported fields
}

GenBag holds pagination states that can be serialized for use as page tokens. It acts as a stack that you can push and pop pagination operations from. This is a generic version of the Bag struct.

func GenBagFromToken added in v0.2.64

func GenBagFromToken[T any](pToken *Token) (*GenBag[T], error)

func (*GenBag[T]) Current added in v0.2.64

func (pb *GenBag[T]) Current() *T

Current returns the current page state for the bag.

func (*GenBag[T]) Marshal added in v0.2.64

func (pb *GenBag[T]) Marshal() (string, error)

Marshal returns a string encoding of the state object.

func (*GenBag[T]) Pop added in v0.2.64

func (pb *GenBag[T]) Pop() *T

Pop returns the current page action, and makes the top of the stack the current.

func (*GenBag[T]) Push added in v0.2.64

func (pb *GenBag[T]) Push(state T)

Push pushes a new page state onto the stack.

func (*GenBag[T]) Unmarshal added in v0.2.64

func (pb *GenBag[T]) Unmarshal(input string) error

Unmarshal takes an input string and unmarshals it onto the state object.

type PageState

type PageState struct {
	Token          string `json:"token,omitempty"`
	ResourceTypeID string `json:"type,omitempty"`
	ResourceID     string `json:"id,omitempty"`
}

type StreamState added in v0.1.16

type StreamState struct {
	Cursor  string `json:"cursor"`
	HasMore bool   `json:"done"`
}

type StreamToken added in v0.1.16

type StreamToken struct {
	Size   int
	Cursor string
}

type Token

type Token struct {
	Size  int
	Token string
}

Jump to

Keyboard shortcuts

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