Added socket_addr() helper to Config.
This commit is contained in:
parent
1f3b3d64b5
commit
d9fc586b8c
1 changed files with 7 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue