stdweb
stdweb copied to clipboard
Any chance of webcore::ConversionError being publicly exported?
I'm writing a library which uses stdweb
for a fairly niche use case and one of the pain points is using generics with TryFrom
and stdweb
's definitions.
Right now there are a number of places in my codebase that look like this because I can't explicitly name ConversionError
:
pub unsafe trait LookConstant {
type Item: TryFrom<Value, Error = <Reference as TryFrom<Value>>::Error>;
fn look_code(&self) -> Look;
}
This works, but it's super ugly to have <Xxx as TryFrom<Value>>::Error
everywhere rather than being able to explicitly name the type.
Is there any chance that ConversionError
is allowed to be publicly referenced? I have no need to construct it, or even access any of it's methods- just having a public type that could be used in type signatures would be a great help.
Actually, being able to construct it would be tremendously useful to implement TryFrom<Value>
for other objects through references, without resorting to a full serde serialization/deserialization process.
Now my only way to achieve that is to move the checks logic for try_from
into javascript and return something that the current implementation doesn't expect.
Hmm.. possibly! I could probably export it as a purely opaque type for now.
Ideally I'd like to figure out a good way to extend it (along with the whole conversion machinery) to include more information so that it could tell you not only what was the expected type, but also what it actually received.
I'll be curious to see what is your solution. AFAIK, the biggest problem is that try_from
consumes its input, which wouldn't leave you with much to report on what happened.