-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamic casting to COM implementation (#3055)
This provides a new feature for COM developers using the windows-rs crate. It allows for safe dynamic casting from IUnknown to an implementation object. It is based on Rust's Any trait. Any type that is marked with #[implement], except for those that contain non-static lifetimes, can be used with dynamic casting. Example: ```rust struct MyApp { ... } fn main() { let my_app = ComObject::new(MyApp { ... }); let iunknown: IUnknown = my_app.to_interface(); do_stuff(&iunknown); } fn do_stuff(unknown: &IUnknown) -> Result<()> { let my_app: ComObject<MyApp> = unknown.cast_object()?; my_app.internal_method(); Ok(()) } ``` Co-authored-by: Arlie Davis <[email protected]>
- Loading branch information
1 parent
40d35fa
commit ccd334f
Showing
5 changed files
with
245 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters