1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#![deny(missing_docs)]
#[macro_use]
extern crate diesel;
pub mod cache;
pub mod cache_structures;
pub mod clients;
pub mod schema;
pub mod utils;
use diesel::pg::PgConnection;
use diesel::prelude::*;
pub struct DatabaseHandler {
pub handle: PgConnection,
pub clients: clients::ClientHandler,
}
impl DatabaseHandler {
pub fn connect() -> Self {
let url = "postgres://muoxi:muoxi@localhost/muoxi".to_string();
let conn = PgConnection::establish(&url).expect("Couldn't create handle to database");
Self {
handle: conn,
clients: clients::ClientHandler {},
}
}
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}