Decoding can fail in the same way as any IO operation or any read_xxx() function in trait Reader. So should the serialize::Decodable trait, no? Otherwise, we again depend on using task::try for decoding data structures.
My proposal is to change the signature of trait Decodable to something like:
pub type DecodeResult<T> = Result<T, &str>;
pub trait Decodable<D: Decoder> {
fn decode(d: &mut D) -> DecodeResult<Self>;
}
Likewise, the trait serialize::Decoder must be changed to return DecodeResults as well.
This of course comes with a slight performance penalty in the non-error case.
Decoding can fail in the same way as any IO operation or any
read_xxx()function in traitReader. So should theserialize::Decodabletrait, no? Otherwise, we again depend on usingtask::tryfor decoding data structures.My proposal is to change the signature of trait
Decodableto something like:Likewise, the trait
serialize::Decodermust be changed to returnDecodeResults as well.This of course comes with a slight performance penalty in the non-error case.