Write tentative interfaces for async operation
This commit is contained in:
parent
cc456733fd
commit
4bded5e501
28
include/IAsyncClient.hpp
Normal file
28
include/IAsyncClient.hpp
Normal 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
27
include/IAsyncServer.hpp
Normal 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 :
|
22
include/IRequestHandler.hpp
Normal file
22
include/IRequestHandler.hpp
Normal 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 :
|
Loading…
Reference in New Issue
Block a user