#[non_exhaustive]pub enum Error {
InvalidParameter {
param: &'static str,
reason: &'static str,
},
IncompatibleParameters,
CapacityExceeded,
}Expand description
Errors returned by fallible operations across the crate.
Every constructor that accepts tuning parameters validates them and returns
Error::InvalidParameter rather than panicking. Operations that combine
two structures (for example BloomFilter::merge)
return Error::IncompatibleParameters when the operands were not built
with the same dimensions. A Cuckoo filter returns Error::CapacityExceeded
when an insertion cannot find a free slot after exhausting its relocation
budget.
The enum is #[non_exhaustive]: matching on it must include a wildcard arm
so that future variants do not break downstream code.
§Examples
use bloom_lib::Error;
let err = Error::InvalidParameter {
param: "rate",
reason: "must be in (0.0, 1.0)",
};
assert_eq!(err.to_string(), "invalid parameter `rate`: must be in (0.0, 1.0)");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidParameter
A tuning parameter fell outside its valid range.
param names the offending argument; reason states the constraint it
violated. Both are static strings so the variant stays allocation-free
and usable on no_std targets.
Fields
IncompatibleParameters
Two structures could not be combined because their parameters differ.
Merging, intersecting, or comparing two probabilistic structures only has a defined meaning when both were constructed with identical dimensions (bit count, hash count, register precision, and so on).
CapacityExceeded
An insertion failed because the structure is full.
Returned by CuckooFilter::insert when no
free slot is found within the relocation budget. It signals that the
filter has reached its practical load limit; create a larger filter.
Trait Implementations§
Source§impl Error for Error
Available on crate feature std only.
impl Error for Error
std only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()