tauri_plugin_video_thumbnail/models.rs
1use serde::{Deserialize, Serialize};
2
3/// Size of the generated thumbnail
4#[derive(Debug, Clone, Copy, Deserialize, Serialize, Default)]
5#[serde(rename_all = "lowercase")]
6pub enum ThumbnailSize {
7 /// 32x32 pixels
8 Small,
9 /// 64x64 pixels
10 #[default]
11 Medium,
12 /// 128x128 pixels
13 Large,
14 /// Custom dimensions
15 Custom { width: u32, height: u32 },
16}
17
18/// Request to generate a thumbnail from a video
19#[derive(Debug, Deserialize, Serialize)]
20#[serde(rename_all = "camelCase")]
21pub struct ThumbnailRequest {
22 /// Video URL (http/https) or local file path
23 pub source: String,
24 /// Optional thumbnail size (defaults to Medium)
25 pub size: Option<ThumbnailSize>,
26 /// Optional output path. If not provided, returns base64 encoded image
27 pub output_path: Option<String>,
28}
29
30/// Response containing the generated thumbnail
31#[derive(Debug, Clone, Deserialize, Serialize)]
32#[serde(rename_all = "camelCase")]
33pub struct ThumbnailResponse {
34 /// Base64 encoded PNG image data (if output_path was not specified)
35 pub base64: Option<String>,
36 /// Path to the saved thumbnail file (if output_path was specified)
37 pub path: Option<String>,
38 /// Width of the generated thumbnail
39 pub width: u32,
40 /// Height of the generated thumbnail
41 pub height: u32,
42}