From d0bff910b0b038ee85bc285bef7a63870a3474ab Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sat, 15 May 2021 13:58:01 +0200 Subject: init --- src/config.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/config.rs (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..f7a0934 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,46 @@ +use serde::Deserialize; + +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, Deserialize)] +pub struct Config { + pub user: User, + pub server: Server, + pub settings: Settings, +} + +impl From for irc::client::prelude::Config { + fn from(input: Config) -> Self { + Self { + nickname: Some(input.user.nickname), + username: Some(input.user.username), + realname: Some(input.user.realname), + nick_password: Some(input.user.password), + server: Some(input.server.hostname), + port: Some(input.server.port), + use_tls: Some(input.server.tls), + channels: input.server.channels, + ..irc::client::prelude::Config::default() + } + } +} + +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, Deserialize)] +pub struct User { + pub nickname: String, + pub username: String, + pub password: String, + pub realname: String, +} + +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, Deserialize)] +pub struct Server { + pub hostname: String, + pub port: u16, + pub tls: bool, + pub sasl: bool, + pub channels: Vec, +} + +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, Deserialize)] +pub struct Settings { + pub prefix: char, +} -- cgit v1.2.3