stream

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package stream provides I/O stream utilities

Index

Constants

View Source
const (
	ListKey = data.Keyword("list")
	Dir     = data.Keyword("dir")
	File    = data.Keyword("file")

	OpenKey    = data.Keyword("open")
	ReadString = data.Keyword("read-string") // String
	ReadLines  = data.Keyword("read-lines")  // String
	ReadAll    = data.Keyword("read-all")    // Bytes
	ReadBlocks = data.Keyword("read-blocks") // Bytes
)
View Source
const (
	ErrExpectedDirectory   = "expected a directory, got a file: %s"
	ErrUnknownOpenMode     = "unknown open mode: %s"
	ErrExpectedFile        = "expected a file, got a directory: %s"
	ErrUnexpectedArguments = "unexpected additional arguments: %s"
)
View Source
const (
	// WriteKey is key used to write to a Writer
	WriteKey = data.Keyword("write")

	// CloseKey is the key used to close a file
	CloseKey = data.Keyword("close")

	// EmitKey is the key used to emit to a Channel
	EmitKey = data.Keyword("emit")

	// SequenceKey is the key used to retrieve the Sequence from a Channel
	SequenceKey = data.Keyword("seq")
)
View Source
const (
	ErrInvalidBlockSize = "block size must be greater than zero: %d"
)

Variables

This section is empty.

Functions

func LineInput

func LineInput(r *bufio.Reader) (ale.Value, bool)

LineInput is the standard single line input function

func NewChannel

func NewChannel(size int) *data.Object

NewChannel produces an Emitter and Sequence pair

func NewChannelSequence

func NewChannelSequence(ch <-chan ale.Value) data.Sequence

NewChannelSequence produces a new Sequence whose values come from a Go chan

func NewReader

func NewReader(r io.Reader, i InputFunc) data.Sequence

NewReader wraps a Go Reader, coupling it with an input function

func NewWriter

func NewWriter(w io.Writer, o OutputFunc) *data.Object

NewWriter wraps a Go Writer, coupling it with an output function

func RuneInput

func RuneInput(r *bufio.Reader) (ale.Value, bool)

RuneInput is the standard single rune input function

func StrOutput

func StrOutput(w *bufio.Writer, v ale.Value)

StrOutput is the standard string-based output function

func WrapFileSystem added in v0.3.0

func WrapFileSystem(fs fs.FS) *data.Object

Types

type InputFunc

type InputFunc func(*bufio.Reader) (ale.Value, bool)

InputFunc is a callback used to unmarshal values from a Reader

func BlockInput added in v0.3.0

func BlockInput(size int) (InputFunc, error)

BlockInput creates an InputFunc that reads up to a fixed number of bytes from the Reader.

type OutputFunc

type OutputFunc func(*bufio.Writer, ale.Value)

OutputFunc is a callback used to marshal values to a Writer

type Writer

type Writer func(ale.Value)

Writer is used to emit or write values to a stream

Jump to

Keyboard shortcuts

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