pub struct CompressedAccountFilterSet { /* private fields */ }Expand description
Safe builder for cuckoo filters sent in subscribe requests.
Holds two parallel collections: a HashSet (exact source of truth for contains/len
and the guard for writes) and a CuckooFilter (compact wire form). Writes go to both;
serialization reads the filter. Strictly safer than a raw CuckooFilter, whose remove
can silently evict the wrong fingerprint-colliding item.
Implementations§
Source§impl CompressedAccountFilterSet
impl CompressedAccountFilterSet
Sourcepub fn with_capacity(
max_capacity: usize,
) -> Result<CompressedAccountFilterSet, CuckooBuildError>
pub fn with_capacity( max_capacity: usize, ) -> Result<CompressedAccountFilterSet, CuckooBuildError>
Empty map pre-sized for max_capacity items (both the HashSet and filter are
allocated up front). Errors CuckooBuildError::CapacityOverflow if it can’t be allocated.
Sourcepub fn insert(&mut self, key: Address) -> Result<bool, TableFullError>
pub fn insert(&mut self, key: Address) -> Result<bool, TableFullError>
Inserts a key. Ok(true) if newly added, Ok(false) if already present (idempotent).
Errors TableFullError if the filter is saturated (map under-sized); state is
unchanged on error.
Sourcepub fn remove(&mut self, key: Address) -> bool
pub fn remove(&mut self, key: Address) -> bool
Removes a key; returns whether it was present. Safe unlike CuckooFilter::remove:
checks the HashSet first and only touches the filter when the key genuinely exists.
Sourcepub fn contains(&self, key: Address) -> bool
pub fn contains(&self, key: Address) -> bool
Exact membership (from the HashSet, no false positives), unlike CuckooFilter::contains.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Items the map can hold without reallocating (≥ the with_capacity argument; the
HashSet rounds up). Useful for headroom checks before a batch of inserts.
Sourcepub fn iter(&self) -> impl Iterator<Item = &[u8; 32]>
pub fn iter(&self) -> impl Iterator<Item = &[u8; 32]>
Iterates items in arbitrary HashSet order (no ordering guarantee).
Sourcepub const fn is_dirty(&self) -> bool
pub const fn is_dirty(&self) -> bool
true if mutated since the last take_dirty (or construction);
does not clear the flag.
Sourcepub fn take_dirty(&mut self) -> bool
pub fn take_dirty(&mut self) -> bool
Returns the dirty flag and clears it. Call when transmitting: true → rebuild and send.
Sourcepub fn to_proto(&self) -> CuckooFilter
pub fn to_proto(&self) -> CuckooFilter
Serializes the cuckoo filter to proto wire format (carries bucket geometry + hash seed).
Sourcepub fn to_account_filter(&self) -> SubscribeRequestFilterAccounts
pub fn to_account_filter(&self) -> SubscribeRequestFilterAccounts
A SubscribeRequestFilterAccounts carrying only this cuckoo filter (no account list,
owner, or predicates) — add it to a request under a name of your choosing.
Sourcepub fn insert_into_subscribe_request(
&mut self,
req: &mut SubscribeRequest,
name: &str,
)
pub fn insert_into_subscribe_request( &mut self, req: &mut SubscribeRequest, name: &str, )
Inserts this filter into req.accounts under name (replacing any existing entry,
preserving others) and marks the map clean.
Auto Trait Implementations§
impl Freeze for CompressedAccountFilterSet
impl RefUnwindSafe for CompressedAccountFilterSet
impl Send for CompressedAccountFilterSet
impl Sync for CompressedAccountFilterSet
impl Unpin for CompressedAccountFilterSet
impl UnsafeUnpin for CompressedAccountFilterSet
impl UnwindSafe for CompressedAccountFilterSet
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request