ioset

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pipe

func Pipe() (In, Out)

Pipe returns a pair of piped readers and writers collection. They are useful for controlling stdio stream using Forwarder function.

Types

type Forwarder

type Forwarder struct {

	// PropagateStdinClose indicates whether EOF from Stdin of Out should be propagated.
	// If this is true, EOF from Stdin (reader) of Out closes Stdin (writer) of In.
	PropagateStdinClose bool
	// contains filtered or unexported fields
}

Forwarder forwards IO between readers and writers contained in In and Out structs. In and Out can be changed during forwarding using SetIn and SetOut methods.

func NewForwarder

func NewForwarder() *Forwarder

func (*Forwarder) Close

func (f *Forwarder) Close() (retErr error)

func (*Forwarder) SetIn

func (f *Forwarder) SetIn(in *In)

func (*Forwarder) SetOut

func (f *Forwarder) SetOut(out *Out)

type In

type In struct {
	Stdin  io.ReadCloser
	Stdout io.WriteCloser
	Stderr io.WriteCloser
}

func (In) Close

func (s In) Close() (retErr error)

type MuxIO

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

func NewMuxIO

func NewMuxIO(in In, outs []MuxOut, initIdx int, toggleMessage func(prev int, res int) string) *MuxIO

NewMuxIO forwards IO stream to/from "in" and "outs". It toggles IO when it detects "C-a-c" key. "outs" are closed automatically when "in" reaches EOF. "in" doesn't closed automatically so the caller needs to explicitly close it.

func (*MuxIO) Disable

func (m *MuxIO) Disable(i int) error

func (*MuxIO) Enable

func (m *MuxIO) Enable(i int)

func (*MuxIO) SwitchTo

func (m *MuxIO) SwitchTo(i int) error

type MuxOut

type MuxOut struct {
	Out
	EnableHook  func()
	DisableHook func()
}

type Out

type Out struct {
	Stdin  io.WriteCloser
	Stdout io.ReadCloser
	Stderr io.ReadCloser
}

func (Out) Close

func (s Out) Close() (retErr error)

type SingleForwarder

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

SingleForwarder forwards IO from a reader to a writer. The reader and writer can be changed during forwarding using SetReader and SetWriter methods.

func NewSingleForwarder

func NewSingleForwarder() *SingleForwarder

func (*SingleForwarder) Close

func (f *SingleForwarder) Close() (retErr error)

Close closes the both of registered reader and writer and finishes the forwarder.

func (*SingleForwarder) SetReader

func (f *SingleForwarder) SetReader(r io.ReadCloser)

SetWriter sets the specified reader as the forward source.

func (*SingleForwarder) SetWriter

func (f *SingleForwarder) SetWriter(w io.WriteCloser, curWEOFHandler func() io.WriteCloser)

SetWriter sets the specified writer as the forward destination. If curWEOFHandler isn't nil, this will be called when the current reader returns EOF.

Jump to

Keyboard shortcuts

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