Add client options
This commit is contained in:
parent
7ac2d7688e
commit
3161bf763d
1 changed files with 40 additions and 0 deletions
40
library/include/larra/client/options.hpp
Normal file
40
library/include/larra/client/options.hpp
Normal 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
|
Loading…
Reference in a new issue