aboutsummaryrefslogtreecommitdiff
path: root/src/diplonat.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2020-05-09 16:50:38 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2020-05-09 16:50:38 +0200
commit00c20390343655c8d43212959a811618bb5072d7 (patch)
treeb997e3e758dfb00923b9f322d7084fc7ee45ef19 /src/diplonat.rs
parent79102ba463204721bccad8086a059adaf510c838 (diff)
downloaddiplonat-00c20390343655c8d43212959a811618bb5072d7.tar.gz
diplonat-00c20390343655c8d43212959a811618bb5072d7.zip
Rewrite as an object
Diffstat (limited to 'src/diplonat.rs')
-rw-r--r--src/diplonat.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/diplonat.rs b/src/diplonat.rs
index c209da5..3dd4e91 100644
--- a/src/diplonat.rs
+++ b/src/diplonat.rs
@@ -1,21 +1,22 @@
use anyhow::{Result, Context};
-use log::*;
use crate::*;
-pub struct DiplonatContext {
+pub struct Diplonat {
pub config: config::DiplonatConfig,
pub gateway: igd::aio::Gateway
}
-pub async fn setup() -> Result<DiplonatContext> {
- let ctx = DiplonatContext {
- config: config::load_env().context("Unable to read configuration from environment")?,
- gateway: gw::get_gateway().await?
- };
+impl Diplonat {
+ pub async fn new() -> Result<Self> {
+ let ctx = Self {
+ config: config::load_env().context("Unable to read configuration from environment")?,
+ gateway: gw::get_gateway().await?
+ };
- return Ok(ctx);
-}
+ return Ok(ctx);
+ }
-pub fn listen() -> bool {
- return true;
+ pub fn listen(&self) -> bool {
+ return true;
+ }
}