mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:37:36 +00:00
LibCore+Everywhere: Make Core::Stream::read() return Bytes
A mistake I've repeatedly made is along these lines: ```c++ auto nread = TRY(source_file->read(buffer)); TRY(destination_file->write(buffer)); ``` It's a little clunky to have to create a Bytes or StringView from the buffer's data pointer and the nread, and easy to forget and just use the buffer. So, this patch changes the read() function to return a Bytes of the data that were just read. The other read_foo() methods will be modified in the same way in subsequent commits. Fixes #13687
This commit is contained in:
parent
6654efcd82
commit
3b1e063d30
22 changed files with 103 additions and 103 deletions
|
@ -79,8 +79,8 @@ TEST_CASE(test_TLS_hello_handshake)
|
|||
auto tls = MUST(TLS::TLSv12::connect(DEFAULT_SERVER, port, move(options)));
|
||||
ByteBuffer contents;
|
||||
tls->on_ready_to_read = [&] {
|
||||
auto nread = MUST(tls->read(contents.must_get_bytes_for_writing(4 * KiB)));
|
||||
if (nread == 0) {
|
||||
auto read_bytes = MUST(tls->read(contents.must_get_bytes_for_writing(4 * KiB)));
|
||||
if (read_bytes.is_empty()) {
|
||||
FAIL("No data received");
|
||||
loop.quit(1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue