Documentation
¶
Overview ¶
Package stream is a library of generic types designed to work on streams of values.
Index ¶
- func Copy[T any](w Writer[T], r Reader[T]) (int64, error)
- func ReadAll[T any](r Reader[T]) ([]T, error)
- func ReadAtLeast[T any](r Reader[T], buf []T, min int) (n int, err error)
- func ReadFull[T any](r Reader[T], buf []T) (int, error)
- func Seek(offset, length, seek int64, whence int) (int64, error)
- func Values[T any](it *Iterator[T]) ([]T, error)
- type Iterator
- type Optional
- type ReadCloser
- type ReadSeekCloser
- type ReadSeeker
- type Reader
- func ChanReader[T any](ch <-chan Optional[T]) Reader[T]
- func ConvertReader[To, From any](base Reader[From], conv func(From) (To, error)) Reader[To]
- func MultiReader[T any](readers ...Reader[T]) Reader[T]
- func NewReader[T any](values ...T) Reader[T]
- func ReaderFunc[T any](f func([]T) (int, error)) Reader[T]
- type WriteCloser
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
Copy writes values read from r to w, returning the number of values written and any error other than io.EOF.
Types ¶
type ReadCloser ¶
ReadCloser represents a closable stream of values of T.
ReadClosers is like io.ReadCloser for values of any type.
func ErrCloser ¶
func ErrCloser[T any](err error) ReadCloser[T]
func NewReadCloser ¶
func NewReadCloser[T any](r Reader[T], c io.Closer) ReadCloser[T]
NewReadCloser constructs a ReadCloser from the pair of r and c.
func NopCloser ¶
func NopCloser[T any](r Reader[T]) ReadCloser[T]
NopCloser constructs a ReadCloser from a Reader.
type Reader ¶
type Reader[T any] interface { // Reads values from the stream, returning the number of values read and any // error that occurred. // // The error is io.EOF when the end of the stream has been reached. Read(values []T) (int, error) }
Reader is an interface implemented by types that read a stream of values of type T.
func ChanReader ¶
func ConvertReader ¶
func MultiReader ¶
type WriteCloser ¶
WriteCloser represents a closable stream of values of T.
WriteClosers is like io.WriteCloser for values of any type.
func NewWriteCloser ¶
func NewWriteCloser[T any](w Writer[T], c io.Closer) WriteCloser[T]
Click to show internal directories.
Click to hide internal directories.