mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
core API: from_file, from_reader
This commit is contained in:
parent
434b824c6e
commit
c86f790986
1 changed files with 2 additions and 2 deletions
|
@ -121,14 +121,14 @@ impl Credentials {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_reader<R: Read>(mut reader: R) -> Credentials {
|
fn from_reader<R: Read>(mut reader: R) -> Credentials {
|
||||||
let mut contents = String::new();
|
let mut contents = String::new();
|
||||||
reader.read_to_string(&mut contents).unwrap();
|
reader.read_to_string(&mut contents).unwrap();
|
||||||
|
|
||||||
serde_json::from_str(&contents).unwrap()
|
serde_json::from_str(&contents).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_file<P: AsRef<Path>>(path: P) -> Option<Credentials> {
|
pub(crate) fn from_file<P: AsRef<Path>>(path: P) -> Option<Credentials> {
|
||||||
File::open(path).ok().map(Credentials::from_reader)
|
File::open(path).ok().map(Credentials::from_reader)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue