contextfree / winrt-rust

Use and (eventually) make Windows Runtime APIs with Rust
Apache License 2.0
142 stars 10 forks source link

Make RuntimeContext not Send and not Sync #61

Closed rbtying closed 5 years ago

rbtying commented 5 years ago

Fixes #60

rbtying commented 5 years ago

Less happily, it looks like cargo test doesn't pass for this crate on my machine?

Boddlnagg commented 5 years ago

@rbtying So cargo test doesn't pass even without your change? Do you have any idea, why? This reminds me that I really need to setup CI (#13) ...

//EDIT: Ah, maybe you forgot to specify the features (#13 mentions this): You need to run cargo test --features "windows-devices windows-data windows-ui windows-system" (and possibly some more features by now)

rbtying commented 5 years ago

Hm. I'm trying now with the features specified, but some of the examples seem to be failing to compile?

>cargo test --features "windows-devices windows-data windows-ui windows-system"
   Compiling winapi v0.3.6
   Compiling winrt v0.5.1 (file:///C:/Users/robert/winrt-rust)
error[E0432]: unresolved import `winrt::windows::storage`
  --> examples\hexdump.rs:11:21
   |
11 | use winrt::windows::storage::*;
   |                     ^^^^^^^ Could not find `storage` in `windows`

error[E0433]: failed to resolve. Use of undeclared type or module `StorageFile`
  --> examples\hexdump.rs:27:16
   |
27 |     let file = StorageFile::get_file_from_path_async(&*FastHString::new(&exe_path_str)).unwrap().blocking_get().expect("get_file_from_path_async failed").unwrap();
   |                ^^^^^^^^^^^ Use of undeclared type or module `StorageFile`

error[E0432]: unresolved import `winrt::windows::storage`
  --> examples\test.rs:11:21
   |
11 | use winrt::windows::storage::*;
   |                     ^^^^^^^ Could not find `storage` in `windows`

error[E0433]: failed to resolve. Use of undeclared type or module `StorageFile`
   --> examples\test.rs:155:16
    |
155 |     let file = StorageFile::get_file_from_path_async(&*FastHString::new(&exe_path_str)).unwrap().blocking_get().expect("get_file_from_path_async failed").unwrap();
    |                ^^^^^^^^^^^ Use of undeclared type or module `StorageFile`

error[E0433]: failed to resolve. Use of undeclared type or module `streams`
  --> examples\hexdump.rs:31:47
   |
31 |     let input_stream = file.query_interface::<streams::IInputStreamReference>().unwrap().open_sequential_read_async().unwrap().blocking_get().unwrap().unwrap();
   |                                               ^^^^^^^ Use of undeclared type or module `streams`

error[E0433]: failed to resolve. Use of undeclared type or module `streams`
  --> examples\hexdump.rs:33:23
   |
33 |     let data_reader = streams::DataReader::create_data_reader(&input_stream).unwrap();
   |                       ^^^^^^^ Use of undeclared type or module `streams`

error[E0412]: cannot find type `IStorageItem` in this scope
  --> examples\hexdump.rs:28:57
   |
28 |     println!("Dumping file: {}", file.query_interface::<IStorageItem>().unwrap().get_path().unwrap());
   |                                                         ^^^^^^^^^^^^ not found in this scope

warning: unused import: `winrt::windows::storage::*`
  --> examples\hexdump.rs:11:5
   |
11 | use winrt::windows::storage::*;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(unused_imports)] on by default

error[E0433]: failed to resolve. Use of undeclared type or module `CreationCollisionOption`
   --> examples\test.rs:164:88
    |
164 |     let txt_file = exe_folder.create_file_async(&*FastHString::new("__test_file.txt"), CreationCollisionOption::ReplaceExisting).unwrap().blocking_get().expect("create_file_async failed").unwrap();
    |                                                                                        ^^^^^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `CreationCollisionOption`

error[E0433]: failed to resolve. Use of undeclared type or module `FileIO`
   --> examples\test.rs:166:5
    |
166 |     FileIO::append_text_async(&txt_file, &*FastHString::new("This is a test\nand a second line.")).unwrap().blocking_wait();
    |     ^^^^^^ Use of undeclared type or module `FileIO`

error[E0433]: failed to resolve. Use of undeclared type or module `FileIO`
   --> examples\test.rs:167:47
    |
167 |     let mut lines: ComPtr<IVector<HString>> = FileIO::read_lines_async(&txt_file).unwrap().blocking_get().expect("read_lines_async failed").unwrap();
    |                                               ^^^^^^ Use of undeclared type or module `FileIO`

error[E0412]: cannot find type `IStorageItem` in this scope
   --> examples\test.rs:156:60
    |
156 |     println!("Executable file: {}", file.query_interface::<IStorageItem>().unwrap().get_path().unwrap());
    |                                                            ^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `IStorageItem2` in this scope
   --> examples\test.rs:163:45
    |
163 |     let exe_folder = file.query_interface::<IStorageItem2>().unwrap().get_parent_async().unwrap().blocking_get().expect("get_parent_async failed").unwrap();
    |                                             ^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `IStorageItem` in this scope
   --> examples\test.rs:165:65
    |
165 |     println!("Created text file {}", txt_file.query_interface::<IStorageItem>().unwrap().get_path().unwrap());
    |                                                                 ^^^^^^^^^^^^ not found in this scope

warning: unused import: `winrt::windows::storage::*`
  --> examples\test.rs:11:5
   |
11 | use winrt::windows::storage::*;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 5 previous errors

   |
Some errors occurred: E0412, E0432, E0433.
   = note: #[warn(unused_imports)] on by default

For more information about an error, try `rustc --explain E0412`.
error: Could not compile `winrt`.
warning: build failed, waiting for other jobs to finish...
error: aborting due to 8 previous errors

Some errors occurred: E0412, E0432, E0433.
For more information about an error, try `rustc --explain E0412`.
error: Could not compile `winrt`.

To learn more, run the command again with --verbose.
Boddlnagg commented 5 years ago

Then that list is outdated and you need to add the windows-storage feature to the list of --features. I need to update that documentation ...

Boddlnagg commented 5 years ago

I tested this and it's all fine. Thank you again :-)