io/FileDescriptor: add Read()/Write() overloads with std::span

This commit is contained in:
Max Kellermann
2023-09-27 10:46:43 +02:00
committed by Max Kellermann
parent 5fbe5951ab
commit cad35a83fb
7 changed files with 14 additions and 7 deletions

View File

@@ -217,6 +217,10 @@ public:
}
#endif
ssize_t Read(std::span<std::byte> dest) const noexcept {
return ::read(fd, dest.data(), dest.size());
}
ssize_t Read(void *buffer, std::size_t length) const noexcept {
return ::read(fd, buffer, length);
}
@@ -227,6 +231,10 @@ public:
*/
void FullRead(std::span<std::byte> dest) const;
ssize_t Write(std::span<const std::byte> src) const noexcept {
return ::write(fd, src.data(), src.size());
}
ssize_t Write(const void *buffer, std::size_t length) const noexcept {
return ::write(fd, buffer, length);
}