mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
core API: save_to_file, save_to_writer
This commit is contained in:
parent
c86f790986
commit
a105fd44c4
1 changed files with 2 additions and 2 deletions
|
@ -132,12 +132,12 @@ impl Credentials {
|
||||||
File::open(path).ok().map(Credentials::from_reader)
|
File::open(path).ok().map(Credentials::from_reader)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_to_writer<W: Write>(&self, writer: &mut W) {
|
fn save_to_writer<W: Write>(&self, writer: &mut W) {
|
||||||
let contents = serde_json::to_string(&self.clone()).unwrap();
|
let contents = serde_json::to_string(&self.clone()).unwrap();
|
||||||
writer.write_all(contents.as_bytes()).unwrap();
|
writer.write_all(contents.as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_to_file<P: AsRef<Path>>(&self, path: P) {
|
pub(crate) fn save_to_file<P: AsRef<Path>>(&self, path: P) {
|
||||||
let mut file = File::create(path).unwrap();
|
let mut file = File::create(path).unwrap();
|
||||||
self.save_to_writer(&mut file)
|
self.save_to_writer(&mut file)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue