const EOF
pub const EOF = "EOF"Purpose
Constant EOF, defining protocol or algorithm parameters.
#ioBuffer / Cursor, stream copying, EOF/error results with data, and write-progress contracts; also multi/tee/section/pipe.
const EOFpub const EOF = "EOF"Constant EOF, defining protocol or algorithm parameters.
struct@ Writerstruct@ Writer {
fn write(&string) int
}Writer data I/O method-set constraint.
write fn write(&string) intWriter: write data and return the byte count.(Writer) writefn write(&string) intOperation on Writer: write data and return the byte count.
self SelfSelf instance used by this call (value receiver).string &stringint — bytes written
struct@ Readerstruct@ Reader {
fn read_n(int) string
}Reader data I/O method-set constraint.
read_n fn read_n(int) stringReader: read at most n bytes; may return shorter or empty at end.(Reader) read_nfn read_n(int) stringOperation on Reader: read at most n bytes; may return shorter or empty at end.
self SelfSelf instance used by this call (value receiver).int intstring — result string
struct Bufferpub struct Buffer {
pub data string
pub off int
}Structure encapsulating data, off.
data stringoff intstruct Cursorpub struct Cursor {
pub data string
pub off int
}Structure encapsulating data, off.
data stringoff intbufferpub fn buffer() BufferExecute buffer.
No arguments are required.
Buffer — a value of this type
buffer_frompub fn buffer_from(s string) BufferBuffer from.
s stringBuffer — a value of this type
cursorpub fn cursor(s string) CursorExecute cursor.
s stringCursor — a value of this type
($&Cursor) resetpub fn (c $&Cursor) reset(s string)Operation on $&Cursor: clear internal state so the value can be reused.
c $&CursorCursor instance used by this call (exclusive borrow).s stringThis call does not return a value.
($&Buffer) resetpub fn (b $&Buffer) reset()Operation on $&Buffer: clear internal state so the value can be reused.
b $&BufferBuffer instance used by this call (exclusive borrow).This call does not return a value.
(&Buffer) lenpub fn (b &Buffer) len() intOperation on &Buffer: return the length.
b &BufferBuffer instance used by this call (borrow).int — a value of this type
(&Buffer) cappub fn (b &Buffer) cap() intOperation on &Buffer: return the capacity.
b &BufferBuffer instance used by this call (borrow).int — a value of this type
(&Cursor) sizepub fn (c &Cursor) size() intOperation on &Cursor: return the size.
c &CursorCursor instance used by this call (borrow).int — a value of this type
($&Buffer) writepub fn (b $&Buffer) write(data &string) intOperation on $&Buffer: write data and return the byte count.
b $&BufferBuffer instance used by this call (exclusive borrow).data &stringint — bytes written
($&Buffer) write_strpub fn (b $&Buffer) write_str(s string) intwrite_str appends an owned string without requiring a borrow of a local.
b $&BufferBuffer instance used by this call (exclusive borrow).s stringint — a value of this type
($&Buffer) write_bytepub fn (b $&Buffer) write_byte(c int) intOperation on $&Buffer: write one byte.
b $&BufferBuffer instance used by this call (exclusive borrow).c intint — bytes written
($&Buffer) read_npub fn (b $&Buffer) read_n(n int) stringOperation on $&Buffer: read at most n bytes; may return shorter or empty at end.
b $&BufferBuffer instance used by this call (exclusive borrow).n intstring — result string
(&Buffer) bytespub fn (b &Buffer) bytes() stringOperation on &Buffer: return the buffered bytes.
b &BufferBuffer instance used by this call (borrow).string — result string
($&Cursor) read_npub fn (c $&Cursor) read_n(n int) stringOperation on $&Cursor: read at most n bytes; may return shorter or empty at end.
c $&CursorCursor instance used by this call (exclusive borrow).n intstring — result string
copypub fn copy(dst Buffer, src Cursor) stringDrain src cursor into dst buffer until EOF, returning remaining bytes.
dst Buffersrc Cursorwritten string content
copy_topub fn copy_to(dst Buffer, src Cursor) Buffercopy_to is the Buffer-returning form.
dst Buffersrc CursorBuffer — a value of this type
read_allpub fn read_all(src Cursor) stringRead all.
src Cursorstring — result string
(&Cursor) remainingpub fn (c &Cursor) remaining() intExecute remaining on &Cursor.
c &CursorCursor instance used by this call (borrow).int — a value of this type
($&Cursor) seekpub fn (c $&Cursor) seek(offset int, whence int) intOperation on $&Cursor: move the read position. whence 0/1/2 = absolute / relative / from end. Throws on failure; handle the error or propagate it to the caller.
c $&CursorCursor instance used by this call (exclusive borrow).offset intwhence intint — a value of this type
(&Cursor) read_atpub fn (c &Cursor) read_at(n int, off int) stringOperation on &Cursor: read at most n bytes starting at offset off. Throws on failure; handle the error or propagate it to the caller.
c &CursorCursor instance used by this call (borrow).n intoff intstring — result string
read_fullpub fn read_full(src Cursor, n int) stringRead full.
src Cursorn intstring — result string
read_at_leastpub fn read_at_least(src Cursor, min int, max int) stringRead at least. Throws on failure; handle the error or propagate it to the caller.
src Cursormin intmax intstring — result string
copy_npub fn copy_n(dst Buffer, src Cursor, n int) stringCopy n. Throws on failure; handle the error or propagate it to the caller.
dst Buffersrc Cursorn intstring — result string
struct LimitCursorpub struct LimitCursor {
pub src Cursor
pub n int
}Structure encapsulating src, n.
src Cursorn intlimit_cursorpub fn limit_cursor(src Cursor, n int) LimitCursorLimit cursor.
src Cursorn intLimitCursor — a value of this type
(LimitCursor) remainingpub fn (l LimitCursor) remaining() intExecute remaining on LimitCursor.
l LimitCursorLimitCursor instance used by this call (value receiver).int — a value of this type
($&LimitCursor) read_npub fn (l $&LimitCursor) read_n(n int) stringOperation on $&LimitCursor: read at most n bytes; may return shorter or empty at end.
l $&LimitCursorLimitCursor instance used by this call (exclusive borrow).n intstring — result string
struct Discardpub struct Discard {
pub n int
}Structure encapsulating n.
n intdiscardpub fn discard() DiscardExecute discard.
No arguments are required.
Discard — a value of this type
($&Discard) writepub fn (d $&Discard) write(data &string) intOperation on $&Discard: write data and return the byte count.
d $&DiscardDiscard instance used by this call (exclusive borrow).data &stringint — bytes written
(Discard) writtenpub fn (d Discard) written() intExecute written on Discard.
d DiscardDiscard instance used by this call (value receiver).int — a value of this type
struct MultiCursorpub struct MultiCursor {
pub chunks []string
pub i int
pub off int
}Concatenate string snapshots ( MultiReader, bound to Cursor-shaped chunks — no generic Reader). One read_n drains the current chunk only empty/exhausted chunks are skipped in the same call.
chunks []stringi intoff intmulti_cursorpub fn multi_cursor(parts <-> string) MultiCursorMulti cursor.
parts <-> stringMultiCursor — a value of this type
($&MultiCursor) read_npub fn (m $&MultiCursor) read_n(n int) stringOperation on $&MultiCursor: read at most n bytes; may return shorter or empty at end.
m $&MultiCursorMultiCursor instance used by this call (exclusive borrow).n intstring — result string
struct MultiBufferpub struct MultiBuffer {
pub parts []string
}Write the same bytes to n owning destinations ( MultiWriter).
parts []stringmulti_bufferpub fn multi_buffer(n int) MultiBufferMulti buffer.
n intMultiBuffer — a value of this type
($&MultiBuffer) writepub fn (m $&MultiBuffer) write(data &string) intOperation on $&MultiBuffer: write data and return the byte count.
m $&MultiBufferMultiBuffer instance used by this call (exclusive borrow).data &stringint — bytes written
(&MultiBuffer) textpub fn (m &MultiBuffer) text(i int) stringOperation on &MultiBuffer: return the current text.
m &MultiBufferMultiBuffer instance used by this call (borrow).i intstring — result string
struct Teepub struct Tee {
pub src Cursor
pub dst Buffer
}Read from src, copy each chunk into dst ( TeeReader).
src Cursordst Bufferteepub fn tee(src Cursor, dst Buffer) TeeConstruct a Tee reader that mirrors every read chunk into dst.
src Cursordst BufferTee — a value of this type
($&Tee) read_npub fn (t $&Tee) read_n(n int) stringOperation on $&Tee: read at most n bytes; may return shorter or empty at end.
t $&TeeTee instance used by this call (exclusive borrow).n intstring — result string
(&Tee) copiedpub fn (t &Tee) copied() stringExecute copied on &Tee.
t &TeeTee instance used by this call (borrow).string — result string
struct SectionCursorpub struct SectionCursor {
pub data string
pub base int
pub limit int
pub off int
}Window into a string snapshot ( SectionReader + ReadAt/Seek).
data stringbase intlimit intoff intsection_cursorpub fn section_cursor(s string, off int, n int) SectionCursorSection cursor.
s stringoff intn intSectionCursor — a value of this type
($&SectionCursor) read_npub fn (s $&SectionCursor) read_n(n int) stringOperation on $&SectionCursor: read at most n bytes; may return shorter or empty at end.
s $&SectionCursorSectionCursor instance used by this call (exclusive borrow).n intstring — result string
(&SectionCursor) sizepub fn (s &SectionCursor) size() intOperation on &SectionCursor: return the size.
s &SectionCursorSectionCursor instance used by this call (borrow).int — a value of this type
($&SectionCursor) seekpub fn (s $&SectionCursor) seek(offset int, whence int) intOperation on $&SectionCursor: move the read position. whence 0/1/2 = absolute / relative / from end. Throws on failure; handle the error or propagate it to the caller.
s $&SectionCursorSectionCursor instance used by this call (exclusive borrow).offset intwhence intint — a value of this type
(&SectionCursor) read_atpub fn (s &SectionCursor) read_at(n int, off int) stringOperation on &SectionCursor: read at most n bytes starting at offset off. Throws on failure; handle the error or propagate it to the caller.
s &SectionCursorSectionCursor instance used by this call (borrow).n intoff intstring — result string
struct PipeReaderpub struct PipeReader {
pub r chan string
pub buf string
pub off int
}In-memory one-way pipe ( io.Pipe shape; queue is a bounded chan like net.pipe, not a synchronous unbuffered handshake).
r chan stringbuf stringoff intstruct PipeWriterpub struct PipeWriter {
pub w chan string
pub closed int
}Writing end of an in-memory synchronous pipe.
w chan stringclosed intstruct Pipepub struct Pipe {
pub r PipeReader
pub w PipeWriter
}Structure encapsulating r, w.
r PipeReaderw PipeWriterpipepub fn pipe() PipeCreate a pair of connected synchronous in-memory pipe endpoints.
No arguments are required.
Pipe — a value of this type
($&PipeReader) read_npub fn (p $&PipeReader) read_n(n int) stringOperation on $&PipeReader: read at most n bytes; may return shorter or empty at end.
p $&PipeReaderPipeReader instance used by this call (exclusive borrow).n intstring — result string
(PipeWriter) writepub fn (w PipeWriter) write(data &string) intOperation on PipeWriter: write data and return the byte count. Throws on failure; handle the error or propagate it to the caller.
w PipeWriterPipeWriter instance used by this call (value receiver).data &stringint — bytes written
($&PipeWriter) closepub fn (w $&PipeWriter) close() intOperation on $&PipeWriter: close the resource.
w $&PipeWriterPipeWriter instance used by this call (exclusive borrow).int — a value of this type
enum ReadResultpub enum ReadResult {
Data(string)
End(string)
Failed(string, errors.Error)
}Owned chunks; terminal conditions may accompany the last bytes.
enum WriteResultpub enum WriteResult {
Written(int)
Failed(int, errors.Error)
Unknown(errors.Error)
}Counts acknowledge a prefix of this call's input. Unknown is required when a legacy operation throws after effects it cannot quantify.
enum CopyResultpub enum CopyResult {
Copied(int)
Failed(int, errors.Error)
Uncertain(int, errors.Error)
}Failed has an exact accepted count; Uncertain has a confirmed lower bound.
struct@ ProgressReaderpub struct@ ProgressReader {
fn read_result(int) ReadResult
}ProgressReader data I/O method-set constraint.
read_result fn read_result(int) ReadResultProgressReader: read result.(ProgressReader) read_resultfn read_result(int) ReadResultOperation on ProgressReader: read result.
self SelfSelf instance used by this call (value receiver).int intReadResult — a value of this type
struct@ ProgressWriterpub struct@ ProgressWriter {
fn write_result(string) WriteResult
}ProgressWriter data I/O method-set constraint.
write_result fn write_result(string) WriteResultProgressWriter: write result.(ProgressWriter) write_resultfn write_result(string) WriteResultOperation on ProgressWriter: write result.
self SelfSelf instance used by this call (value receiver).string stringWriteResult — a value of this type
struct LegacyReader#R:StreamReaderpub struct LegacyReader#R:StreamReader {
pub src R
}Legacy readers cannot recover bytes that were lost when throwing.
src Rstruct LegacyWriter#W:StreamWriterpub struct LegacyWriter#W:StreamWriter {
pub dst W
}Io Streaming writer and encoder.
dst Wprogress_readerpub fn progress_reader#R:StreamReader(src R) LegacyReader#RProgress reader.
src RLegacyReader#R — a value of this type
progress_writerpub fn progress_writer#W:StreamWriter(dst W) LegacyWriter#WProgress writer.
dst WLegacyWriter#W — a value of this type
($&LegacyReader#R) read_resultpub fn (r $&LegacyReader#R) read_result(n int) ReadResultOperation on $&LegacyReader#R: read result.
r $&LegacyReader#RLegacyReader#R instance used by this call (exclusive borrow).n intReadResult — a value of this type
($&LegacyWriter#W) write_resultpub fn (w $&LegacyWriter#W) write_result(data string) WriteResultOperation on $&LegacyWriter#W: write result.
w $&LegacyWriter#WLegacyWriter#W instance used by this call (exclusive borrow).data stringWriteResult — a value of this type
copy_resultpub fn copy_result#W:ProgressWriter,R:ProgressReader(dst $&W, src $&R) CopyResultCopy result.
dst $&Wsrc $&RCopyResult — a value of this type
copy_result_bufferpub fn copy_result_buffer#W:ProgressWriter,R:ProgressReader(dst $&W, src $&R, size int) CopyResultCopy result buffer.
dst $&Wsrc $&Rsize intCopyResult — a value of this type
copy_result_npub fn copy_result_n#W:ProgressWriter,R:ProgressReader(dst $&W, src $&R, n int) CopyResultCopy result n.
dst $&Wsrc $&Rn intCopyResult — a value of this type
($&Cursor) read_resultpub fn (c $&Cursor) read_result(n int) ReadResultOperation on $&Cursor: read result.
c $&CursorCursor instance used by this call (exclusive borrow).n intReadResult — a value of this type
($&Buffer) read_resultpub fn (b $&Buffer) read_result(n int) ReadResultOperation on $&Buffer: read result.
b $&BufferBuffer instance used by this call (exclusive borrow).n intReadResult — a value of this type
($&Buffer) write_resultpub fn (b $&Buffer) write_result(data string) WriteResultOperation on $&Buffer: write result.
b $&BufferBuffer instance used by this call (exclusive borrow).data stringWriteResult — a value of this type
($&Discard) write_resultpub fn (d $&Discard) write_result(data string) WriteResultOperation on $&Discard: write result.
d $&DiscardDiscard instance used by this call (exclusive borrow).data stringWriteResult — a value of this type
enum ReadIntopub enum ReadInto {
Filled(int)
End(int)
Failed(int, errors.Error)
}ReadInto reports how many bytes were stored in the caller's buffer. The destination is exclusively borrowed for the call and is never grown. The result owns only the count and error; it does not borrow the buffer. Bytes outside the written prefix stay unchanged. A zero count performs no I/O.
($&Cursor) read_intopub fn (c $&Cursor) read_into(dst $&[]int, off int, n int) ReadIntoOperation on $&Cursor: read into.
c $&CursorCursor instance used by this call (exclusive borrow).dst $&[]intoff intn intReadInto — a value of this type
($&Buffer) read_intopub fn (b $&Buffer) read_into(dst $&[]int, off int, n int) ReadIntoOperation on $&Buffer: read into.
b $&BufferBuffer instance used by this call (exclusive borrow).dst $&[]intoff intn intReadInto — a value of this type
read_intopub fn read_into#R:ProgressReader(src $&R, dst $&[]int, off int, n int) ReadIntoOne synchronous read_result, then a copy into the exclusive window. The temporary owned chunk dies before return. Invalid counts are not stored. This does not retry and does not replace Cursor/Buffer.read_into.
src $&Rdst $&[]intoff intn intReadInto — a value of this type
struct@ StreamReaderpub struct@ StreamReader {
fn read_n(int) string
}read_n(n>0) returns at most n bytes. Empty string or an error with message eof ends the stream; other errors propagate. Unlike Reader, this API cannot return bytes and an error in the same operation.
read_n fn read_n(int) stringStreamReader: read at most n bytes; may return shorter or empty at end.(StreamReader) read_nfn read_n(int) stringOperation on StreamReader: read at most n bytes; may return shorter or empty at end.
self SelfSelf instance used by this call (value receiver).int intstring — result string
struct@ StreamWriterpub struct@ StreamWriter {
fn write_str(string) int
}write_str consumes one owning chunk. It must accept the whole chunk or throw; returning a shorter count is a short write, never an invitation to replay a partially accepted chunk. The destination may retain data itself.
write_str fn write_str(string) intStreamWriter: write a string.(StreamWriter) write_strfn write_str(string) intOperation on StreamWriter: write a string.
self SelfSelf instance used by this call (value receiver).string stringint — a value of this type
copy_streampub fn copy_stream#W:StreamWriter,R:StreamReader(dst $&W, src $&R) intThe three public forms retain their independently tested copy contracts. Generic forwarding is supported; no additional whole-stream staging is used. Both endpoints are borrowed; their partial effects remain visible on errors. Throws on failure; handle the error or propagate it to the caller.
dst $&Wsrc $&Rint — a value of this type
copy_stream_bufferpub fn copy_stream_buffer#W:StreamWriter,R:StreamReader(dst $&W, src $&R, size int) intMaximum owning chunk size, with no whole-stream staging. Throws on failure; handle the error or propagate it to the caller.
dst $&Wsrc $&Rsize intint — a value of this type
copy_stream_npub fn copy_stream_n#W:StreamWriter,R:StreamReader(dst $&W, src $&R, n int) intExactly n bytes, with no over-read. n=0 touches neither endpoint. Throws on failure; handle the error or propagate it to the caller.
dst $&Wsrc $&Rn intint — a value of this type
($&Discard) write_strpub fn (d $&Discard) write_str(data string) intOperation on $&Discard: write a string.
d $&DiscardDiscard instance used by this call (exclusive borrow).data stringint — a value of this type