pub struct Wikipedia<A: HttpClient> {
pub client: A,
pub pre_language_url: String,
pub post_language_url: String,
pub language: String,
pub search_results: u32,
pub images_results: String,
pub links_results: String,
pub categories_results: String,
}Fields§
§client: AHttpClient struct.
pre_language_url: StringUrl is created by concatenating pre_language_url + language + post_language_url.
post_language_url: String§language: String§search_results: u32Number of results to fetch when searching.
images_results: StringNumber of images to fetch in each request when calling get_images.
The iterator will go through all of them, fetching pages of this size.
It can be the string “max” to fetch as many as possible on every request.
links_results: StringLike images_results, for links and references.
categories_results: StringLike images_results, for categories.
Implementations§
Source§impl<A: HttpClient> Wikipedia<A>
impl<A: HttpClient> Wikipedia<A>
Sourcepub fn new(client: A) -> Self
pub fn new(client: A) -> Self
Creates a new object using the provided client and default values.
Sourcepub async fn get_languages(&self) -> Result<Vec<(String, String)>>
pub async fn get_languages(&self) -> Result<Vec<(String, String)>>
Returns a list of languages in the form of (identifier, language),
for example [(“en”, “English”), (“es”, “Español”)]
Sourcepub fn set_base_url(&mut self, base_url: &str)
pub fn set_base_url(&mut self, base_url: &str)
Updates the url format. The substring {language} will be replaced
with the selected language.
Sourcepub async fn search(&self, query: &str) -> Result<Vec<String>>
pub async fn search(&self, query: &str) -> Result<Vec<String>>
Searches for a string and returns a list of relevant page titles.
§Examples
extern crate wikipedia_wasm;
let wiki = wikipedia_wasm::Wikipedia::<wikipedia_wasm::http::default::Client>::default();
let results = wiki.search("keyboard").unwrap();
assert!(results.contains(&"Computer keyboard".to_owned()));Sourcepub async fn geosearch(
&self,
latitude: f64,
longitude: f64,
radius: u16,
) -> Result<Vec<String>>
pub async fn geosearch( &self, latitude: f64, longitude: f64, radius: u16, ) -> Result<Vec<String>>
Search articles within radius meters of latitude and longitude.
§Examples
extern crate wikipedia_wasm;
let wiki = wikipedia_wasm::Wikipedia::<wikipedia_wasm::http::default::Client>::default();
let results = wiki.geosearch(40.750556,-73.993611, 20).unwrap();
assert!(results.contains(&"Madison Square Garden".to_owned()));Sourcepub async fn random_count(&self, count: u8) -> Result<Vec<String>>
pub async fn random_count(&self, count: u8) -> Result<Vec<String>>
Fetches count random articles’ title.
Sourcepub fn page_from_title<'a>(&'a self, title: String) -> Page<'a, A>
pub fn page_from_title<'a>(&'a self, title: String) -> Page<'a, A>
Creates a new Page given a title.
Sourcepub fn page_from_pageid<'a>(&'a self, pageid: String) -> Page<'a, A>
pub fn page_from_pageid<'a>(&'a self, pageid: String) -> Page<'a, A>
Creates a new Page given a pageid.