From: "ioquatix (Samuel Williams)" Date: 2022-10-15T00:35:02+00:00 Subject: [ruby-core:110297] [Ruby master Feature#15560] Add support for read/write offsets. Issue #15560 has been updated by ioquatix (Samuel Williams). I've added this to the `IO::Buffer` interface which is good enough for my requirements. ```ruby buffer = IO::Buffer.new buffer.read(io, length, offset) buffer.write(io, length, offset) ``` If we want to introduce the same model to `IO.read(length, [buffer, [offset]])` and `IO.write(length, [buffer, [offset]])` that would be reasonable. ---------------------------------------- Feature #15560: Add support for read/write offsets. https://bugs.ruby-lang.org/issues/15560#change-99583 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal ---------------------------------------- It would be nice if read/write/send/recv/etc methods could accept an offset argument. e.g. ``` socket = Socket.new(...) buffer = String.b socket.read(1024, buffer) socket.read(1024, buffer, offset: buffer.bytesize) ``` The same for write, e.g. ``` socket = Socket.new(...) buffer = String.b amount = socket.write(buffer) socket.write(buffer, offset: amount) ``` Could also include "size:" so that we can selectively write parts of the buffer. -- https://bugs.ruby-lang.org/ Unsubscribe: