API
#bufio/file
Xu 0.8.8 API
import: #bufio/file
counts: 4 函数, 4 方法, 2 类型, 0 常量, 0 方法集
标准库包 `#bufio/file`。
struct FileReader
pub struct FileReader {
pub src os.File
pub buf string
pub r int
pub err string
pub size int
pub last_byte int
}
用途
公开结构体 `FileReader`。
参数
src os.File- 源数据
buf string- 缓冲
r int- rune(Unicode 码点)
err string- 错误
size int- 字段(int)
last_byte int- 字段(int)
struct FileWriter
pub struct FileWriter {
pub dst os.File
pub buf string
pub size int
pub err string
}
用途
公开结构体 `FileWriter`。
参数
dst os.File- 目标
buf string- 缓冲
size int- 字段(int)
err string- 错误
new_reader
pub fn new_reader(src os.File) FileReader
用途
构造 reader。
参数
src os.File- 源数据(os.File)
返回
FileReader — 该类型的值
new_reader_size
pub fn new_reader_size(src os.File, size int) FileReader
用途
构造 reader size。
参数
src os.File- 源数据(os.File)
size int- size(int)
返回
FileReader — 该类型的值
new_writer
pub fn new_writer(dst os.File) FileWriter
用途
构造 writer。
参数
dst os.File- 目标(os.File)
返回
FileWriter — 该类型的值
new_writer_size
pub fn new_writer_size(dst os.File, size int) FileWriter
用途
构造 writer size。
参数
dst os.File- 目标(os.File)
size int- size(int)
返回
FileWriter — 该类型的值
(&mut FileReader) read_byte
pub fn (r &mut FileReader) read_byte() int
用途
`&mut FileReader` 上的方法:读一个字节;失败时 throw。
参数
r &mut FileReader- 接收者 &mut FileReader(可变借用)
返回
int — 该类型的值
(&mut FileReader) read_string
pub fn (r &mut FileReader) read_string(delim int) string
用途
`&mut FileReader` 上的方法:读取字符串。失败时 throw。
参数
r &mut FileReader- 接收者 &mut FileReader(可变借用)
delim int- delim(int)
返回
string — 结果字符串
(&mut FileWriter) write
pub fn (w &mut FileWriter) write(data string) int
用途
`&mut FileWriter` 上的方法:写入数据,返回写入的字节数。失败时 throw。
参数
w &mut FileWriter- 接收者 &mut FileWriter(可变借用)
data string- 数据(string)
返回
int — 写入的字节数
(&mut FileWriter) flush
pub fn (w &mut FileWriter) flush() int
用途
`&mut FileWriter` 上的方法:刷出缓冲。失败时 throw。
参数
w &mut FileWriter- 接收者 &mut FileWriter(可变借用)
返回
int — 该类型的值