This will be rather inefficient, as it goes through the repeated position checks and translation in both the memory segment and the byte buffer. This should really be one bulk copy. We need to add respective methods to MemorySegment, if we keep this method.