cleanup nodename()
This commit is contained in:
parent
74a69302a7
commit
0d38dcb43c
19
src/tools.rs
19
src/tools.rs
|
@ -234,12 +234,12 @@ pub fn nodename() -> &'static str {
|
||||||
lazy_static!{
|
lazy_static!{
|
||||||
static ref NODENAME: String = {
|
static ref NODENAME: String = {
|
||||||
|
|
||||||
let utsname = nix::sys::utsname::uname();
|
nix::sys::utsname::uname()
|
||||||
let nodename = utsname.nodename();
|
.nodename()
|
||||||
|
.split('.')
|
||||||
let parts: Vec<&str> = nodename.split('.').collect();
|
.next()
|
||||||
|
.unwrap()
|
||||||
parts[0].to_owned()
|
.to_owned()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,3 +252,10 @@ pub fn required_string_param<'a>(param: &'a Value, name: &str) -> Result<&'a str
|
||||||
None => bail!("missing parameter '{}'", name),
|
None => bail!("missing parameter '{}'", name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn required_integer_param<'a>(param: &'a Value, name: &str) -> Result<i64, Error> {
|
||||||
|
match param[name].as_i64() {
|
||||||
|
Some(s) => Ok(s),
|
||||||
|
None => bail!("missing parameter '{}'", name),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue