Skip to main content

wikimedia_api/endpoints/
search.rs

1use serde::{Deserialize, Serialize};
2
3// Wikimedia SearchResult object: https://api.wikimedia.org/wiki/Core_REST_API/Reference/Search/Search_result_object
4#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
5pub struct SearchResult {
6    pub id: usize,     // Page identifier
7    pub key: String,   // Page title in URL-friendly format
8    pub title: String, // Page title in reading-friendly format
9    /* For search content endpoint:
10    A few lines giving a sample of page content with search terms highlighted with <span class=\"searchmatch\"> tags. Excerpts may end mid-sentence.
11    For search titles endpoint:
12    Page title in reading-friendly format */
13    pub excerpt: String,
14    /* Title of the page redirected from, if the search term matched a redirect page, or null if search term did not match a redirect page */
15    pub matched_title: Option<String>,
16    pub description: Option<String>, // Short summary of the page or null if no description exists
17    pub thumbnail: Option<ThumbNailFormat>, // Reduced-size version of the page's lead image or null if no lead image exists
18}
19
20#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
21pub struct ThumbNailFormat {
22    pub mimetype: String,        // Media type for the image. For example: image/jpeg
23    pub size: Option<usize>,     // File size in bytes or null if not available
24    pub width: Option<usize>, // Maximum recommended image width in pixels or null if not available
25    pub height: Option<usize>, // Maximum recommended image height in pixels or null if not available
26    pub duration: Option<usize>, // Length of the video, audio, or multimedia file or null for other media types
27    pub url: String,             // URL to download the file
28}