diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-03-07 10:28:04 +0100 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-03-07 10:28:04 +0100 |
commit | 7a097bd3bdb288342cc7314f6942347274811030 (patch) | |
tree | 4655ba3f79e79b74ae83ad724d66a56a5e319a1b /modules/io/c++/io_helpers.hpp | |
parent | d2520819150d9a794baf7505d7d02dadeacd5266 (diff) |
io: Move to new dir structure
Diffstat (limited to 'modules/io/c++/io_helpers.hpp')
-rw-r--r-- | modules/io/c++/io_helpers.hpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/modules/io/c++/io_helpers.hpp b/modules/io/c++/io_helpers.hpp new file mode 100644 index 0000000..4f45382 --- /dev/null +++ b/modules/io/c++/io_helpers.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include <forstio/async/async.hpp> +#include <forstio/common.hpp> + +#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 |