aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2021-05-15 13:58:01 +0200
committerMax Audron <audron@cocaine.farm>2021-05-15 13:58:01 +0200
commitd0bff910b0b038ee85bc285bef7a63870a3474ab (patch)
treeb840d0b932c080fa5d5053b6bf66a91f94a80481 /src/config.rs
init
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs46
1 files changed, 46 insertions, 0 deletions
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<Config> 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<String>,
+}
+
+#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, Deserialize)]
+pub struct Settings {
+ pub prefix: char,
+}