Struct std::io::Chain 1.0.0[−][src]
pub struct Chain<T, U> { /* fields omitted */ }
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(())
}
RunTrait Implementations
与 read
相似,不同之处在于它读入缓冲区的一部分。 Read more
读取所有字节,直到此源中的 EOF 为止,然后将它们放入 buf
。 Read more
读取这个源中的所有字节,直到 EOF 为止,然后将它们追加到 buf
。 Read more
为这个 Read
实例创建一个 “by reference” 适配器。 Read more
创建一个适配器,将这个流与另一个链接起来。 Read more