pub enum CidrError {
InvalidFormat(String),
InvalidIpAddress(String),
InvalidPrefixLength(String),
IpVersionMismatch,
}Expand description
Represents error types that can occur during CIDR operations.
This enum provides detailed error variants for invalid CIDR formats, IP address issues, and prefix length validation.
§Examples
use gooty_proxy::definitions::errors::CidrError;
let error = CidrError::InvalidFormat("Invalid CIDR".to_string());
println!("Error: {}", error);Variants§
InvalidFormat(String)
Indicates that the provided CIDR string does not follow the correct format.
The format should be IP_ADDRESS/PREFIX_LENGTH, such as “192.168.1.0/24”.
InvalidIpAddress(String)
Indicates that the IP address portion of a CIDR string is not valid.
The IP address should be a valid IPv4 or IPv6 address.
InvalidPrefixLength(String)
Indicates that the prefix length portion of a CIDR string is not valid.
For IPv4, the prefix length should be between 0 and 32. For IPv6, the prefix length should be between 0 and 128.
IpVersionMismatch
Indicates that there’s a mismatch between the IP version and the context.
This typically occurs when trying to use an IPv4 address in an IPv6 context or vice versa.
Trait Implementations§
Source§impl Error for CidrError
impl Error for CidrError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()