MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / test_splice_cursor

Function test_splice_cursor

tests/pipe/splice.rs:4–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2#[cfg(linux_kernel)]
3#[test]
4fn test_splice_cursor() {
5 use rustix::pipe::{pipe, splice, SpliceFlags};
6 use std::io::{Read as _, Seek as _, SeekFrom, Write as _};
7
8 let mut src = tempfile::tempfile().unwrap();
9 let mut dest = tempfile::tempfile().unwrap();
10 let (read_p, write_p) = pipe().unwrap();
11 let mut buff = vec![];
12
13 writeln!(src, "hello world").unwrap();
14
15 src.seek(SeekFrom::Start(6)).unwrap();
16
17 splice(&src, None, &write_p, None, 5, SpliceFlags::empty()).unwrap();
18 splice(&read_p, None, &dest, None, 5, SpliceFlags::empty()).unwrap();
19
20 dest.rewind().unwrap();
21
22 dest.read_to_end(&mut buff).unwrap();
23 assert_eq!(buff, b"world");
24}
25
26#[cfg(feature = "fs")]
27#[cfg(linux_kernel)]

Callers

nothing calls this directly

Calls 4

pipeFunction · 0.50
spliceFunction · 0.50
seekMethod · 0.45
rewindMethod · 0.45

Tested by

no test coverage detected