pub enum VideoPlatform {
YouTube,
Facebook,
Vimeo,
DailyMotion,
Wistia,
}
Expand description
Supported video platforms
Variants§
Implementations§
Source§impl VideoPlatform
impl VideoPlatform
Sourcepub fn as_str(&self) -> &'static str
pub fn as_str(&self) -> &'static str
Get the platform name as a string
Examples found in repository?
examples/basic_usage.rs (line 25)
3fn main() {
4 let validator = VideoUrlValidator::new();
5
6 // Example URLs to test
7 let test_urls = [
8 "https://youtube.com/watch?v=dQw4w9WgXcQ",
9 "https://www.youtube.com/watch?v=abc123&t=30s",
10 "https://youtu.be/xyz789",
11 "https://vimeo.com/123456789",
12 "https://www.facebook.com/user/videos/987654321",
13 "https://dailymotion.com/video/x7abc123",
14 "https://dai.ly/x7def456",
15 "https://company.wistia.com/medias/abc123def456",
16 "https://invalid-url.com/video",
17 ];
18
19 println!("Video URL Validation Examples\n");
20 println!("{:-<60}", "");
21
22 for url in &test_urls {
23 match validator.validate_video_url(url) {
24 Some(platform) => {
25 println!("✅ {} -> {}", platform.as_str(), url);
26
27 // Show platform-specific validation
28 match platform {
29 VideoPlatform::YouTube => {
30 if let Some(id) = video_url_validator::extract_youtube_id(url) {
31 println!(" Video ID: {}", id);
32 }
33 }
34 VideoPlatform::Vimeo => {
35 if let Some(id) = video_url_validator::extract_vimeo_id(url) {
36 println!(" Video ID: {}", id);
37 }
38 }
39 _ => {}
40 }
41 }
42 None => {
43 println!("❌ Invalid/Unsupported -> {}", url);
44 }
45 }
46 println!();
47 }
48
49 // Demonstrate batch validation
50 println!("\nBatch Validation Results:");
51 println!("{:-<60}", "");
52
53 let results = validator.validate_multiple(&test_urls);
54 let valid_count = results
55 .iter()
56 .filter(|(_, platform)| platform.is_some())
57 .count();
58
59 println!("Total URLs: {}", results.len());
60 println!("Valid URLs: {}", valid_count);
61 println!("Invalid URLs: {}", results.len() - valid_count);
62
63 // Show supported platforms
64 println!("\nSupported Platforms:");
65 println!("{:-<60}", "");
66 for platform in validator.supported_platforms() {
67 println!("• {}", platform.as_str());
68 }
69}
Trait Implementations§
Source§impl Clone for VideoPlatform
impl Clone for VideoPlatform
Source§fn clone(&self) -> VideoPlatform
fn clone(&self) -> VideoPlatform
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for VideoPlatform
impl Debug for VideoPlatform
Source§impl Hash for VideoPlatform
impl Hash for VideoPlatform
Source§impl PartialEq for VideoPlatform
impl PartialEq for VideoPlatform
impl Eq for VideoPlatform
impl StructuralPartialEq for VideoPlatform
Auto Trait Implementations§
impl Freeze for VideoPlatform
impl RefUnwindSafe for VideoPlatform
impl Send for VideoPlatform
impl Sync for VideoPlatform
impl Unpin for VideoPlatform
impl UnwindSafe for VideoPlatform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more