Skip to main content

geminiomni_client/
lib.rs

1//! Lightweight helpers for Gemini Omni-style AI video generation workflows.
2//!
3//! This crate provides simple request, aspect-ratio, and metadata types for
4//! Rust applications that need to organize AI video generation prompts.
5
6#[cfg(feature = "serde")]
7use serde::{Deserialize, Serialize};
8
9/// Common video aspect ratios.
10#[derive(Debug, Clone, PartialEq, Eq)]
11#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
12pub enum AspectRatio {
13    /// 16:9 widescreen video.
14    Widescreen,
15    /// 9:16 vertical video for short-form platforms.
16    Vertical,
17    /// 1:1 square video.
18    Square,
19    /// Custom aspect ratio, such as "4:3" or "21:9".
20    Custom(String),
21}
22
23/// A structured request for an AI video generation workflow.
24#[derive(Debug, Clone, PartialEq, Eq)]
25#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
26pub struct VideoRequest {
27    /// Main text prompt.
28    pub prompt: String,
29    /// Desired aspect ratio.
30    pub aspect_ratio: AspectRatio,
31    /// Duration in seconds.
32    pub duration_seconds: u32,
33    /// Optional negative prompt.
34    pub negative_prompt: Option<String>,
35    /// Optional model name or provider identifier.
36    pub model: Option<String>,
37}
38
39impl VideoRequest {
40    /// Creates a new video request with sensible defaults.
41    pub fn new(prompt: impl Into<String>) -> Self {
42        Self {
43            prompt: prompt.into(),
44            aspect_ratio: AspectRatio::Widescreen,
45            duration_seconds: 8,
46            negative_prompt: None,
47            model: None,
48        }
49    }
50
51    /// Sets the aspect ratio.
52    pub fn aspect_ratio(mut self, aspect_ratio: AspectRatio) -> Self {
53        self.aspect_ratio = aspect_ratio;
54        self
55    }
56
57    /// Sets the duration in seconds.
58    pub fn duration_seconds(mut self, seconds: u32) -> Self {
59        self.duration_seconds = seconds;
60        self
61    }
62
63    /// Sets a negative prompt.
64    pub fn negative_prompt(mut self, prompt: impl Into<String>) -> Self {
65        self.negative_prompt = Some(prompt.into());
66        self
67    }
68
69    /// Sets a model identifier.
70    pub fn model(mut self, model: impl Into<String>) -> Self {
71        self.model = Some(model.into());
72        self
73    }
74}
75
76#[cfg(test)]
77mod tests {
78    use super::*;
79
80    #[test]
81    fn creates_default_video_request() {
82        let request = VideoRequest::new("A cinematic city scene");
83
84        assert_eq!(request.duration_seconds, 8);
85        assert_eq!(request.aspect_ratio, AspectRatio::Widescreen);
86    }
87
88    #[test]
89    fn updates_video_request_fields() {
90        let request = VideoRequest::new("A product video")
91            .aspect_ratio(AspectRatio::Vertical)
92            .duration_seconds(12)
93            .negative_prompt("blurry")
94            .model("gemini-omni");
95
96        assert_eq!(request.duration_seconds, 12);
97        assert_eq!(request.aspect_ratio, AspectRatio::Vertical);
98        assert_eq!(request.negative_prompt, Some("blurry".to_string()));
99        assert_eq!(request.model, Some("gemini-omni".to_string()));
100    }
101}