io/FileDescriptor: add Read()/Write() overloads with std::span
This commit is contained in:

committed by
Max Kellermann

parent
5fbe5951ab
commit
cad35a83fb
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user