stream

package
v0.0.0-...-e537141 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StdModes = [...]Mode{ModeStdout, ModeStdin, ModeStderr}

	StdIOModes = StdToIOMode{
		ModeStdin:  IOModeRead,
		ModeStdout: IOModeWrite,
		ModeStderr: IOModeWrite,
	}

	IOModesToStd = mapping.Reverse(StdIOModes)

	StdSetups = makeStdSetups()
)
View Source
var StdNames = StdNameMap{
	ModeStderr: "stderr",
	ModeStdin:  "stdin",
	ModeStdout: "stdout",
}

Functions

func AddFile

func AddFile(s MutStreams, key string, path string, mode IOMode, fsys afero.Fs) error

func ParseSetupInto

func ParseSetupInto(lp LineParser, sl SetupLines, fsys afero.Fs, s MutStreams) error

Types

type Closer

type Closer interface {
	Close(key string, c io.Closer) error
}

type Config

type Config struct {
	Fs     afero.Fs
	Parser Parser
	Lines  SetupLines
}

type ConfigParser

type ConfigParser interface {
	ParseReader(string) (Setup, error)
}

type IOMode

type IOMode int

ENUM(

Read
Write
ReadWrite

)

const (
	// IOModeRead is a IOMode of type Read.
	IOModeRead IOMode = iota
	// IOModeWrite is a IOMode of type Write.
	IOModeWrite
	// IOModeReadWrite is a IOMode of type ReadWrite.
	IOModeReadWrite
)

func ParseIOMode

func ParseIOMode(name string) (IOMode, error)

ParseIOMode attempts to convert a string to a IOMode.

func (IOMode) MarshalText

func (x IOMode) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (IOMode) String

func (x IOMode) String() string

String implements the Stringer interface.

func (*IOMode) UnmarshalText

func (x *IOMode) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type IOModeToStd

type IOModeToStd map[IOMode]Mode

type InOutStreams

type InOutStreams map[string]ReadWriteCloser

type InStreams

type InStreams map[string]ReadCloser

type LineParser

type LineParser interface {
	ParseStreamLine(line string) (Setup, error)
}

type Maker

type Maker interface {
	OpenStream(fsys fs.FS, path string) (ReadCloser, error)
	CreateStream(fsys fs.FS, path string) (WriteCloser, error)
	OpenMutStream(fsys fs.FS, path string) (ReadWriteCloser, error)
}

type Manager

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

func DoConfig

func DoConfig(cfg Config, meth Methods) (*Manager, error)

func NewManager

func NewManager(fs afero.Fs, meth Methods) Manager

func (Manager) CloseAll

func (m Manager) CloseAll() error

func (*Manager) Create

func (m *Manager) Create(path string) (io.WriteCloser, error)

func (*Manager) CreateRw

func (m *Manager) CreateRw(path string) (io.ReadWriteCloser, error)

func (Manager) GetReadWriter

func (m Manager) GetReadWriter(key string) (io.ReadWriter, error)

func (Manager) GetReader

func (m Manager) GetReader(key string) (io.Reader, error)

func (Manager) GetWriter

func (m Manager) GetWriter(key string) (io.Writer, error)

func (*Manager) NamedOpen

func (m *Manager) NamedOpen(name string) (io.Reader, error)

func (*Manager) NamedReadWriter

func (m *Manager) NamedReadWriter(name string) (io.ReadWriter, error)

func (*Manager) NamedWriter

func (m *Manager) NamedWriter(name string) (io.Writer, error)

func (*Manager) Open

func (m *Manager) Open(path string) (io.ReadCloser, error)

func (*Manager) SetReadWriter

func (m *Manager) SetReadWriter(key string, w io.ReadWriteCloser) error

func (*Manager) SetReader

func (m *Manager) SetReader(key string, r io.ReadCloser) error

func (*Manager) SetWriter

func (m *Manager) SetWriter(key string, w io.WriteCloser) error

type Methods

type Methods struct {
	Map         *mapping.Methods
	Closer      Closer
	NamedGetter NamedGetter
}

type Mode

type Mode int

ENUM(

Stdout
Stdin
Stderr
DevNull
File

)

const (
	// ModeStdout is a Mode of type Stdout.
	ModeStdout Mode = iota
	// ModeStdin is a Mode of type Stdin.
	ModeStdin
	// ModeStderr is a Mode of type Stderr.
	ModeStderr
	// ModeDevNull is a Mode of type DevNull.
	ModeDevNull
	// ModeFile is a Mode of type File.
	ModeFile
)

func ParseMode

func ParseMode(name string) (Mode, error)

ParseMode attempts to convert a string to a Mode.

func (Mode) MarshalText

func (x Mode) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (Mode) String

func (x Mode) String() string

String implements the Stringer interface.

func (*Mode) UnmarshalText

func (x *Mode) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type MutStreams

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

func (MutStreams) SetReadWriter

func (ms MutStreams) SetReadWriter(key string, rw ReadWriteCloser) error

func (MutStreams) SetReader

func (ms MutStreams) SetReader(key string, rc ReadCloser) error

func (MutStreams) SetWriter

func (ms MutStreams) SetWriter(key string, wc WriteCloser) error

type NameToStd

type NameToStd map[string]Mode

type NamedGetter

type NamedGetter interface {
	NamedReader(name string, m *Manager) (io.Reader, error)
	NamedWriter(name string, m *Manager) (io.Writer, error)
	NamedReadWriter(name string, m *Manager) (io.ReadWriter, error)
}

type OutStreams

type OutStreams map[string]WriteCloser

type ParseEachLine

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

func (ParseEachLine) ParseStreamSetup

func (pl ParseEachLine) ParseStreamSetup(sl SetupLines, fsys afero.Fs, s MutStreams) error

type Parser

type Parser interface {
	ParseStreamSetup(SetupLines, afero.Fs, MutStreams) error
}

type ReadCloser

type ReadCloser = io.ReadCloser

type ReadWriteCloser

type ReadWriteCloser = io.ReadWriteCloser

type Setup

type Setup struct {
	Path       string
	StreamMode Mode
	IOMode     IOMode
}

type SetupLines

type SetupLines map[string]string

type StdNameMap

type StdNameMap map[Mode]string

func (StdNameMap) IsMode

func (s StdNameMap) IsMode(mode Mode, name string) bool

func (StdNameMap) IsStderr

func (s StdNameMap) IsStderr(name string) bool

func (StdNameMap) IsStdin

func (s StdNameMap) IsStdin(name string) bool

func (StdNameMap) IsStdout

func (s StdNameMap) IsStdout(name string) bool

type StdSetup

type StdSetup map[Mode]Setup

type StdToIOMode

type StdToIOMode map[Mode]IOMode

type Streams

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

func EmptyStreams

func EmptyStreams() Streams

func ParseSetup

func ParseSetup(lp LineParser, sl SetupLines, fsys afero.Fs, meth *mapping.Methods) (Streams, error)

func (*Streams) MutRef

func (s *Streams) MutRef(meth *mapping.Methods) MutStreams

func (Streams) SetReadWriter

func (s Streams) SetReadWriter(meth *mapping.Methods, key string, rw ReadWriteCloser) error

func (Streams) SetReader

func (s Streams) SetReader(meth *mapping.Methods, key string, rc ReadCloser) error

func (Streams) SetWriter

func (s Streams) SetWriter(meth *mapping.Methods, key string, wc WriteCloser) error

type WriteCloser

type WriteCloser = io.WriteCloser

Jump to

Keyboard shortcuts

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