struct@ Writer
struct@ Writer {
fn write(&string) int
}用途
方法集约束 `Writer`。实现类型须提供下列方法。不是接口值。
参数
writefn write(&string) int- `Writer` 上的方法:写入数据,返回写入的字节数。
API
#ioBuffer / Cursor、流复制、带数据的 EOF/错误结果与写入进度契约;另有 multi/tee/section/pipe。
struct@ Writerstruct@ Writer {
fn write(&string) int
}方法集约束 `Writer`。实现类型须提供下列方法。不是接口值。
write fn write(&string) int(Writer) writefn write(&string) int`Writer` 上的方法:写入数据,返回写入的字节数。
self Selfstring &stringint — 写入的字节数
struct@ Readerstruct@ Reader {
fn read_n(int) string
}方法集约束 `Reader`。实现类型须提供下列方法。不是接口值。
read_n fn read_n(int) string(Reader) read_nfn read_n(int) string`Reader` 上的方法:最多读 n 字节;到末尾可返回更短或空串。
self Selfint intstring — 结果字符串
struct Bufferpub struct Buffer {
pub data string
pub off int
}公开结构体 `Buffer`。
data stringoff intstruct Cursorpub struct Cursor {
pub data string
pub off int
}公开结构体 `Cursor`。
data stringoff intbufferpub fn buffer() Buffer缓冲。
无
Buffer — 该类型的值
buffer_frompub fn buffer_from(s string) Buffer缓冲从。
s stringBuffer — 该类型的值
cursorpub fn cursor(s string) Cursor游标。
s stringCursor — 该类型的值
(&mut Cursor) resetpub fn (c &mut Cursor) reset(s string)`&mut Cursor` 上的方法:清空内部状态,可再写入或读取。
c &mut Cursors string(&mut Buffer) resetpub fn (b &mut Buffer) reset()`&mut Buffer` 上的方法:清空内部状态,可再写入或读取。
b &mut Buffer(&Buffer) lenpub fn (b &Buffer) len() int`&Buffer` 上的方法:返回长度。
b &Bufferint — 该类型的值
(&Buffer) cappub fn (b &Buffer) cap() int`&Buffer` 上的方法:返回容量。
b &Bufferint — 该类型的值
(&Cursor) sizepub fn (c &Cursor) size() int`&Cursor` 上的方法:返回尺寸。
c &Cursorint — 该类型的值
(&mut Buffer) writepub fn (b &mut Buffer) write(data &string) int`&mut Buffer` 上的方法:写入数据,返回写入的字节数。
b &mut Bufferdata &stringint — 写入的字节数
(&mut Buffer) write_strpub fn (b &mut Buffer) write_str(s string) int`&mut Buffer` 上的方法:写入字符串。
b &mut Buffers stringint — 该类型的值
(&mut Buffer) write_bytepub fn (b &mut Buffer) write_byte(c int) int`&mut Buffer` 上的方法:写入一个字节。
b &mut Bufferc intint — 写入的字节数
(&mut Buffer) read_npub fn (b &mut Buffer) read_n(n int) string`&mut Buffer` 上的方法:最多读 n 字节;到末尾可返回更短或空串。
b &mut Buffern intstring — 结果字符串
(&Buffer) bytespub fn (b &Buffer) bytes() string`&Buffer` 上的方法:返回已缓冲的字节串。
b &Bufferstring — 结果字符串
(&mut Cursor) read_npub fn (c &mut Cursor) read_n(n int) string`&mut Cursor` 上的方法:最多读 n 字节;到末尾可返回更短或空串。
c &mut Cursorn intstring — 结果字符串
copypub fn copy(dst Buffer, src Cursor) string拷贝。
dst Buffersrc Cursorstring — 结果字符串
copy_topub fn copy_to(dst Buffer, src Cursor) Buffer拷贝到。
dst Buffersrc CursorBuffer — 该类型的值
read_allpub fn read_all(src Cursor) string读取all。
src Cursorstring — 结果字符串
const eofpub const eof = "EOF"公开常量 `eof`。 值为 `"EOF"`
无
(&Cursor) remainingpub fn (c &Cursor) remaining() int在 `&Cursor` 上调用 `remaining`。
c &Cursorint — 该类型的值
(&mut Cursor) seekpub fn (c &mut Cursor) seek(offset int, whence int) int`&mut Cursor` 上的方法:按 whence 把读位置移到 offset。whence 0/1/2 分别为绝对、相对、从末尾。失败时 throw。
c &mut Cursoroffset intwhence intint — 该类型的值
(&Cursor) read_atpub fn (c &Cursor) read_at(n int, off int) string`&Cursor` 上的方法:从偏移 off 起最多读 n 字节。失败时 throw。
c &Cursorn intoff intstring — 结果字符串
read_fullpub fn read_full(src Cursor, n int) string读取full。
src Cursorn intstring — 结果字符串
read_at_leastpub fn read_at_least(src Cursor, min int, max int) string读取atleast。失败时 throw。
src Cursormin intmax intstring — 结果字符串
copy_npub fn copy_n(dst Buffer, src Cursor, n int) string拷贝n。失败时 throw。
dst Buffersrc Cursorn intstring — 结果字符串
struct LimitCursorpub struct LimitCursor {
pub src Cursor
pub n int
}公开结构体 `LimitCursor`。
src Cursorn intlimit_cursorpub fn limit_cursor(src Cursor, n int) LimitCursorlimit游标。
src Cursorn intLimitCursor — 该类型的值
(LimitCursor) remainingpub fn (l LimitCursor) remaining() int在 `LimitCursor` 上调用 `remaining`。
l LimitCursorint — 该类型的值
(&mut LimitCursor) read_npub fn (l &mut LimitCursor) read_n(n int) string`&mut LimitCursor` 上的方法:最多读 n 字节;到末尾可返回更短或空串。
l &mut LimitCursorn intstring — 结果字符串
struct Discardpub struct Discard {
pub n int
}公开结构体 `Discard`。
n intdiscardpub fn discard() Discard丢弃。
无
Discard — 该类型的值
(&mut Discard) writepub fn (d &mut Discard) write(data &string) int`&mut Discard` 上的方法:写入数据,返回写入的字节数。
d &mut Discarddata &stringint — 写入的字节数
(Discard) writtenpub fn (d Discard) written() int在 `Discard` 上调用 `written`。
d Discardint — 该类型的值
struct MultiCursorpub struct MultiCursor {
pub chunks []string
pub i int
pub off int
}公开结构体 `MultiCursor`。
chunks []stringi intoff intmulti_cursorpub fn multi_cursor(parts <-> string) MultiCursormulti游标。
parts <-> stringMultiCursor — 该类型的值
(&mut MultiCursor) read_npub fn (m &mut MultiCursor) read_n(n int) string`&mut MultiCursor` 上的方法:最多读 n 字节;到末尾可返回更短或空串。
m &mut MultiCursorn intstring — 结果字符串
struct MultiBufferpub struct MultiBuffer {
pub parts []string
}公开结构体 `MultiBuffer`。
parts []stringmulti_bufferpub fn multi_buffer(n int) MultiBuffermulti缓冲。
n intMultiBuffer — 该类型的值
(&mut MultiBuffer) writepub fn (m &mut MultiBuffer) write(data &string) int`&mut MultiBuffer` 上的方法:写入数据,返回写入的字节数。
m &mut MultiBufferdata &stringint — 写入的字节数
(&MultiBuffer) textpub fn (m &MultiBuffer) text(i int) string`&MultiBuffer` 上的方法:返回当前文本。
m &MultiBufferi intstring — 结果字符串
struct Teepub struct Tee {
pub src Cursor
pub dst Buffer
}公开结构体 `Tee`。
src Cursordst Bufferteepub fn tee(src Cursor, dst Buffer) Teetee,返回 Tee。
src Cursordst BufferTee — 该类型的值
(&mut Tee) read_npub fn (t &mut Tee) read_n(n int) string`&mut Tee` 上的方法:最多读 n 字节;到末尾可返回更短或空串。
t &mut Teen intstring — 结果字符串
(&Tee) copiedpub fn (t &Tee) copied() string在 `&Tee` 上调用 `copied`。
t &Teestring — 结果字符串
struct SectionCursorpub struct SectionCursor {
pub data string
pub base int
pub limit int
pub off int
}公开结构体 `SectionCursor`。
data stringbase intlimit intoff intsection_cursorpub fn section_cursor(s string, off int, n int) SectionCursorsection游标。
s stringoff intn intSectionCursor — 该类型的值
(&mut SectionCursor) read_npub fn (s &mut SectionCursor) read_n(n int) string`&mut SectionCursor` 上的方法:最多读 n 字节;到末尾可返回更短或空串。
s &mut SectionCursorn intstring — 结果字符串
(&SectionCursor) sizepub fn (s &SectionCursor) size() int`&SectionCursor` 上的方法:返回尺寸。
s &SectionCursorint — 该类型的值
(&mut SectionCursor) seekpub fn (s &mut SectionCursor) seek(offset int, whence int) int`&mut SectionCursor` 上的方法:按 whence 把读位置移到 offset。whence 0/1/2 分别为绝对、相对、从末尾。失败时 throw。
s &mut SectionCursoroffset intwhence intint — 该类型的值
(&SectionCursor) read_atpub fn (s &SectionCursor) read_at(n int, off int) string`&SectionCursor` 上的方法:从偏移 off 起最多读 n 字节。失败时 throw。
s &SectionCursorn intoff intstring — 结果字符串
struct PipeReaderpub struct PipeReader {
pub r chan string
pub buf string
pub off int
}公开结构体 `PipeReader`。
r chan stringbuf stringoff intstruct PipeWriterpub struct PipeWriter {
pub w chan string
pub closed int
}公开结构体 `PipeWriter`。
w chan stringclosed intstruct Pipepub struct Pipe {
pub r PipeReader
pub w PipeWriter
}公开结构体 `Pipe`。
r PipeReaderw PipeWriterpipepub fn pipe() Pipepipe,返回 Pipe。
无
Pipe — 该类型的值
(&mut PipeReader) read_npub fn (p &mut PipeReader) read_n(n int) string`&mut PipeReader` 上的方法:最多读 n 字节;到末尾可返回更短或空串。
p &mut PipeReadern intstring — 结果字符串
(PipeWriter) writepub fn (w PipeWriter) write(data &string) int`PipeWriter` 上的方法:写入数据,返回写入的字节数。失败时 throw。
w PipeWriterdata &stringint — 写入的字节数
(&mut PipeWriter) closepub fn (w &mut PipeWriter) close() int`&mut PipeWriter` 上的方法:关闭资源。
w &mut PipeWriterint — 该类型的值
enum ReadResultpub enum ReadResult {
Data(string)
End(string)
Failed(string, errors.Error)
}公开枚举 `ReadResult`;变体与载荷见声明。
无
enum WriteResultpub enum WriteResult {
Written(int)
Failed(int, errors.Error)
Unknown(errors.Error)
}公开枚举 `WriteResult`;变体与载荷见声明。
无
enum CopyResultpub enum CopyResult {
Copied(int)
Failed(int, errors.Error)
Uncertain(int, errors.Error)
}公开枚举 `CopyResult`;变体与载荷见声明。
无
struct@ ProgressReaderpub struct@ ProgressReader {
fn read_result(int) ReadResult
}方法集约束 `ProgressReader`。实现类型须提供下列方法。不是接口值。
read_result fn read_result(int) ReadResult(ProgressReader) read_resultfn read_result(int) ReadResult`ProgressReader` 上的方法:读取结果。
self Selfint intReadResult — 该类型的值
struct@ ProgressWriterpub struct@ ProgressWriter {
fn write_result(string) WriteResult
}方法集约束 `ProgressWriter`。实现类型须提供下列方法。不是接口值。
write_result fn write_result(string) WriteResult(ProgressWriter) write_resultfn write_result(string) WriteResult`ProgressWriter` 上的方法:写入结果。
self Selfstring stringWriteResult — 该类型的值
struct LegacyReader#R:StreamReaderpub struct LegacyReader#R:StreamReader {
pub src R
}公开结构体 `LegacyReader#R:StreamReader`。
src Rstruct LegacyWriter#W:StreamWriterpub struct LegacyWriter#W:StreamWriter {
pub dst W
}公开结构体 `LegacyWriter#W:StreamWriter`。
dst Wprogress_readerpub fn progress_reader#R:StreamReader(src R) LegacyReader#Rprogress读取器。
src RLegacyReader#R — 该类型的值
progress_writerpub fn progress_writer#W:StreamWriter(dst W) LegacyWriter#Wprogress写入器。
dst WLegacyWriter#W — 该类型的值
(&mut LegacyReader#R) read_resultpub fn (r &mut LegacyReader#R) read_result(n int) ReadResult`&mut LegacyReader#R` 上的方法:读取结果。
r &mut LegacyReader#Rn intReadResult — 该类型的值
(&mut LegacyWriter#W) write_resultpub fn (w &mut LegacyWriter#W) write_result(data string) WriteResult`&mut LegacyWriter#W` 上的方法:写入结果。
w &mut LegacyWriter#Wdata stringWriteResult — 该类型的值
copy_resultpub fn copy_result#W:ProgressWriter,R:ProgressReader(dst &mut W, src &mut R) CopyResult拷贝结果。
dst &mut Wsrc &mut RCopyResult — 该类型的值
copy_result_bufferpub fn copy_result_buffer#W:ProgressWriter,R:ProgressReader(dst &mut W, src &mut R, size int) CopyResult拷贝结果缓冲。
dst &mut Wsrc &mut Rsize intCopyResult — 该类型的值
copy_result_npub fn copy_result_n#W:ProgressWriter,R:ProgressReader(dst &mut W, src &mut R, n int) CopyResult拷贝结果n。
dst &mut Wsrc &mut Rn intCopyResult — 该类型的值
(&mut Cursor) read_resultpub fn (c &mut Cursor) read_result(n int) ReadResult`&mut Cursor` 上的方法:读取结果。
c &mut Cursorn intReadResult — 该类型的值
(&mut Buffer) read_resultpub fn (b &mut Buffer) read_result(n int) ReadResult`&mut Buffer` 上的方法:读取结果。
b &mut Buffern intReadResult — 该类型的值
(&mut Buffer) write_resultpub fn (b &mut Buffer) write_result(data string) WriteResult`&mut Buffer` 上的方法:写入结果。
b &mut Bufferdata stringWriteResult — 该类型的值
(&mut Discard) write_resultpub fn (d &mut Discard) write_result(data string) WriteResult`&mut Discard` 上的方法:写入结果。
d &mut Discarddata stringWriteResult — 该类型的值
enum ReadIntopub enum ReadInto {
Filled(int)
End(int)
Failed(int, errors.Error)
}公开枚举 `ReadInto`;变体与载荷见声明。
无
(&mut Cursor) read_intopub fn (c &mut Cursor) read_into(dst &mut []int, off int, n int) ReadInto`&mut Cursor` 上的方法:读取into。
c &mut Cursordst &mut []intoff intn intReadInto — 该类型的值
(&mut Buffer) read_intopub fn (b &mut Buffer) read_into(dst &mut []int, off int, n int) ReadInto`&mut Buffer` 上的方法:读取into。
b &mut Bufferdst &mut []intoff intn intReadInto — 该类型的值
read_intopub fn read_into#R:ProgressReader(src &mut R, dst &mut []int, off int, n int) ReadInto读取into。
src &mut Rdst &mut []intoff intn intReadInto — 该类型的值
struct@ StreamReaderpub struct@ StreamReader {
fn read_n(int) string
}方法集约束 `StreamReader`。实现类型须提供下列方法。不是接口值。
read_n fn read_n(int) string(StreamReader) read_nfn read_n(int) string`StreamReader` 上的方法:最多读 n 字节;到末尾可返回更短或空串。
self Selfint intstring — 结果字符串
struct@ StreamWriterpub struct@ StreamWriter {
fn write_str(string) int
}方法集约束 `StreamWriter`。实现类型须提供下列方法。不是接口值。
write_str fn write_str(string) int(StreamWriter) write_strfn write_str(string) int`StreamWriter` 上的方法:写入字符串。
self Selfstring stringint — 该类型的值
copy_streampub fn copy_stream#W:StreamWriter,R:StreamReader(dst &mut W, src &mut R) int拷贝流。失败时 throw。
dst &mut Wsrc &mut Rint — 该类型的值
copy_stream_bufferpub fn copy_stream_buffer#W:StreamWriter,R:StreamReader(dst &mut W, src &mut R, size int) int拷贝流缓冲。失败时 throw。
dst &mut Wsrc &mut Rsize intint — 该类型的值
copy_stream_npub fn copy_stream_n#W:StreamWriter,R:StreamReader(dst &mut W, src &mut R, n int) int拷贝流n。失败时 throw。
dst &mut Wsrc &mut Rn intint — 该类型的值
(&mut Discard) write_strpub fn (d &mut Discard) write_str(data string) int`&mut Discard` 上的方法:写入字符串。
d &mut Discarddata stringint — 该类型的值