std/io/hostio
import "github.com/eugenioenko/goalchemy/std/io/hostio"Package hostio adapts host streams passed to library exports as std/io interfaces. The compiler includes it in libraries whose exports take std/io parameters; programs do not import it directly. Each operation is a host callback named “goalchemy.stream.<id>” carrying a one-byte opcode: ‘r’ with an 8-byte count, ‘w’ with data, ‘s’ with an 8-byte offset and 1-byte whence, or ‘c’. Every reply starts with a status byte: 0 for success, 1 for a read that reached end of stream, or 2 for a host error followed by its message. Read data, or the 8-byte big-endian write count or seek position, follows a success status.
const MaxChunk = 128<<10 - 16MaxChunk bounds the bytes moved by one host operation, within every target’s callback reply limit.
const MaxView = 1 << 20MaxView bounds the bytes one host read of a source stream returns.
CloseView
Section titled “CloseView”func CloseView(c io.Closer) errorCloseView closes c for a host stream view.
ReadCloser
Section titled “ReadCloser”func ReadCloser(id int64) io.ReadCloserReadCloser returns the host stream id as an io.ReadCloser.
ReadSeekCloser
Section titled “ReadSeekCloser”func ReadSeekCloser(id int64) io.ReadSeekCloserReadSeekCloser returns the host stream id as an io.ReadSeekCloser.
ReadSeeker
Section titled “ReadSeeker”func ReadSeeker(id int64) io.ReadSeekerReadSeeker returns the host stream id as an io.ReadSeeker.
ReadView
Section titled “ReadView”func ReadView(r io.Reader, n int) ([]byte, bool, error)ReadView reads at most n bytes from r for a host stream view. It retries empty reads, so it returns data, end of stream, or an error. eof reports that r returned io.EOF; data read before it is returned with it.
ReadWriter
Section titled “ReadWriter”func ReadWriter(id int64) io.ReadWriterReadWriter returns the host stream id as an io.ReadWriter.
Reader
Section titled “Reader”func Reader(id int64) io.ReaderReader returns the host stream id as an io.Reader.
SeekView
Section titled “SeekView”func SeekView(s io.Seeker, offset int64, whence int) (int64, error)SeekView seeks s for a host stream view.
WriteCloser
Section titled “WriteCloser”func WriteCloser(id int64) io.WriteCloserWriteCloser returns the host stream id as an io.WriteCloser.
WriteSeeker
Section titled “WriteSeeker”func WriteSeeker(id int64) io.WriteSeekerWriteSeeker returns the host stream id as an io.WriteSeeker.
WriteView
Section titled “WriteView”func WriteView(w io.Writer, p []byte) (int, error)WriteView writes all of p to w for a host stream view.
Writer
Section titled “Writer”func Writer(id int64) io.WriterWriter returns the host stream id as an io.Writer.
type Stream
Section titled “type Stream”type Stream struct {}Stream is a host stream identified by a per-call registry number.
Stream.Close
Section titled “Stream.Close”func (s *Stream) Close() errorStream.Read
Section titled “Stream.Read”func (s *Stream) Read(p []byte) (int, error)Stream.Seek
Section titled “Stream.Seek”func (s *Stream) Seek(offset int64, whence int) (int64, error)Stream.Write
Section titled “Stream.Write”func (s *Stream) Write(p []byte) (int, error)