pub enum Source {
Lan,
Wan,
}👎Deprecated:
Redesign in the future
Expand description
表示网络请求的源类型
Variants§
Implementations§
Source§impl Source
impl Source
pub fn as_str(&self) -> &'static str
Sourcepub fn is_match(&self, source: IpAddr) -> bool
pub fn is_match(&self, source: IpAddr) -> bool
判断IP地址是否匹配当前源类型
use dhttp_access::expr::atomics::Source;
let lan = Source::Lan;
let wan = Source::Wan;
// LAN 地址
assert!(lan.is_match("192.168.1.1".parse().unwrap()));
assert!(lan.is_match("10.0.0.1".parse().unwrap()));
assert!(lan.is_match("::1".parse().unwrap()));
// WAN 地址
assert!(wan.is_match("8.8.8.8".parse().unwrap()));
assert!(wan.is_match("2001:4860:4860::8888".parse().unwrap()));
// 交叉验证
assert!(!lan.is_match("8.8.8.8".parse().unwrap()));
assert!(!wan.is_match("192.168.1.1".parse().unwrap()));Trait Implementations§
impl Copy for Source
impl Eq for Source
impl StructuralPartialEq for Source
Auto Trait Implementations§
impl Freeze for Source
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnsafeUnpin for Source
impl UnwindSafe for Source
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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