pagination

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: Apache-2.0 Imports: 2 Imported by: 89

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 PageState

type PageState struct {
	Token          string `json:"token"`
	ResourceTypeID string `json:"resource_type_id"`
	ResourceID     string `json:"resource_id"`
}

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