| 99 | #[cfg(feature = "fs")] |
| 100 | #[test] |
| 101 | fn test_readwrite_v() { |
| 102 | use rustix::fs::{openat, seek, Mode, OFlags, SeekFrom, CWD}; |
| 103 | use rustix::io::{readv, writev}; |
| 104 | |
| 105 | let tmp = tempfile::tempdir().unwrap(); |
| 106 | let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); |
| 107 | let file = openat( |
| 108 | &dir, |
| 109 | "file", |
| 110 | OFlags::RDWR | OFlags::CREATE | OFlags::TRUNC, |
| 111 | Mode::RUSR | Mode::WUSR, |
| 112 | ) |
| 113 | .unwrap(); |
| 114 | |
| 115 | writev(&file, &[IoSlice::new(b"hello")]).unwrap(); |
| 116 | writev(&file, &[IoSlice::new(b"world")]).unwrap(); |
| 117 | seek(&file, SeekFrom::Start(0)).unwrap(); |
| 118 | let mut buf = [0_u8; 5]; |
| 119 | readv(&file, &mut [IoSliceMut::new(&mut buf)]).unwrap(); |
| 120 | assert_eq!(&buf, b"hello"); |
| 121 | readv(&file, &mut [IoSliceMut::new(&mut buf)]).unwrap(); |
| 122 | assert_eq!(&buf, b"world"); |
| 123 | } |
| 124 | |
| 125 | #[cfg(feature = "fs")] |
| 126 | #[test] |