#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum AspectRatio {
Widescreen,
Vertical,
Square,
Custom(String),
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct VideoRequest {
pub prompt: String,
pub aspect_ratio: AspectRatio,
pub duration_seconds: u32,
pub negative_prompt: Option<String>,
pub model: Option<String>,
}
impl VideoRequest {
pub fn new(prompt: impl Into<String>) -> Self {
Self {
prompt: prompt.into(),
aspect_ratio: AspectRatio::Widescreen,
duration_seconds: 8,
negative_prompt: None,
model: None,
}
}
pub fn aspect_ratio(mut self, aspect_ratio: AspectRatio) -> Self {
self.aspect_ratio = aspect_ratio;
self
}
pub fn duration_seconds(mut self, seconds: u32) -> Self {
self.duration_seconds = seconds;
self
}
pub fn negative_prompt(mut self, prompt: impl Into<String>) -> Self {
self.negative_prompt = Some(prompt.into());
self
}
pub fn model(mut self, model: impl Into<String>) -> Self {
self.model = Some(model.into());
self
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn creates_default_video_request() {
let request = VideoRequest::new("A cinematic city scene");
assert_eq!(request.duration_seconds, 8);
assert_eq!(request.aspect_ratio, AspectRatio::Widescreen);
}
#[test]
fn updates_video_request_fields() {
let request = VideoRequest::new("A product video")
.aspect_ratio(AspectRatio::Vertical)
.duration_seconds(12)
.negative_prompt("blurry")
.model("gemini-omni");
assert_eq!(request.duration_seconds, 12);
assert_eq!(request.aspect_ratio, AspectRatio::Vertical);
assert_eq!(request.negative_prompt, Some("blurry".to_string()));
assert_eq!(request.model, Some("gemini-omni".to_string()));
}
}