Write tentative interfaces for async operation

This commit is contained in:
S David 2024-03-15 23:44:14 -04:00
parent cc456733fd
commit 4bded5e501
3 changed files with 77 additions and 0 deletions

28
include/IAsyncClient.hpp Normal file
View File

@ -0,0 +1,28 @@
/* IAsyncClient.hpp
* Copyright © 2024 Saul D. Beniquez
* License: Mozilla Public License v. 2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v.2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <string>
#include "types/Result.hpp"
#include <nlohmann/json.hpp>
namespace mdml {
struct IAsyncServer;
struct IAsyncClient {
virtual auto connect(IAsyncServer& server) -> error_t = 0;
virtual auto sendMsg(nlohmann::json json_msg) -> error_t = 0;
virtual auto read() -> nlohmann::json = 0;
};
}
// clang-format off
// vim: set foldmethod=syntax foldminlines=10 textwidth=80 ts=8 sts=0 sw=8 noexpandtab ft=cpp.doxygen :

27
include/IAsyncServer.hpp Normal file
View File

@ -0,0 +1,27 @@
/* IAsyncServer.hpp
* Copyright © 2024 Saul D. Beniquez
* License: Mozilla Public License v. 2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v.2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <filesystem>
namespace {
namespace fs = std::filesystem;
}
namespace mdml {
struct IAsyncClient;
struct IAsyncServer {
virtual void creasteSocket(const fs::path& path) = 0;
virtual void listen(std::function<bool>&& handler) = 0;
};
}
// clang-format off
// vim: set foldmethod=syntax foldminlines=10 textwidth=80 ts=8 sts=0 sw=8 noexpandtab ft=cpp.doxygen :

View File

@ -0,0 +1,22 @@
/* IRequestHandler.hpp
* Copyright © 2024 Saul D. Beniquez
* License: Mozilla Public License v. 2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v.2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <string>
#include "types/Result.hpp"
namespace mdml {
struct IRequestHandler {
virtual auto processRequest() -> Result<std::string> = 0;
};
}
// clang-format off
// vim: set foldmethod=syntax foldminlines=10 textwidth=80 ts=8 sts=0 sw=8 noexpandtab ft=cpp.doxygen :