diff options
| author | Sean McArthur <sean.monstar@gmail.com> | 2014-03-18 10:58:26 -0700 |
|---|---|---|
| committer | Sean McArthur <sean.monstar@gmail.com> | 2014-03-27 17:41:55 -0700 |
| commit | f1739b14a1346419a4598339aee32aab07e0d12e (patch) | |
| tree | 1f22c1cc492f9729cd1420654f97f3b511938369 /src/libworkcache | |
| parent | 13dafa09f1a80b8b50f41cab42ac2bfd24dfa6b9 (diff) | |
| download | rust-f1739b14a1346419a4598339aee32aab07e0d12e.tar.gz rust-f1739b14a1346419a4598339aee32aab07e0d12e.zip | |
serialize: use Result
All of Decoder and Encoder's methods now return a Result. Encodable.encode() and Decodable.decode() return a Result as well. fixes #12292
Diffstat (limited to 'src/libworkcache')
| -rw-r--r-- | src/libworkcache/lib.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/libworkcache/lib.rs b/src/libworkcache/lib.rs index 3e513472027..a049279c5c4 100644 --- a/src/libworkcache/lib.rs +++ b/src/libworkcache/lib.rs @@ -203,7 +203,7 @@ impl Database { self.db_filename.display(), e.to_str()), Ok(r) => { let mut decoder = json::Decoder::new(r); - self.db_cache = Decodable::decode(&mut decoder); + self.db_cache = Decodable::decode(&mut decoder).unwrap(); } } } @@ -252,19 +252,19 @@ enum Work<'a, T> { WorkFromTask(&'a Prep<'a>, Receiver<(Exec, T)>), } -fn json_encode<'a, T:Encodable<json::Encoder<'a>>>(t: &T) -> ~str { +fn json_encode<'a, T:Encodable<json::Encoder<'a>, io::IoError>>(t: &T) -> ~str { let mut writer = MemWriter::new(); let mut encoder = json::Encoder::new(&mut writer as &mut io::Writer); - t.encode(&mut encoder); + let _ = t.encode(&mut encoder); str::from_utf8_owned(writer.unwrap()).unwrap() } // FIXME(#5121) -fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T { +fn json_decode<T:Decodable<json::Decoder, json::Error>>(s: &str) -> T { debug!("json decoding: {}", s); let j = json::from_str(s).unwrap(); let mut decoder = json::Decoder::new(j); - Decodable::decode(&mut decoder) + Decodable::decode(&mut decoder).unwrap() } impl Context { @@ -392,15 +392,15 @@ impl<'a> Prep<'a> { } pub fn exec<'a, T:Send + - Encodable<json::Encoder<'a>> + - Decodable<json::Decoder>>( + Encodable<json::Encoder<'a>, io::IoError> + + Decodable<json::Decoder, json::Error>>( &'a self, blk: proc:Send(&mut Exec) -> T) -> T { self.exec_work(blk).unwrap() } fn exec_work<'a, T:Send + - Encodable<json::Encoder<'a>> + - Decodable<json::Decoder>>( // FIXME(#5121) + Encodable<json::Encoder<'a>, io::IoError> + + Decodable<json::Decoder, json::Error>>( // FIXME(#5121) &'a self, blk: proc:Send(&mut Exec) -> T) -> Work<'a, T> { let mut bo = Some(blk); @@ -443,8 +443,8 @@ impl<'a> Prep<'a> { } impl<'a, T:Send + - Encodable<json::Encoder<'a>> + - Decodable<json::Decoder>> + Encodable<json::Encoder<'a>, io::IoError> + + Decodable<json::Decoder, json::Error>> Work<'a, T> { // FIXME(#5121) pub fn from_value(elt: T) -> Work<'a, T> { |
