XU XUv0.8.8
EN

API

#net/stream

import: #net/stream

counts: 1 函数, 10 方法, 1 类型, 0 常量, 0 方法集

标准库包 `#net/stream`。

struct Stream

XuAPI
pub struct Stream {
    pub c net.Conn
}

用途

公开结构体 `Stream`。

参数

c net.Conn
字节或字符码

from_tcp

XuAPI
pub fn from_tcp(c net.Conn) Stream

用途

从 tcp 构造。

参数

c net.Conn
字节或字符码(net.Conn)

返回

Stream — 该类型的值

(&Stream) fd

XuAPI
pub fn (s &Stream) fd() int

用途

在 `&Stream` 上调用 `fd`。失败时 throw。

参数

s &Stream
接收者 &Stream(借用)

返回

int — 该类型的值

(Stream) remote_addr

XuAPI
pub fn (s Stream) remote_addr() string

用途

`Stream` 上的方法:remote地址。

参数

s Stream
接收者 Stream(值接收者)

返回

string — 结果字符串

(&mut Stream) read

XuAPI
pub fn (s &mut Stream) read(max int) string

用途

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

参数

s &mut Stream
接收者 &mut Stream(可变借用)
max int
上限(int)

返回

string — 结果字符串

(&mut Stream) write

XuAPI
pub fn (s &mut Stream) write(data &string) int

用途

`&mut Stream` 上的方法:写入数据,返回写入的字节数。失败时 throw。

参数

s &mut Stream
接收者 &mut Stream(可变借用)
data &string
数据(借用,调用方仍持有;类型 &string)

返回

int — 写入的字节数

(&mut Stream) set_read_deadline

XuAPI
pub fn (s &mut Stream) set_read_deadline(t_ns int) int

用途

`&mut Stream` 上的方法:设置 read deadline。

参数

s &mut Stream
接收者 &mut Stream(可变借用)
t_ns int
t_ns(int)

返回

int — 该类型的值

(&mut Stream) set_write_deadline

XuAPI
pub fn (s &mut Stream) set_write_deadline(t_ns int) int

用途

`&mut Stream` 上的方法:设置 write deadline。

参数

s &mut Stream
接收者 &mut Stream(可变借用)
t_ns int
t_ns(int)

返回

int — 该类型的值

(&mut Stream) set_deadline

XuAPI
pub fn (s &mut Stream) set_deadline(t_ns int) int

用途

`&mut Stream` 上的方法:设置 deadline。

参数

s &mut Stream
接收者 &mut Stream(可变借用)
t_ns int
t_ns(int)

返回

int — 该类型的值

(&mut Stream) close

XuAPI
pub fn (s &mut Stream) close() int

用途

`&mut Stream` 上的方法:关闭资源。失败时 throw。

参数

s &mut Stream
接收者 &mut Stream(可变借用)

返回

int — 该类型的值

(&mut Stream) read_result

XuAPI
pub fn (s &mut Stream) read_result(n int) io.ReadResult

用途

`&mut Stream` 上的方法:读取结果。

参数

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

返回

io.ReadResult — 该类型的值

(&mut Stream) write_result

XuAPI
pub fn (s &mut Stream) write_result(data string) io.WriteResult

用途

`&mut Stream` 上的方法:写入结果。

参数

s &mut Stream
接收者 &mut Stream(可变借用)
data string
数据(string)

返回

io.WriteResult — 该类型的值