Add client options

This commit is contained in:
sha512sum 2024-08-31 18:35:55 +00:00
parent 7ac2d7688e
commit 3161bf763d

View file

@ -0,0 +1,40 @@
#pragma once
#include <larra/proxy.hpp>
#include <larra/utils.hpp>
namespace larra::xmpp::client {
struct Options {
enum UseTls { kNever, kWhenAvailable, kRequire };
UseTls useTls = kWhenAvailable;
bool allowPlainWithoutTls = false;
std::optional<std::string> hostname = std::nullopt;
std::optional<std::uint16_t> port = std::nullopt;
Proxy proxy = SystemConfiguredProxy{};
template <typename Self>
constexpr auto UseTls(this Self&& self, UseTls value) -> Options {
return utils::FieldSetHelper::With<"useTls", Options>(std::forward<Self>(self), std::move(value));
}
template <typename Self>
constexpr auto AllowPlainWithoutTls(this Self&& self, bool value) -> Options {
return utils::FieldSetHelper::With<"allowPlainWithoutTls", Options>(std::forward<Self>(self), std::move(value));
}
template <typename Self>
constexpr auto Hostname(this Self&& self, std::optional<std::string> value) -> Options {
return utils::FieldSetHelper::With<"hostname", Options>(std::forward<Self>(self), std::move(value));
}
template <typename Self>
constexpr auto Port(this Self&& self, std::optional<std::uint16_t> value) -> Options {
return utils::FieldSetHelper::With<"port", Options>(std::forward<Self>(self), std::move(value));
}
template <typename Self>
constexpr auto Proxy(this Self&& self, Proxy value) -> Options {
return utils::FieldSetHelper::With<"proxy", Options>(std::forward<Self>(self), std::move(value));
}
};
} // namespace larra::xmpp::client