I have been thinking, should we have more than just a TooShort option for DecodeError to be more descriptive? Almost all decoders will be doing some kind of utf-8 parsing and then conversion to a RocType. Perhaps adding a BadUtf8, UnexpectedType and InvalidType as well as TooShort might be helpful?
Can a decoder not specify its own error types?
Hmm, not sure. The type in the Decode builtin is currently DecodeError : [TooShort] which I think means it is open by default now. So I guess so?
Yeah, we should have more error options. The current list was not meant to be exhaustive
Decoders cannot specify their own error types because in order to do so we would need associated types on abilities, which we don’t intend to add.
We could add a catch all “Other Str” error that decoders could use to fill in non-standard errors with
BadUtf8 is probably too specific, but maybe something about "the encoding was wrong" would be a good one
like MalformedContent or something
How does serde in rust deal with this?
associated types on deserializers
https://docs.rs/serde/1.0.159/serde/trait.Deserializer.html
Last updated: Jun 16 2026 at 16:19 UTC