diff options
author | Claudius Holeksa <mail@keldu.de> | 2023-05-03 20:34:02 +0200 |
---|---|---|
committer | Claudius Holeksa <mail@keldu.de> | 2023-05-03 20:34:02 +0200 |
commit | 2aa2af0007b7e969845642027c635cd3fd9c8aea (patch) | |
tree | e72a05a3c2bfe58442b160c0c8e98ce1d095f36f /src/io/io_helpers.h | |
parent | 9b81a2585142260f89d47cbe1e592cec9e1f778f (diff) |
Moved dirs and added codec-json dir
Diffstat (limited to 'src/io/io_helpers.h')
-rw-r--r-- | src/io/io_helpers.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/io/io_helpers.h b/src/io/io_helpers.h new file mode 100644 index 0000000..94e37f4 --- /dev/null +++ b/src/io/io_helpers.h @@ -0,0 +1,53 @@ +#pragma once + +#include <forstio/async/async.h> +#include <forstio/core/common.h> + +#include <cstdint> +#include <optional> + +namespace saw { +/* + * Helper classes for the specific driver implementations + */ + +/* + * Since I don't want to repeat these implementations for tls on unix systems + * and gnutls doesn't let me write or read into buffers I have to have this kind + * of strange abstraction. This may also be reusable for windows/macOS though. + */ +class input_stream; + +class read_task_and_step_helper { +public: + struct read_io_task { + void *buffer; + size_t min_length; + size_t max_length; + size_t already_read = 0; + }; + std::optional<read_io_task> read_task; + own<conveyor_feeder<size_t>> read_done = nullptr; + + own<conveyor_feeder<void>> on_read_disconnect = nullptr; + +public: + void read_step(input_stream &reader); +}; + +class output_stream; + +class write_task_and_step_helper { +public: + struct write_io_task { + const void *buffer; + size_t length; + size_t already_written = 0; + }; + std::optional<write_io_task> write_task; + own<conveyor_feeder<size_t>> write_done = nullptr; + +public: + void write_step(output_stream &writer); +}; +} // namespace saw |