pub struct VideoUrlValidator { /* private fields */ }Expand description
Main validator struct for video URLs
Implementations§
Source§impl VideoUrlValidator
impl VideoUrlValidator
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new VideoUrlValidator instance
Examples found in repository?
examples/basic_usage.rs (line 4)
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}Sourcepub fn validate_youtube_video_url(&self, url: &str) -> bool
pub fn validate_youtube_video_url(&self, url: &str) -> bool
Validate a YouTube video URL
Sourcepub fn validate_facebook_video_url(&self, url: &str) -> bool
pub fn validate_facebook_video_url(&self, url: &str) -> bool
Validate a Facebook video URL
Sourcepub fn validate_vimeo_video_url(&self, url: &str) -> bool
pub fn validate_vimeo_video_url(&self, url: &str) -> bool
Validate a Vimeo video URL
Sourcepub fn validate_dailymotion_video_url(&self, url: &str) -> bool
pub fn validate_dailymotion_video_url(&self, url: &str) -> bool
Validate a DailyMotion video URL
Sourcepub fn validate_wistia_video_url(&self, url: &str) -> bool
pub fn validate_wistia_video_url(&self, url: &str) -> bool
Validate a Wistia video URL
Sourcepub fn validate_video_url(&self, url: &str) -> Option<VideoPlatform>
pub fn validate_video_url(&self, url: &str) -> Option<VideoPlatform>
Validate any video URL and return the detected platform
Examples found in repository?
examples/basic_usage.rs (line 23)
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}Sourcepub fn is_valid_video_url(&self, url: &str) -> bool
pub fn is_valid_video_url(&self, url: &str) -> bool
Check if a URL is a valid video URL from any supported platform
Sourcepub fn supported_platforms(&self) -> Vec<VideoPlatform>
pub fn supported_platforms(&self) -> Vec<VideoPlatform>
Get all supported platforms
Examples found in repository?
examples/basic_usage.rs (line 66)
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}Sourcepub fn validate_multiple(
&self,
urls: &[&str],
) -> Vec<(String, Option<VideoPlatform>)>
pub fn validate_multiple( &self, urls: &[&str], ) -> Vec<(String, Option<VideoPlatform>)>
Validate multiple URLs at once
Examples found in repository?
examples/basic_usage.rs (line 53)
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§
Auto Trait Implementations§
impl Freeze for VideoUrlValidator
impl RefUnwindSafe for VideoUrlValidator
impl Send for VideoUrlValidator
impl Sync for VideoUrlValidator
impl Unpin for VideoUrlValidator
impl UnwindSafe for VideoUrlValidator
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