Documentation
¶
Index ¶
- Variables
- type Stream
- func (r *Stream[T]) Async(fn func(T)) error
- func (r *Stream[T]) BeforeClose(f func())
- func (r *Stream[T]) Close()
- func (r *Stream[T]) Filter(f func(T) error)
- func (r *Stream[T]) IsClosed() bool
- func (r *Stream[T]) Next() bool
- func (r *Stream[T]) OnClose(f func())
- func (r *Stream[T]) Read() (T, error)
- func (r *Stream[T]) Size() int
- func (r *Stream[T]) Write(data T) error
- func (r *Stream[T]) WriteBlocking(data T)
- func (r *Stream[T]) WriteError(err error)
Constants ¶
This section is empty.
Variables ¶
var ErrEmpty = errors.New("no data available")
Functions ¶
This section is empty.
Types ¶
type Stream ¶
type Stream[T any] struct { // contains filtered or unexported fields }
func (*Stream[T]) Async ¶
Async wraps the stream with a new stream, and allows customized operations
func (*Stream[T]) BeforeClose ¶
func (r *Stream[T]) BeforeClose(f func())
BeforeClose adds a function to be called before the stream is closed
func (*Stream[T]) Filter ¶
Filter filters the stream with a function if the function returns an error, the stream will be closed
func (*Stream[T]) Next ¶
Next returns true if there are more data to be read and waits for the next data to be available returns false if the stream is closed NOTE: even if the stream is closed, it will return true if there is data available
func (*Stream[T]) OnClose ¶
func (r *Stream[T]) OnClose(f func())
OnClose adds a function to be called when the stream is closed
func (*Stream[T]) Read ¶
Read reads buffered data from the stream and it returns error only if the buffer is empty or an error is written to the stream
func (*Stream[T]) WriteBlocking ¶
func (r *Stream[T]) WriteBlocking(data T)
WriteBlocking writes data to the stream, blocks if the buffer is full until space becomes available
func (*Stream[T]) WriteError ¶
WriteError writes an error to the stream