XU XUv0.8.8
EN

API

#encoding/csv

import: #encoding/csv

counts: 3 函数, 13 方法, 2 类型, 0 常量, 0 方法集

RFC4180 Reader/Writer,源为 owning 字符串。

struct Reader

XuAPI
pub struct Reader {
    pub data string
    pub pos int
    pub comma int
    pub comment int
    pub lazy_quotes bool
    pub sticky string
    pub fields_per_record int
    pub trim_leading_space bool
    pub learned int
}

用途

公开结构体 `Reader`。

参数

data string
数据
pos int
字段(int)
comma int
字段(int)
comment int
字段(int)
lazy_quotes bool
字段(bool)
sticky string
字段(string)
fields_per_record int
字段(int)
trim_leading_space bool
字段(bool)
learned int
字段(int)

struct Writer

XuAPI
pub struct Writer {
    pub buf string
    pub comma int
    pub need_nl bool
    pub use_crlf bool
}

用途

公开结构体 `Writer`。

参数

buf string
缓冲
comma int
字段(int)
need_nl bool
字段(bool)
use_crlf bool
字段(bool)

new_reader

XuAPI
pub fn new_reader(data string) Reader

用途

构造 reader。

参数

data string
数据(string)

返回

Reader — 该类型的值

new_writer

XuAPI
pub fn new_writer() Writer

用途

构造 writer。

参数

无

返回

Writer — 该类型的值

host_crlf

XuAPI
pub fn host_crlf() bool

用途

主机crlf。

参数

无

返回

bool — 是否成立

(&mut Reader) set_comma

XuAPI
pub fn (r &mut Reader) set_comma(c int)

用途

`&mut Reader` 上的方法:设置 comma。

参数

r &mut Reader
接收者 &mut Reader(可变借用)
c int
字节或字符码(int)

(&mut Reader) set_comment

XuAPI
pub fn (r &mut Reader) set_comment(c int)

用途

`&mut Reader` 上的方法:设置 comment。

参数

r &mut Reader
接收者 &mut Reader(可变借用)
c int
字节或字符码(int)

(&mut Writer) set_comma

XuAPI
pub fn (w &mut Writer) set_comma(c int)

用途

`&mut Writer` 上的方法:设置 comma。

参数

w &mut Writer
接收者 &mut Writer(可变借用)
c int
字节或字符码(int)

(&mut Writer) set_use_crlf

XuAPI
pub fn (w &mut Writer) set_use_crlf(on bool)

用途

`&mut Writer` 上的方法:设置 use crlf。

参数

w &mut Writer
接收者 &mut Writer(可变借用)
on bool
on(bool)

(&mut Reader) set_lazy_quotes

XuAPI
pub fn (r &mut Reader) set_lazy_quotes(on bool)

用途

`&mut Reader` 上的方法:设置 lazy quotes。

参数

r &mut Reader
接收者 &mut Reader(可变借用)
on bool
on(bool)

(&mut Reader) set_trim_leading_space

XuAPI
pub fn (r &mut Reader) set_trim_leading_space(on bool)

用途

`&mut Reader` 上的方法:设置 trim leading space。

参数

r &mut Reader
接收者 &mut Reader(可变借用)
on bool
on(bool)

(&mut Reader) set_fields_per_record

XuAPI
pub fn (r &mut Reader) set_fields_per_record(n int)

用途

`&mut Reader` 上的方法:设置 fields per record。

参数

r &mut Reader
接收者 &mut Reader(可变借用)
n int
数量、长度或上限(int)

(&mut Reader) read

XuAPI
pub fn (r &mut Reader) read() []string

用途

`&mut Reader` 上的方法:读出最多 max 字节。失败时 throw。

参数

r &mut Reader
接收者 &mut Reader(可变借用)

返回

[]string — 切片结果

(&mut Reader) read_all

XuAPI
pub fn (r &mut Reader) read_all() [][]string

用途

`&mut Reader` 上的方法:读取all。失败时 throw。

参数

r &mut Reader
接收者 &mut Reader(可变借用)

返回

[][]string — 切片结果

(&mut Writer) write

XuAPI
pub fn (w &mut Writer) write(record &[]string) int

用途

`&mut Writer` 上的方法:写入数据,返回写入的字节数。

参数

w &mut Writer
接收者 &mut Writer(可变借用)
record &[]string
record(借用,调用方仍持有;类型 &[]string)

返回

int — 写入的字节数

(&mut Writer) write_all

XuAPI
pub fn (w &mut Writer) write_all(records &[][]string) int

用途

`&mut Writer` 上的方法:写入all。

参数

w &mut Writer
接收者 &mut Writer(可变借用)
records &[][]string
records(借用,调用方仍持有;类型 &[][]string)

返回

int — 该类型的值

(&Writer) text

XuAPI
pub fn (w &Writer) text() string

用途

`&Writer` 上的方法:返回当前文本。

参数

w &Writer
接收者 &Writer(借用)

返回

string — 结果字符串

(&mut Writer) flush

XuAPI
pub fn (w &mut Writer) flush()

用途

`&mut Writer` 上的方法:刷出缓冲。

参数

w &mut Writer
接收者 &mut Writer(可变借用)