MCPcopy Create free account
hub / github.com/bytecodealliance/system-interface / file_is_read_write

Function file_is_read_write

tests/read_ready.rs:9–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8#[test]
9fn file_is_read_write() {
10 let mut f = File::open("Cargo.toml").unwrap();
11
12 let len = f.metadata().unwrap().len();
13 assert_eq!(f.num_ready_bytes().unwrap(), len);
14
15 let mut buf = [0u8; 6];
16 f.read_exact(&mut buf).unwrap();
17 assert_eq!(f.num_ready_bytes().unwrap(), len - (buf.len() as u64));
18
19 #[cfg(target_os = "linux")]
20 {
21 let f = File::open("/dev/urandom").unwrap();
22 let _ = f.num_ready_bytes().unwrap();
23
24 let f = File::open("/dev/null").unwrap();
25 let _ = f.num_ready_bytes().unwrap();
26 }
27}

Callers

nothing calls this directly

Calls 2

read_exactMethod · 0.80
num_ready_bytesMethod · 0.80

Tested by

no test coverage detected