feat(rpc): add query methods to ActiveFilters (#22275)

Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Matthias Seitz
2026-02-17 15:37:04 +01:00
committed by GitHub
parent 61038449c8
commit e89bf483bc

View File

@@ -759,6 +759,26 @@ impl<T> ActiveFilters<T> {
pub fn new() -> Self {
Self { inner: Arc::new(Mutex::new(HashMap::default())) }
}
/// Returns `true` if a filter with the given id exists.
pub async fn contains(&self, id: &FilterId) -> bool {
self.inner.lock().await.contains_key(id)
}
/// Returns the number of currently active filters.
pub async fn len(&self) -> usize {
self.inner.lock().await.len()
}
/// Returns `true` if there are no active filters.
pub async fn is_empty(&self) -> bool {
self.inner.lock().await.is_empty()
}
/// Returns all active filter ids.
pub async fn ids(&self) -> Vec<FilterId> {
self.inner.lock().await.keys().cloned().collect()
}
}
/// An installed filter