28#include <seastar/core/align.hh>
29#include <seastar/core/internal/io_intent.hh>
30#include <seastar/core/temporary_buffer.hh>
35template <
typename CharType>
36struct file_read_state {
37 typedef temporary_buffer<CharType> tmp_buf_type;
39 file_read_state(uint64_t offset, uint64_t front,
size_t to_read,
40 size_t memory_alignment,
size_t disk_alignment, io_intent* intent)
41 : buf(tmp_buf_type::aligned(memory_alignment,
42 align_up(to_read, disk_alignment)))
49 return eof || pos >= _to_read;
59 void trim_buf_before_ret() {
60 if (have_good_bytes()) {
62 buf.trim_front(_front);
68 uint64_t cur_offset()
const {
72 size_t left_space()
const {
73 return buf.size() - pos;
76 size_t left_to_read()
const {
78 return _to_read - pos;
81 void append_new_data(tmp_buf_type& new_data) {
82 auto to_copy = std::min(left_space(), new_data.size());
84 std::memcpy(buf.get_write() + pos, new_data.get(), to_copy);
88 bool have_good_bytes()
const {
92 io_intent* get_intent() {
93 return _iref.retrieve();
104 internal::intent_reference _iref;
Seastar API namespace.
Definition: abort_on_ebadf.hh:26