As this is the core library I would prefer keeping its size minimal. Pulling in two different json crates seems kind of counterintuitive, now that serde is at 1.0 and stable.
We should remove the json dependency and try to replace the code block below with code that uses serde_json instead.
|
Err(_) => { |
|
println!("I have to do this here"); |
|
let mut file = File::open(path).unwrap(); |
|
let mut data = String::new(); |
|
file.read_to_string(&mut data).unwrap(); |
|
let mut json = match parse(&data) { |
|
Ok(content) => content, |
|
Err(_) => { |
|
return Err(ErrorKind::StorageError(storage_error::ErrorKind::FileCorrupted) |
|
.into()) |
|
} |
|
}; |
|
|
|
let mut lists: Vec<TodoList> = vec![]; |
|
|
|
for outer in json.entries_mut() { |
|
let mut list = TodoList::new(outer.0); |
|
for inner in outer.1.entries_mut() { |
|
let tdo_id = match inner.0.parse::<u32>() { |
|
Ok(id) => id, |
|
Err(_) => return Err(ErrorKind::StorageError(storage_error::ErrorKind::UnableToConvert).into()), |
|
}; |
|
let done = match inner.1.pop().as_bool() { |
|
Some(x) => x, |
|
None => return Err(ErrorKind::StorageError(storage_error::ErrorKind::UnableToConvert).into()), |
|
}; |
|
let tdo_name = match inner.1.pop().as_str() { |
|
Some(x) => String::from(x), |
|
None => return Err(ErrorKind::StorageError(storage_error::ErrorKind::UnableToConvert).into()), |
|
}; |
|
let mut todo = Todo::new(tdo_id, &tdo_name, None); |
|
if done { |
|
todo.set_done(); |
|
} |
|
list.add(todo); |
|
} |
|
lists.push(list); |
|
} |
|
let tdo = Tdo { |
|
lists: lists, |
|
access_token: None, |
|
version: env!("CARGO_PKG_VERSION").to_string(), |
|
}; |
|
Ok(tdo) |
I would propose releasing this as version 0.2.2, which also includes the dependency update I just pushed.
As this is the core library I would prefer keeping its size minimal. Pulling in two different
jsoncrates seems kind of counterintuitive, now thatserdeis at 1.0 and stable.We should remove the
jsondependency and try to replace the code block below with code that usesserde_jsoninstead.tdo-core/src/tdo.rs
Lines 250 to 293 in 6e5d218
I would propose releasing this as version
0.2.2, which also includes the dependency update I just pushed.