ai_twerk_video_generator/
lib.rs1const BASE_URL: &str = "https://supermaker.ai/video/ai-twerk-video-generator/";
6
7#[derive(Debug)]
10pub struct VideoRequest {
11 pub model_id: String,
12 pub animation_type: String,
13 pub duration_seconds: u32,
14}
15
16impl VideoRequest {
17 pub fn new(model_id: String, animation_type: String, duration_seconds: u32) -> Self {
19 VideoRequest {
20 model_id,
21 animation_type,
22 duration_seconds,
23 }
24 }
25}
26
27pub fn generate_video_id(request: &VideoRequest) -> String {
30 let combined_string = format!(
31 "{}-{}-{}",
32 request.model_id, request.animation_type, request.duration_seconds
33 );
34 let hash = combined_string.chars().fold(5381, |acc, c| ((acc << 5) + acc) + c as u32);
36 format!("video_{:x}", hash)
37}
38
39pub fn get_video_status(video_id: &str) -> Option<String> {
42 if video_id.starts_with("video_") {
44 Some("Processing".to_string()) } else {
46 None }
48}
49
50pub fn get_endpoint(path: &str) -> String {
52 let mut url = BASE_URL.to_string();
53 url.push_str(path);
54 url
55}
56
57#[cfg(test)]
58mod tests {
59 use super::*;
60
61 #[test]
62 fn test_generate_video_id() {
63 let request = VideoRequest::new("model_123".to_string(), "twerk_dance".to_string(), 30);
64 let video_id = generate_video_id(&request);
65 assert!(video_id.starts_with("video_"));
66 }
67
68 #[test]
69 fn test_get_video_status() {
70 let status = get_video_status("video_12345678");
71 assert_eq!(status, Some("Processing".to_string()));
72
73 let status = get_video_status("invalid_id");
74 assert_eq!(status, None);
75 }
76
77 #[test]
78 fn test_get_endpoint() {
79 let endpoint = get_endpoint("generate");
80 assert_eq!(endpoint, "https://supermaker.ai/video/ai-twerk-video-generator/generate");
81 }
82}