Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing invalid model data #16

Open
bikeshedder opened this issue Oct 26, 2024 · 0 comments
Open

Parsing invalid model data #16

bikeshedder opened this issue Oct 26, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@bikeshedder
Copy link
Owner

What should happen if parsing of a point fails? What about non-spec compliant devices? As of now you just can't interact with those devices using the read_model function. It will just return an Err(ReadModelError::DecodeError(_)).

I quite like the idea of returning the not fully validated model as part of the ReadModelError. It makes it painfully obvious that something went wrong but still provides access to the structurally parsed data.

Alternatively a second set of models could be generated where everything is Optional and validation doesn't happen at all. This could even ignore errors such as models which are too short, etc.

I was also thinking of wrapping all points in a PointValue<T> structure that implements Deref<Target=T> making it possible to add an extra error: Option<PointError> field to every value. This will double the memory usage and require users to sprinkle a lot of * in the code for manual dereferencing which can panic if used with the non-validated variant of that struct.

I don't even know if this is an issue to begin with. Are there any real-world devices that need to be supported that implement the spec horribly wrong? Should this even be supported by this crate?

@bikeshedder bikeshedder added the enhancement New feature or request label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant