Struct std::io::Chain1.0.0[][src]

pub struct Chain<T, U> { /* fields omitted */ }
Expand description

将两个 readers 链接在一起的适配器。

通常通过在 reader 上调用 chain 来创建此结构体。 请参见 chain 的文档以获取更多详细信息。

Implementations

消耗 Chain,返回包装的 readers。

Examples

use std::io;
use std::io::prelude::*;
use std::fs::File;

fn main() -> io::Result<()> {
    let mut foo_file = File::open("foo.txt")?;
    let mut bar_file = File::open("bar.txt")?;

    let chain = foo_file.chain(bar_file);
    let (foo_file, bar_file) = chain.into_inner();
    Ok(())
}
Run

在此 Chain 中获得对基础 readers 的引用。

Examples

use std::io;
use std::io::prelude::*;
use std::fs::File;

fn main() -> io::Result<()> {
    let mut foo_file = File::open("foo.txt")?;
    let mut bar_file = File::open("bar.txt")?;

    let chain = foo_file.chain(bar_file);
    let (foo_file, bar_file) = chain.get_ref();
    Ok(())
}
Run

获取此 Chain 中基础 readers 的可变引用。

应注意避免修改基础 readers 的内部 I/O 状态,因为这样做可能会破坏该 Chain 的内部状态。

Examples

use std::io;
use std::io::prelude::*;
use std::fs::File;

fn main() -> io::Result<()> {
    let mut foo_file = File::open("foo.txt")?;
    let mut bar_file = File::open("bar.txt")?;

    let mut chain = foo_file.chain(bar_file);
    let (foo_file, bar_file) = chain.get_mut();
    Ok(())
}
Run

Trait Implementations

返回内部缓冲区的内容,如果内部缓冲区为空,则使用内部 reader 中的更多数据填充内部缓冲区。 Read more

告诉此缓冲区 amt 字节已从缓冲区中消耗掉,因此在调用 read 时不再应返回它们。 Read more

🔬 This is a nightly-only experimental API. (buf_read_has_data_left #86423)

recently added

检查底层 Read 是否有任何数据可供读取。 Read more

将所有字节读入 buf,直到到达定界符 byte 或 EOF。 Read more

读取所有字节,直到到达换行符 (0xA 字节),然后将它们附加到提供的缓冲区中。 Read more

返回对该字节 byte 上的 reader 拆分内容的迭代器。 Read more

返回此 reader 的各行上的迭代器。 Read more

使用给定的格式化程序格式化该值。 Read more

从该源中提取一些字节到指定的缓冲区中,返回读取的字节数。 Read more

read 相似,不同之处在于它读入缓冲区的一部分。 Read more

🔬 This is a nightly-only experimental API. (read_initializer #42788)

确定该 Reader 是否可以与未初始化内存的缓冲区一起使用。 Read more

🔬 This is a nightly-only experimental API. (can_vector #69941)

确定此 Read 是否具有有效的 read_vectored 实现。 Read more

读取所有字节,直到此源中的 EOF 为止,然后将它们放入 bufRead more

读取所有字节,直到该源中的 EOF 为止,然后将它们附加到 bufRead more

读取填充 buf 所需的确切字节数。 Read more

为此 Read 实例创建 “by reference” 适配器。 Read more

将此 Read 实例的字节数转换为 IteratorRead more

创建一个适配器,它将将此流与另一个流链接。 Read more

创建一个适配器,该适配器最多可以从中读取 limit 字节。 Read more

Auto Trait Implementations

Blanket Implementations

获取 selfTypeIdRead more

从拥有的值中一成不变地借用。 Read more

从拥有的值中借用。 Read more

执行转换。

执行转换。

发生转换错误时返回的类型。

执行转换。

发生转换错误时返回的类型。

执行转换。