pub struct QuotaViolationError { /* private fields */ }Expand description
Raised when a sensor records a value that takes a metric outside the bounds configured as its quota.
Corresponds to Java’s QuotaViolationException. It has no entry in Errors,
so it carries no protocol code.
Java extends chain:
QuotaViolationException -> KafkaException
Hand-written rather than declared with kafka_error_type! because it adds
subclass state (the metric, the recorded value and the bound) and overrides
toString() instead of taking the generated
"<TypeName>: <message>" form.
Two deliberate deviations from the Java class:
- Java holds the
KafkaMetricitself and exposes it asmetric(). This holds the metric’sMetricName, becauseKafkaMetricowns aBox<dyn Measurable>and so is neitherClonenorDebug— both of whichErrorrequires. Nothing is lost for a client: Java’s owntoString()uses onlymetric.metricName(), and the client has no caller ofmetric()(the broker’sClientQuotaManageris the only one in the Kafka tree). - Java overrides
fillInStackTrace()to skip capturing a stack trace, since quota violations are frequent and the trace is never read. Rust errors do not capture one at all, so there is nothing to suppress.
Implementations§
Source§impl QuotaViolationError
impl QuotaViolationError
Sourcepub fn new(metric_name: MetricName, value: f64, bound: f64) -> Self
pub fn new(metric_name: MetricName, value: f64, bound: f64) -> Self
Create the error, mirroring Java’s
QuotaViolationException(KafkaMetric metric, double value, double bound).
Sourcepub fn metric_name(&self) -> &MetricName
pub fn metric_name(&self) -> &MetricName
The name of the metric that violated its quota.
Stands in for Java’s metric() — see the type-level note.
Trait Implementations§
Source§impl Clone for QuotaViolationError
impl Clone for QuotaViolationError
Source§fn clone(&self) -> QuotaViolationError
fn clone(&self) -> QuotaViolationError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QuotaViolationError
impl Debug for QuotaViolationError
Source§impl Display for QuotaViolationError
impl Display for QuotaViolationError
Source§impl Error for QuotaViolationError
impl Error for QuotaViolationError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for QuotaViolationError
impl RefUnwindSafe for QuotaViolationError
impl Send for QuotaViolationError
impl Sync for QuotaViolationError
impl Unpin for QuotaViolationError
impl UnsafeUnpin for QuotaViolationError
impl UnwindSafe for QuotaViolationError
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