1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use super::Validator;
use url::{Host, ParseError};

/// A validator for the hostname of a URL.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct HostnameValidator;

impl Validator<str> for HostnameValidator {
    type Error = ParseError;

    #[inline]
    fn validate(&self, data: &str) -> Result<(), Self::Error> {
        Host::parse(data)?;
        Ok(())
    }
}