Added socket_addr() helper to Config.

This commit is contained in:
Aaron Weiss 2017-01-15 17:32:41 -05:00
parent 1f3b3d64b5
commit d9fc586b8c
No known key found for this signature in database
GPG key ID: 0237035D9BF03AE2

View file

@ -4,6 +4,7 @@ use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::{Error, ErrorKind, Result};
use std::net::SocketAddr;
use std::path::Path;
use rustc_serialize::json::{decode, encode};
@ -127,6 +128,12 @@ impl Config {
})
}
/// Gets the server and port as a `SocketAddr`.
/// This panics when server is not specified or the address is malformed.
pub fn socket_addr(&self) -> SocketAddr {
format!("{}:{}", self.server(), self.port()).parse().unwrap()
}
/// Gets the server password specified in the configuration.
/// This defaults to a blank string when not specified.
pub fn password(&self) -> &str {