Struct metrics_util::MetricKindMask
source · pub struct MetricKindMask(/* private fields */);
Expand description
Metric kind mask.
Useful for matching against a kind, or kinds, of metrics.
In order to use for defining multiple metric kinds, can be used in a bitmask fashion, as this
type implements bitwise OR support, and checking for inclusion of a specific kind within another
kind value can be checked via matches
:
// Let's only match counters and histograms:
let mask = MetricKindMask::COUNTER | MetricKindMask::HISTOGRAM;
// And check to see if the kinds we have matches our mask:
assert!(!mask.matches(MetricKind::Gauge));
assert!(mask.matches(MetricKind::Counter));
// There's even two handy versions to avoid extra typing:
let none_mask = MetricKindMask::NONE;
let all_mask = MetricKindMask::ALL;
assert!(!none_mask.matches(MetricKind::Counter));
assert!(!none_mask.matches(MetricKind::Gauge));
assert!(!none_mask.matches(MetricKind::Histogram));
assert!(all_mask.matches(MetricKind::Counter));
assert!(all_mask.matches(MetricKind::Gauge));
assert!(all_mask.matches(MetricKind::Histogram));
Implementations§
source§impl MetricKindMask
impl MetricKindMask
sourcepub const NONE: MetricKindMask = _
pub const NONE: MetricKindMask = _
No metric kinds.
sourcepub const COUNTER: MetricKindMask = _
pub const COUNTER: MetricKindMask = _
The counter kind.
sourcepub const GAUGE: MetricKindMask = _
pub const GAUGE: MetricKindMask = _
The gauge kind.
sourcepub const HISTOGRAM: MetricKindMask = _
pub const HISTOGRAM: MetricKindMask = _
The histogram kind.
sourcepub const ALL: MetricKindMask = _
pub const ALL: MetricKindMask = _
All metric kinds.
sourcepub fn matches(&self, kind: MetricKind) -> bool
pub fn matches(&self, kind: MetricKind) -> bool
Whether or not this metric kind contains the specified kind.
Trait Implementations§
source§impl BitOr for MetricKindMask
impl BitOr for MetricKindMask
source§impl Clone for MetricKindMask
impl Clone for MetricKindMask
source§fn clone(&self) -> MetricKindMask
fn clone(&self) -> MetricKindMask
Returns a copy 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 MetricKindMask
impl Debug for MetricKindMask
source§impl Hash for MetricKindMask
impl Hash for MetricKindMask
source§impl Ord for MetricKindMask
impl Ord for MetricKindMask
source§fn cmp(&self, other: &MetricKindMask) -> Ordering
fn cmp(&self, other: &MetricKindMask) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for MetricKindMask
impl PartialEq for MetricKindMask
source§fn eq(&self, other: &MetricKindMask) -> bool
fn eq(&self, other: &MetricKindMask) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for MetricKindMask
impl PartialOrd for MetricKindMask
source§fn partial_cmp(&self, other: &MetricKindMask) -> Option<Ordering>
fn partial_cmp(&self, other: &MetricKindMask) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for MetricKindMask
impl Eq for MetricKindMask
impl StructuralEq for MetricKindMask
impl StructuralPartialEq for MetricKindMask
Auto Trait Implementations§
impl RefUnwindSafe for MetricKindMask
impl Send for MetricKindMask
impl Sync for MetricKindMask
impl Unpin for MetricKindMask
impl UnwindSafe for MetricKindMask
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