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

Allow creation of multiple COMLibrary instances #69

Merged

Conversation

FantasyTeddy
Copy link
Contributor

This fixes #37 where the relevant discussion can be found.

The second commit adds an example for how to use COMLibrary as a per-thread singleton, since this should still be the recommended way of using it.

match instance.init_security() {
Ok(()) => {}
// Security was already initialized, this is fine
Err(WMIError::HResultError { hres }) if hres == RPC_E_TOO_LATE.0 => {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having to access the i32 representation of the HRESULT with .0 seems a bit off to me.
Can we change the type of hres to HRESULT?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but that will be a breaking change so I wanted to avoid that for now.

match instance.init_security() {
Ok(()) => {}
// Security was already initialized, this is fine
Err(WMIError::HResultError { hres }) if hres == RPC_E_TOO_LATE.0 => {}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but that will be a breaking change so I wanted to avoid that for now.

@ohadravid ohadravid merged commit cf37b8e into ohadravid:main Mar 18, 2023
@FantasyTeddy FantasyTeddy deleted the allow-creation-of-multiple-COMLibrary branch March 18, 2023 11:02
@FantasyTeddy
Copy link
Contributor Author

Quick question: I realized during development, that formatting is not enforced (I had several local changes that were due to the fact that my editor automatically formats on save).
Would you be interested in a PR that formats the code via cargo fmt and also add a CI check for formatting?

Additionally, the same could be done for cargo clippy, if you would be okay with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

COMLibrary always fails on second call
2 participants