pub struct ValidatedQuery { /* private fields */ }Expand description
Unified validated query that auto-detects domain vs IP address
This type automatically determines whether the input is a domain name or an IP address and validates it accordingly.
§Examples
use whois_service::ValidatedQuery;
// Domain detection
let query = ValidatedQuery::new("example.com").unwrap();
assert!(query.is_domain());
// IPv4 detection
let query = ValidatedQuery::new("8.8.8.8").unwrap();
assert!(query.is_ip());
// IPv6 detection
let query = ValidatedQuery::new("2001:4860:4860::8888").unwrap();
assert!(query.is_ip());Implementations§
Source§impl ValidatedQuery
impl ValidatedQuery
Sourcepub fn new(input: impl Into<String>) -> Result<Self, WhoisError>
pub fn new(input: impl Into<String>) -> Result<Self, WhoisError>
Automatically detect whether input is domain or IP address and validate it
This function tries to parse the input as an IP address first (faster validation), then falls back to domain validation if IP parsing fails.
§Errors
Returns an error if the input is neither a valid IP address nor a valid domain name.
Sourcepub fn query_type(&self) -> &DetectedQueryType
pub fn query_type(&self) -> &DetectedQueryType
Get the query type (domain or IP)
Sourcepub fn into_inner(self) -> String
pub fn into_inner(self) -> String
Consume and return the inner string
Trait Implementations§
Source§impl AsRef<str> for ValidatedQuery
impl AsRef<str> for ValidatedQuery
Source§impl Clone for ValidatedQuery
impl Clone for ValidatedQuery
Source§fn clone(&self) -> ValidatedQuery
fn clone(&self) -> ValidatedQuery
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 ValidatedQuery
impl Debug for ValidatedQuery
Auto Trait Implementations§
impl Freeze for ValidatedQuery
impl RefUnwindSafe for ValidatedQuery
impl Send for ValidatedQuery
impl Sync for ValidatedQuery
impl Unpin for ValidatedQuery
impl UnwindSafe for ValidatedQuery
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