Crates.io | wikipedia-wasm |
lib.rs | wikipedia-wasm |
version | 0.1.1 |
source | src |
created_at | 2024-09-02 20:17:10.919424 |
updated_at | 2024-10-09 21:06:26.950168 |
description | Access wikipedia articles from Rust |
homepage | https://github.com/Nvt500/wikipedia-rs-wasm |
repository | https://github.com/Nvt500/wikipedia-rs-wasm |
max_upload_size | |
id | 1361016 |
size | 112,400 |
Access wikipedia articles from Rust.
This is an alteration of the crate wikipedia
to make it able to compile to
wasm and should still work for other platforms.
The only downsides are anything returning an iterator actually returns a custom iterator that can use an async next which means no for loops and that your program will be all async but if it is going to be in wasm it probably was going to be anyway.
Also, the four tests that this crate fails the original crate also fails.
use wikipedia_wasm::{Wikipedia, http};
#[tokio::main]
async fn main()
{
let wiki = Wikipedia::<http::default::Client>::default();
let page = wiki.page_from_title("World War II".to_string());
let content = page.get_content().await.unwrap();
assert!(content.starts_with("World War II or the Second World War (1 September 1939 – 2 September 1945)"));
}
The original crate used reqwest's blocking feature which cannot compile to wasm because of the internet's single thread nature or something like that.