23template <
class TSettings,
class TSnapshot = TSettings>
28 using Builder = std::function<TSnapshot(TSettings)>;
32 requires std::same_as<TSettings, TSnapshot>
33 : _build([](TSettings parsed) {
return parsed; })
44 _path = std::string(path);
48 return std::unexpected(
parsed.error());
52 _snapshot = std::move(
next);
53 Log::Info(
"Loaded settings from {}", path);
62 return std::unexpected(
Error::NotReady(
"no settings file was loaded yet"));
64 return Load(std::string(_path));
static Result< T > ReadFile(std::string_view path)
Parse path (resolved via ResolvePath) into T.
Owns a plugin's settings and republishes them whole on every Load.
std::function< TSnapshot(TSettings)> Builder
Validates the parsed settings and derives whatever Get() offers beside them.
const TSnapshot & Get() const
Status Load(std::string_view path)
Load path (JSONC tolerated), build the snapshot, then publish it in one move.
void Info(std::format_string< Args... > fmt, Args &&... args)
static std::string ReadFile(const std::filesystem::path &path)
std::expected< void, Error > Status
static Error NotReady(std::string detail)