Skip to main content

wikimedia_api/endpoints/
file.rs

1use serde::{Deserialize, Serialize};
2
3// Wikimedia File object: https://api.wikimedia.org/wiki/Core_REST_API/Reference/Media_files/File_object
4#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
5pub struct File {
6    pub title: String,                // File title
7    pub file_description_url: String, // URL for the page describing the file, including license information and other metadata
8    pub latest: FileLatest, // Object containing information about the latest revision to the file
9    pub preferred: FileFormat, // Information about the file's preferred preview format
10    pub original: FileFormat, // Information about the file's original format
11    // Get file only:
12    pub thumbnail: Option<FileFormat>, // Information about the file's thumbnail format
13}
14
15#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
16pub struct FileLatest {
17    pub timestamp: String, // Timestamp of the latest revision in ISO 8601 format
18    pub user: FileUser,    // Object containing information about the user who uploaded the file
19}
20
21#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
22pub struct FileUser {
23    id: usize,    // User identifier
24    name: String, // Username
25}
26
27#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
28pub struct FileFormat {
29    pub mediatype: String, // File type, one of: BITMAP, DRAWING, AUDIO, VIDEO, MULTIMEDIA, UNKNOWN, OFFICE, TEXT, EXECUTABLE, ARCHIVE, or 3D
30    pub size: Option<usize>, // File size in bytes or null if not available
31    pub width: Option<usize>, // Maximum recommended image width in pixels or null if not available
32    pub height: Option<usize>, // Maximum recommended image height in pixels or null if not available
33    pub duration: Option<usize>, // Length of the video, audio, or multimedia file or null for other media types
34    pub url: String,             // URL to download the file
35}