pub trait Trust {
// Required method
fn is_trusted(&self, addr: IpAddr) -> bool;
}Expand description
Decides whether an address belongs to a proxy you trust.
Implemented for every Fn(IpAddr) -> bool; a deployment’s CIDR sets
(net-io, bouncer-io configuration) implement it directly.
§Examples
use core::net::IpAddr;
use parse_net::Trust;
struct Loopback;
impl Trust for Loopback {
fn is_trusted(&self, addr: IpAddr) -> bool { addr.is_loopback() }
}
assert!(Loopback.is_trusted("127.0.0.1".parse()?));
let proxy: IpAddr = "10.0.0.2".parse()?;
assert!(!(|a: IpAddr| a == proxy).is_trusted("192.0.2.1".parse()?));Required Methods§
Sourcefn is_trusted(&self, addr: IpAddr) -> bool
fn is_trusted(&self, addr: IpAddr) -> bool
Whether addr is a trusted proxy.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".