mirror of
https://git.meli.delivery/meli/meli
synced 2024-11-17 03:26:20 +00:00
Store Addressbook in JSON
This commit is contained in:
parent
b437e55b67
commit
5bffd8e966
@ -8,6 +8,7 @@ workspace = ".."
|
||||
xdg = "2.1.0"
|
||||
serde = "1.0.71"
|
||||
serde_derive = "1.0.71"
|
||||
serde_json = "1.0"
|
||||
config = "0.6"
|
||||
chan = "0.1.21"
|
||||
chan-signal = "0.3.1"
|
||||
|
@ -67,6 +67,7 @@ pub struct Account {
|
||||
|
||||
impl Drop for Account {
|
||||
fn drop(&mut self) {
|
||||
//TODO: Avoid panics
|
||||
let data_dir =
|
||||
xdg::BaseDirectories::with_profile("meli", &self.name)
|
||||
.unwrap();
|
||||
@ -79,7 +80,7 @@ impl Drop for Account {
|
||||
}
|
||||
};
|
||||
let writer = io::BufWriter::new(f);
|
||||
bincode::serialize_into(writer, &self.address_book).unwrap();
|
||||
serde_json::to_writer(writer, &self.address_book).unwrap();
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -104,7 +105,7 @@ impl Account {
|
||||
let address_book = if let Ok(data) = data_dir.place_data_file("addressbook") {
|
||||
if data.exists() {
|
||||
let reader = io::BufReader::new(fs::File::open(data).unwrap());
|
||||
let result: result::Result<AddressBook, _> = bincode::deserialize_from(reader);
|
||||
let result: result::Result<AddressBook, _> = serde_json::from_reader(reader);
|
||||
if let Ok(mut data_t) = result {
|
||||
data_t
|
||||
} else {
|
||||
|
@ -40,6 +40,8 @@ extern crate termion;
|
||||
#[macro_use]
|
||||
extern crate nom;
|
||||
|
||||
extern crate serde_json;
|
||||
|
||||
use melib::*;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user