paging

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package paging implements result set management.

Index

Constants

View Source
const (
	NS = "http://jabber.org/protocol/rsm"
)

Namespaces used by this package.

Variables

View Source
var (
	Feature = info.Feature{Var: NS}
)

A list of service discovery features that are supported by this package.

Functions

This section is empty.

Types

type Iter

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

Iter provides a mechanism for iterating over the children of an XML element. Successive calls to Next will step through each child, returning its start element and a reader that is limited to the remainder of the child.

If the results indicate that there is another page of data, the paging child is skipped and the various paging methods will return queries that can be used to fetch the next and/or previous pages.

func NewIter

func NewIter(r xml.TokenReader, max uint64) *Iter

NewIter returns a new iterator that iterates over the children of the most recent start element already consumed from r.

func WrapIter

func WrapIter(iter *xmlstream.Iter, max uint64) *Iter

WrapIter returns a new iterator that supports paging from an existing xmlstream.Iter.

func (*Iter) Close

func (i *Iter) Close() error

Close indicates that we are finished with the given iterator. Calling it multiple times has no effect.

If the underlying TokenReader is also an io.Closer, Close calls the readers Close method.

func (*Iter) Current

func (i *Iter) Current() (*xml.StartElement, xml.TokenReader)

Current returns a reader over the most recent child.

func (*Iter) CurrentPage

func (i *Iter) CurrentPage() *Set

CurrentPage returns information about the current page.

It is only guaranteed to be set once iteration is finished, or when the iterator is closed without error and may be nil.

func (*Iter) Err

func (i *Iter) Err() error

Err returns the last error encountered by the iterator (if any).

func (*Iter) Next

func (i *Iter) Next() bool

Next returns true if there are more items to decode.

func (*Iter) NextPage

func (i *Iter) NextPage() *RequestNext

NextPage returns a value that can be used to construct a new iterator that queries for the next page.

It is only guaranteed to be set once iteration is finished, or when the iterator is closed without error and may be nil.

func (*Iter) PreviousPage

func (i *Iter) PreviousPage() *RequestPrev

PreviousPage returns a value that can be used to construct a new iterator that queries for the previous page.

It is only guaranteed to be set once iteration is finished, or when the iterator is closed without error and may be nil.

type RequestCount

type RequestCount struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/rsm set"`
}

RequestCount can be added to a query to request the count of elements without returning any actual items.

func (*RequestCount) MarshalXML

func (req *RequestCount) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

MarshalXML implements xml.Marshaler.

func (*RequestCount) TokenReader

func (req *RequestCount) TokenReader() xml.TokenReader

TokenReader implements xmlstream.Marshaler.

func (*RequestCount) WriteXML

func (req *RequestCount) WriteXML(w xmlstream.TokenWriter) (int, error)

WriteXML implements xmlstream.WriterTo.

type RequestIndex

type RequestIndex struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/rsm set"`
	Max     uint64   `xml:"max"`
	Index   uint64   `xml:"index"`
}

RequestIndex can be added to a query to skip to a specific page. It is not always supported.

func (*RequestIndex) MarshalXML

func (req *RequestIndex) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

MarshalXML implements xml.Marshaler.

func (*RequestIndex) TokenReader

func (req *RequestIndex) TokenReader() xml.TokenReader

TokenReader implements xmlstream.Marshaler.

func (*RequestIndex) WriteXML

func (req *RequestIndex) WriteXML(w xmlstream.TokenWriter) (int, error)

WriteXML implements xmlstream.WriterTo.

type RequestNext

type RequestNext struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/rsm set"`
	Max     uint64   `xml:"max,omitempty"`
	After   string   `xml:"after,omitempty"`
}

RequestNext can be added to a query to request the first page or to page forward.

func (*RequestNext) MarshalXML

func (req *RequestNext) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

MarshalXML implements xml.Marshaler.

func (*RequestNext) TokenReader

func (req *RequestNext) TokenReader() xml.TokenReader

TokenReader implements xmlstream.Marshaler.

func (*RequestNext) WriteXML

func (req *RequestNext) WriteXML(w xmlstream.TokenWriter) (int, error)

WriteXML implements xmlstream.WriterTo.

type RequestPrev

type RequestPrev struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/rsm set"`
	Max     uint64   `xml:"max,omitempty"`
	Before  string   `xml:"before"`
}

RequestPrev can be added to a query to request the last page or to page backward.

func (*RequestPrev) MarshalXML

func (req *RequestPrev) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

MarshalXML implements xml.Marshaler.

func (*RequestPrev) TokenReader

func (req *RequestPrev) TokenReader() xml.TokenReader

TokenReader implements xmlstream.Marshaler.

func (*RequestPrev) WriteXML

func (req *RequestPrev) WriteXML(w xmlstream.TokenWriter) (int, error)

WriteXML implements xmlstream.WriterTo.

type Set

type Set struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/rsm set"`
	First   struct {
		ID    string  `xml:",cdata"`
		Index *uint64 `xml:"index,attr,omitempty"`
	} `xml:"first"`
	Last  string  `xml:"last"`
	Count *uint64 `xml:"count,omitempty"`
}

Set describes a page from a returned result set.

func (*Set) MarshalXML

func (s *Set) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML satisfies the xml.Marshaler interface.

func (*Set) TokenReader

func (s *Set) TokenReader() xml.TokenReader

TokenReader implements xmlstream.Marshaler.

func (*Set) WriteXML

func (s *Set) WriteXML(w xmlstream.TokenWriter) (int, error)

WriteXML implements xmlstream.WriterTo.

Jump to

Keyboard shortcuts

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