contextfree / winrt-rust

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

cannot compile toast_notify.rs #38

Closed hoodie closed 7 years ago

hoodie commented 7 years ago

I was trying to build the toast example but all I got was this t-shirt - er, I mean, this error. Looks like you're relying on code that is not published yet?

error[E0432]: unresolved import `winrt::windows::data::xml::dom::*`
 --> examples\toast_notify.rs:9:5
  |
9 | use winrt::windows::data::xml::dom::*;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could not find `data` in `windows`

error[E0432]: unresolved import `winrt::windows::ui::notifications::*`
  --> examples\toast_notify.rs:10:5
   |
10 | use winrt::windows::ui::notifications::*;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could not find `ui` in `windows`

error[E0433]: failed to resolve. Use of undeclared type or module `ToastNotificationManager`
  --> examples\toast_notify.rs:20:25
   |
20 |     let mut toast_xml = ToastNotificationManager::get_template_content(ToastTemplateType_ToastText02).unwrap();
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `ToastNotificationManager`

error[E0425]: cannot find value `ToastTemplateType_ToastText02` in this scope
  --> examples\toast_notify.rs:20:72
   |
20 |     let mut toast_xml = ToastNotificationManager::get_template_content(ToastTemplateType_ToastText02).unwrap();
   |                                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `IXmlNode` in this scope
  --> examples\toast_notify.rs:25:150
   |
25 |     toast_text_elements.item(0).unwrap().append_child(&*toast_xml.create_text_node(&FastHString::new("Hello from Rust!")).unwrap().query_interface::<IXmlNode>().unwrap()).unwrap();
   |                                                                                                                                                      ^^^^^^^^ not found in this scope

error[E0412]: cannot find type `IXmlNode` in this scope
  --> examples\toast_notify.rs:26:157
   |
26 |     toast_text_elements.item(1).unwrap().append_child(&*toast_xml.create_text_node(&FastHString::new("This is some more text.")).unwrap().query_interface::<IXmlNode>().unwrap()).unwrap();
   |                                                                                                                                                             ^^^^^^^^ not found in this scope

error[E0433]: failed to resolve. Use of undeclared type or module `ToastNotification`
  --> examples\toast_notify.rs:32:17
   |
32 |     let toast = ToastNotification::create_toast_notification(&*toast_xml).unwrap();
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `ToastNotification`

error[E0433]: failed to resolve. Use of undeclared type or module `ToastNotificationManager`
  --> examples\toast_notify.rs:35:5
   |
35 |     ToastNotificationManager::create_toast_notifier_with_id(&FastHString::new("myrustapp.exe")).unwrap().show(&*toast).unwrap();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `ToastNotificationManager`

error: aborting due to 8 previous errors

error: Could not compile `winrt`.
Boddlnagg commented 7 years ago

You need to enable the cargo features windows-data (for the windows::data module/namespace) and windows-ui (for windows::ui). See also the comment at the top of the file.