21 lines
421 B
Rust
21 lines
421 B
Rust
use crate::config::GeoffreyAPIConfig;
|
|
use crate::Result;
|
|
use geoffrey_db::database::Database;
|
|
use std::sync::Arc;
|
|
|
|
pub struct Context {
|
|
pub db: Database,
|
|
pub cfg: GeoffreyAPIConfig,
|
|
}
|
|
|
|
impl Context {
|
|
pub fn new(cfg: GeoffreyAPIConfig) -> Result<Arc<Self>> {
|
|
let ctx = Self {
|
|
db: Database::new(cfg.db_path.as_path()).unwrap(),
|
|
cfg,
|
|
};
|
|
|
|
Ok(Arc::new(ctx))
|
|
}
|
|
}
|