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
52
53
54
55
56
57
58
59
60
61
62
63
64
const APP_NAME: &str = "Postgres";
const MODULE_VERSION: &'static str = env!("CARGO_PKG_VERSION");
use anyhow::{Context, Result};
use serde_derive::{Deserialize, Serialize};
use super::*;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Postgres {
instance: AppInstance,
}
impl Postgres {
fn get_module_version() -> Result<semver::Version> {
Ok({
semver::Version::parse(MODULE_VERSION).context(format!(
"{} has an invalid version number '{}' Cargo.toml",
APP_NAME, MODULE_VERSION
))
}?)
}
fn get_name(&self) -> String {
match &self.instance.version {
Some(ver) => format!("{} ({})", APP_NAME, ver),
None => format!("{} (Unknown Version)", APP_NAME),
}
}
}
impl AppTrait for Postgres {
fn get_name(&self) -> String {
self.get_name()
}
fn build(instance: AppInstance, _parent: Option<Rc<dyn ContainerTrait>>) -> Result<Postgres> {
Ok(Postgres {
instance: AppInstance {
module_version: Some(Postgres::get_module_version()?),
..instance.clone()
},
})
}
fn set_version(&self, _instance: AppInstance) -> Result<AppInstance> {
unimplemented!()
}
}