You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hub/dev-environment/rust/rss-reader-rust-for-windows.md
+12-6Lines changed: 12 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ manager: jken
7
7
ms.topic: article
8
8
keywords: rust, windows 10, microsoft, learning rust, rust on windows for beginners, rust with vs code, rust for windows
9
9
ms.localizationpriority: medium
10
-
ms.date: 12/09/2022
10
+
ms.date: 05/22/2023
11
11
---
12
12
13
13
# RSS reader tutorial (Rust for Windows with VS Code)
@@ -72,7 +72,7 @@ Now let's try out Rust for Windows by writing a simple console app that download
72
72
...
73
73
74
74
fn main() -> Result<()> {
75
-
let uri = Uri::CreateUri(h!("https://blog.rust-lang.org/feed.xml"))?;
75
+
let uri = Uri::CreateUri(h!("https://blogs.windows.com/feed"))?;
76
76
77
77
Ok(())
78
78
}
@@ -91,7 +91,7 @@ Now let's try out Rust for Windows by writing a simple console app that download
91
91
...
92
92
93
93
fn main() -> windows::core::Result<()> {
94
-
let uri = Uri::CreateUri(h!("https://blog.rust-lang.org/feed.xml"))?;
94
+
let uri = Uri::CreateUri(h!("https://blogs.windows.com/feed"))?;
95
95
let client = SyndicationClient::new()?;
96
96
97
97
Ok(())
@@ -107,7 +107,7 @@ Now let's try out Rust for Windows by writing a simple console app that download
107
107
...
108
108
109
109
fn main() -> windows::core::Result<()> {
110
-
let uri = Uri::CreateUri(h!("https://blog.rust-lang.org/feed.xml"))?;
110
+
let uri = Uri::CreateUri(h!("https://blogs.windows.com/feed"))?;
111
111
let client = SyndicationClient::new()?;
112
112
let feed = client.RetrieveFeedAsync(&uri)?.get()?;
113
113
@@ -117,15 +117,21 @@ Now let's try out Rust for Windows by writing a simple console app that download
117
117
118
118
Because [**RetrieveFeedAsync**](/uwp/api/windows.web.syndication.syndicationclient.retrievefeedasync) is an asynchronous API, we use the blocking **get** function to keep the example simple. Alternatively, we could use the `await` operator within an `async` function to cooperatively wait for the results. A more complex app with a graphical user interface will frequently use `async`.
119
119
120
-
9. Now we can iterate over the resulting items, and let's print out just the titles.
120
+
9. Now we can iterate over the resulting items, and let's print out just the titles. You'll also see a few extra lines of code below to set a user-agent header, since some RSS feeds require that.
121
121
122
122
```rust
123
123
// src\main.rs
124
124
...
125
125
126
126
fn main() -> windows::core::Result<()> {
127
-
let uri = Uri::CreateUri(h!("https://blog.rust-lang.org/feed.xml"))?;
127
+
let uri = Uri::CreateUri(h!("https://blogs.windows.com/feed"))?;
128
128
let client = SyndicationClient::new()?;
129
+
130
+
client.SetRequestHeader(
131
+
h!("User-Agent"),
132
+
h!("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"),
133
+
)?;
134
+
129
135
let feed = client.RetrieveFeedAsync(&uri)?.get()?;
0 commit comments