Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Should the safe query_interface return a Result<Interface, HResult> instead of a Option<Interface>? #176

Open
rylev opened this issue Oct 20, 2020 · 1 comment
Labels
question Further information is requested

Comments

@rylev
Copy link
Contributor

rylev commented Oct 20, 2020

We assume that if a call to QueryInterface doesn't return success, that the requested interface is not implemented for the backing class. But it is possible that some implementations may return non-standard errors. Should we provide the ability for the user to inspect the error to ensure that E_NOINTERFACE is returned and if not, do something else with the error?

@rylev rylev added the question Further information is requested label Oct 20, 2020
@russcam
Copy link
Contributor

russcam commented Aug 19, 2021

I think Result<T,E> maps better to QueryInterface semantics than Option<T> does, and as you say, provides ability to make a decision on the error, or call .ok() to get an Option<T> to have current behaviour.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants