summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mullvad-types/src/settings/mod.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/mullvad-types/src/settings/mod.rs b/mullvad-types/src/settings/mod.rs
index edc6de94c6..32190a46cc 100644
--- a/mullvad-types/src/settings/mod.rs
+++ b/mullvad-types/src/settings/mod.rs
@@ -112,7 +112,7 @@ impl Settings {
io::BufReader::new(file)
.read_to_end(&mut settings_bytes)
.map_err(|e| Error::ReadError("Failed to read settings file".to_owned(), e))?;
- Self::parse_settings(&mut settings_bytes).or_else(|e| {
+ Self::load_from_bytes(&mut settings_bytes).or_else(|e| {
log::error!(
"{}",
e.display_chain_with_msg("Failed to parse settings file")
@@ -128,6 +128,11 @@ impl Settings {
}
}
+ pub fn load_from_bytes(bytes: &[u8]) -> Result<Self> {
+ serde_json::from_slice(bytes).map_err(Error::ParseError)
+ }
+
+
/// Serializes the settings and saves them to the file it was loaded from.
fn save(&self) -> Result<()> {
let path = Self::get_settings_path()?;
@@ -162,10 +167,6 @@ impl Settings {
Ok(dir.join(SETTINGS_FILE))
}
- fn parse_settings(bytes: &[u8]) -> Result<Settings> {
- serde_json::from_slice(bytes).map_err(Error::ParseError)
- }
-
pub fn get_account_token(&self) -> Option<String> {
self.account_token.clone()
}