Documentation ¶
Index ¶
- func Collect[T any](ctx context.Context, it Iterator[T], max int) (ret []T, _ error)
- func EOS() error
- func First[T any](ctx context.Context, it Iterator[T]) (maybe.Maybe[T], error)
- func ForEach[T any](ctx context.Context, it Iterator[T], fn func(T) error) error
- func IsEOS(err error) bool
- func Last[T any](ctx context.Context, it Iterator[T]) (last maybe.Maybe[T], _ error)
- func LoadChan[T any](ctx context.Context, it Iterator[T], out chan<- T) error
- func Next[T any](ctx context.Context, it Iterator[T]) (T, error)
- func Peek[T any](ctx context.Context, it Peekable[T]) (T, error)
- func ReadFull[T any](ctx context.Context, it Iterator[T], buf []T) (int, error)
- type Batcher
- type Chan
- type EndOfStream
- type Iterator
- type Peekable
- type Reader
- type Seeker
- type Slice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Collect ¶
Collect is used to collect all of the items from an Iterator. If more than max elements are emitted, then Collect will return an error.
func First ¶
First returns (Just, nil) when the stream produces the next element or (Nothing, nil) if the stream is over. First returns (Nothing, err) if it encouters any error.
func LoadChan ¶
LoadChan loads a channel from an Iterator. If the context is cancelled, LoadChan returns that error. If it.Next errors other than EOS, LoadChan returns that error.
func Next ¶
Next returns a new T instead of writing it to a pointer destination. It calls it.Next on the Iterator
Types ¶
type EndOfStream ¶
type EndOfStream struct{}
EndOfStream is returned by Next and Seek to indicate that the stream has no more elements.
func (EndOfStream) Error ¶
func (EndOfStream) Error() string
type Iterator ¶
type Peekable ¶
type Peekable[T any] interface { Iterator[T] // Peek shows the next element of the Iterator without changing the state of the Iterator Peek(ctx context.Context, dst *T) error }
Peekable is an Iterator which also has the Peek method