pub struct BlocklistCache { /* private fields */ }Expand description
High-performance blocklist cache with O(1) lookups.
Uses DashMap for lock-free concurrent access.
Implementations§
Source§impl BlocklistCache
impl BlocklistCache
Sourcepub fn is_ip_blocked(&self, ip: &str) -> bool
pub fn is_ip_blocked(&self, ip: &str) -> bool
Check if an IP is blocked.
This is an O(1) lookup.
Sourcepub fn is_fingerprint_blocked(&self, fingerprint: &str) -> bool
pub fn is_fingerprint_blocked(&self, fingerprint: &str) -> bool
Check if a fingerprint is blocked.
This is an O(1) lookup.
Sourcepub fn is_blocked(&self, ip: Option<&str>, fingerprint: Option<&str>) -> bool
pub fn is_blocked(&self, ip: Option<&str>, fingerprint: Option<&str>) -> bool
Check if either IP or fingerprint is blocked.
Sourcepub fn get_ip(&self, ip: &str) -> Option<BlocklistEntry>
pub fn get_ip(&self, ip: &str) -> Option<BlocklistEntry>
Get an IP block entry.
Sourcepub fn get_fingerprint(&self, fingerprint: &str) -> Option<BlocklistEntry>
pub fn get_fingerprint(&self, fingerprint: &str) -> Option<BlocklistEntry>
Get a fingerprint block entry.
Sourcepub fn add(&self, entry: BlocklistEntry)
pub fn add(&self, entry: BlocklistEntry)
Add a blocklist entry.
Sourcepub fn load_snapshot(&self, entries: Vec<BlocklistEntry>, sequence_id: u64)
pub fn load_snapshot(&self, entries: Vec<BlocklistEntry>, sequence_id: u64)
Load a full blocklist snapshot from the hub.
Sourcepub fn apply_updates(&self, updates: Vec<BlocklistUpdate>, sequence_id: u64)
pub fn apply_updates(&self, updates: Vec<BlocklistUpdate>, sequence_id: u64)
Apply incremental updates from the hub.
Sourcepub fn fingerprint_count(&self) -> usize
pub fn fingerprint_count(&self) -> usize
Get the fingerprint blocklist size.
Sourcepub fn sequence_id(&self) -> u64
pub fn sequence_id(&self) -> u64
Get the current sequence ID.
Sourcepub fn all_ips(&self) -> Vec<BlocklistEntry>
pub fn all_ips(&self) -> Vec<BlocklistEntry>
Get all IP entries.
Sourcepub fn all_fingerprints(&self) -> Vec<BlocklistEntry>
pub fn all_fingerprints(&self) -> Vec<BlocklistEntry>
Get all fingerprint entries.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BlocklistCache
impl !RefUnwindSafe for BlocklistCache
impl Send for BlocklistCache
impl Sync for BlocklistCache
impl Unpin for BlocklistCache
impl UnsafeUnpin for BlocklistCache
impl UnwindSafe for BlocklistCache
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more