bootstrap

Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-11-25 02:11:19 +03:00
commit ca04975d54
62 files changed
+3381

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
#pragma once
#include <cstddef>
#include <expected>
#include <iosfwd>
#include <optional>
#include <string>
#include <string_view>
namespace vls {
struct FrameLimits {
std::size_t header_bytes{8192};
std::size_t body_bytes{16777216};
};
// A disengaged optional means EOF between frames. Framing errors are fatal: the
// caller must not attempt to find another frame in an untrusted byte stream.
[[nodiscard]] std::expected<std::optional<std::string>, std::string>
read_frame(std::istream &input, FrameLimits limits = {});
[[nodiscard]] std::expected<void, std::string> write_frame(std::ostream &output,
std::string_view body);
} // namespace vls
+23
View File
@@ -0,0 +1,23 @@
#pragma once
#include <Void/Data/StrictJson.hpp>
#include <cstddef>
#include <cstdint>
#include <expected>
#include <string>
#include <string_view>
#include <variant>
namespace vls {
using Json = Void::Json::Strict::Value;
using RequestId = std::variant<std::int32_t, std::string>;
[[nodiscard]] std::expected<Json, std::string> parse_json(std::string_view text,
std::size_t maximum_depth = 64);
[[nodiscard]] std::expected<RequestId, std::string> request_id(const Json &value);
[[nodiscard]] std::string quote_json(std::string_view text);
[[nodiscard]] std::string encode_id(const RequestId &id);
} // namespace vls
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include <vls/Framing.hpp>
#include <iosfwd>
#include <optional>
#include <string>
#include <string_view>
namespace vls {
inline constexpr std::string_view server_version = "0.1.0";
struct DispatchResult {
std::optional<std::string> response;
std::optional<int> exit_code;
};
class Server {
public:
[[nodiscard]] DispatchResult handle(std::string_view body);
private:
enum class State { awaiting_initialize, running, shutdown };
State state_{State::awaiting_initialize};
};
// Thin transport loop shared by the executable and stream-failure unit tests.
[[nodiscard]] int run_stdio(std::istream &input, std::ostream &output, std::ostream &diagnostics,
FrameLimits limits = {});
} // namespace vls