services/src/lib.rs

58 lines
986 B
Rust

pub mod models;
pub mod schema;
use core::fmt::{Debug, Display, Formatter, Result};
use std::fs::read_to_string;
use kdl::KdlDocument;
pub struct Config {
pub database: String,
pub ip_to_asn: String,
pub source_code: String,
}
pub fn get_config() -> Config {
let kdl: KdlDocument = read_to_string("config.kdl")
.expect("unable to open config.kdl")
.parse()
.expect("failed to parse KDL");
Config {
database: kdl
.get_arg("database")
.unwrap()
.as_string()
.unwrap()
.to_string(),
ip_to_asn: kdl
.get_arg("ip-to-asn")
.unwrap()
.as_string()
.unwrap()
.to_string(),
source_code: kdl
.get_arg("source-code")
.unwrap()
.as_string()
.unwrap()
.to_string(),
}
}
#[derive(rocket::FromFormField, Debug, PartialEq)]
pub enum Software {
PeerTube,
Etherpad,
Invidious,
LibreQR,
ServNest,
Lufi,
Librex,
Forgejo,
Gitea,
}
impl Display for Software {
fn fmt(&self, f: &mut Formatter) -> Result {
Debug::fmt(self, f)
}
}