Redefine `Error`s interface
We would like to keep the size of Error as small as possible (currently, it's 48 bytes already).
So it needs to be defined as a struct with Boxed inner error, in the same manner as it's done in serde_json or reqwest:
https://github.com/serde-rs/json/blob/master/src/error.rs
https://github.com/seanmonstar/reqwest/blob/master/src/error.rs
@torymur but with this change, we will have to update code at all places which uses Error::IndexError for example.
Should it then be handled in this way ??
// Convert from ErrorImpl to Error
impl From<ErrorImpl> for Error {
fn from(err_impl: ErrorImpl) -> Self {
Error(Box::new(err_impl))
}
}
And replacing this:
Err(Error::IndexError)
with this:
Err(ErrorImpl::IndexError.into())
Another option is to use constructor methods, I am not sure which design pattern would be better, lmk your thoughts on this.
Hey @sky-2002
Apologies, I now assigned myself to this issue and I will figure out a better way to communicate issues like this, which is more of a note to not forget, rather than anything actionable (even for a better thought than in description). This part of the project is in the middle of heavy refactoring and is not stabilized yet enough to answer here right now.
@torymur ahh right, thanks for clearing, thought as much, it did look like a note to not to forget, my bad 🙌🏻 . Anyways, apologies for the interruption. Actually I keep looking for issues to get hands on with rust (as I come from python) and also with outlines, and so found this one.
@sky-2002 There are some unassigned issues with json schema, for example, recently outlines added support for objects in enum fields, but we didn't have it here: https://github.com/dottxt-ai/outlines-core/issues/100
Cool, will check out those.