From a14896f9ed209dd3f9597722e5a5697bd7dbf531 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 4 Dec 2023 12:18:14 +0100 Subject: meta: Renamed folder containing source --- modules/io/io_helpers.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 modules/io/io_helpers.h (limited to 'modules/io/io_helpers.h') diff --git a/modules/io/io_helpers.h b/modules/io/io_helpers.h new file mode 100644 index 0000000..94e37f4 --- /dev/null +++ b/modules/io/io_helpers.h @@ -0,0 +1,53 @@ +#pragma once + +#include +#include + +#include +#include + +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_task; + own> read_done = nullptr; + + own> 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_task; + own> write_done = nullptr; + +public: + void write_step(output_stream &writer); +}; +} // namespace saw -- cgit v1.2.3