|
|
|
@ -33,11 +33,11 @@ pub struct TomlConfig { |
|
|
|
}
|
|
|
|
|
|
|
|
impl TomlConfig {
|
|
|
|
fn from_str(s: &str) -> Result<Self, toml::de::Error> {
|
|
|
|
pub fn from_str(s: &str) -> Result<Self, toml::de::Error> {
|
|
|
|
toml::from_str(s)
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn from_file_path(path: &Path) -> anyhow::Result<Self> {
|
|
|
|
pub async fn from_file_path(path: &Path) -> anyhow::Result<Self> {
|
|
|
|
let mut file =
|
|
|
|
File::open(path).await.context("opening toml config file")?;
|
|
|
|
|
|
|
|
@ -88,7 +88,7 @@ impl Default for Config { |
|
|
|
|
|
|
|
impl Config {
|
|
|
|
/// Builds a new config with the given `credentials` and default values.
|
|
|
|
fn new(credentials: Credentials) -> Self {
|
|
|
|
pub fn new(credentials: Credentials) -> Self {
|
|
|
|
Self {
|
|
|
|
credentials,
|
|
|
|
server_address: "server.slsknet.org:2242".to_string(),
|
|
|
|
@ -100,7 +100,7 @@ impl Config { |
|
|
|
}
|
|
|
|
|
|
|
|
/// Attempts to build a `Config` from the given `TomlConfig`.
|
|
|
|
fn from_toml(toml: TomlConfig) -> anyhow::Result<Self> {
|
|
|
|
pub fn from_toml(toml: TomlConfig) -> anyhow::Result<Self> {
|
|
|
|
let credentials = Credentials::new(toml.user_name, toml.password)
|
|
|
|
.context("validating credentials")?;
|
|
|
|
|
|
|
|
|