photos

package
v0.100.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 4 Imported by: 6

Documentation

Overview

Package photos contains photos iteration helper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elem

type Elem struct {
	Photo    tg.PhotoClass
	Entities peer.Entities
}

Elem is a photo iterator element.

type GetUserPhotosQueryBuilder

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

GetUserPhotosQueryBuilder is query builder of PhotosGetUserPhotos.

func (*GetUserPhotosQueryBuilder) BatchSize

func (b *GetUserPhotosQueryBuilder) BatchSize(batchSize int) *GetUserPhotosQueryBuilder

BatchSize sets buffer of message loaded from one request. Be carefully, when set this limit, because Telegram does not return error if limit is too big, so results can be incorrect.

func (*GetUserPhotosQueryBuilder) Collect

func (b *GetUserPhotosQueryBuilder) Collect(ctx context.Context) ([]Elem, error)

Collect creates iterator and collects all elements to slice.

func (*GetUserPhotosQueryBuilder) Count

Count fetches remote state to get number of elements.

func (*GetUserPhotosQueryBuilder) ForEach

ForEach calls given callback on each iterator element.

func (*GetUserPhotosQueryBuilder) Iter

Iter returns iterator using built query.

func (*GetUserPhotosQueryBuilder) Query

Query implements Query interface.

func (*GetUserPhotosQueryBuilder) UserID

UserID sets UserID field of GetUserPhotos query.

type Iterator

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

Iterator is a photo stream iterator.

func NewIterator

func NewIterator(query Query, limit int) *Iterator

NewIterator creates new iterator.

func (*Iterator) Err

func (m *Iterator) Err() error

Err returns the error, if any, that was encountered during iteration.

func (*Iterator) FetchTotal

func (m *Iterator) FetchTotal(ctx context.Context) (int, error)

FetchTotal fetches and returns count of elements.

func (*Iterator) Next

func (m *Iterator) Next(ctx context.Context) bool

Next prepares the next message for reading with the Value method. It returns true on success, or false if there is no next message or an error happened while preparing it. Err should be consulted to distinguish between the two cases.

func (*Iterator) Offset

func (m *Iterator) Offset(offset int) *Iterator

Offset sets Offset request parameter.

func (*Iterator) Total

func (m *Iterator) Total(ctx context.Context) (int, error)

Total returns last fetched count of elements. If count was not fetched before, it requests server using FetchTotal.

func (*Iterator) Value

func (m *Iterator) Value() Elem

Value returns current message.

type Query

type Query interface {
	Query(ctx context.Context, req Request) (tg.PhotosPhotosClass, error)
}

Query is an abstraction for photos request. NB: iterator mutates returned data (sorts, at least).

type QueryBuilder

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

QueryBuilder is a helper to create message queries.

func NewQueryBuilder

func NewQueryBuilder(raw *tg.Client) *QueryBuilder

NewQueryBuilder creates new QueryBuilder.

func (*QueryBuilder) GetUserPhotos

func (q *QueryBuilder) GetUserPhotos(paramUserID tg.InputUserClass) *GetUserPhotosQueryBuilder

GetUserPhotos creates query builder of PhotosGetUserPhotos.

type QueryFunc

type QueryFunc func(ctx context.Context, req Request) (tg.PhotosPhotosClass, error)

QueryFunc is a function adapter for Query.

func (QueryFunc) Query

func (q QueryFunc) Query(ctx context.Context, req Request) (tg.PhotosPhotosClass, error)

Query implements Query interface.

type Request

type Request struct {
	Offset int
	Limit  int
}

Request is a parameter for Query.

Jump to

Keyboard shortcuts

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