saluki_metrics/lib.rs
1//! Metrics-related helpers and utilities.
2#![deny(warnings)]
3#![deny(missing_docs)]
4
5mod builder;
6
7pub use self::builder::{MetricTag, MetricsBuilder};
8
9mod macros;
10
11#[cfg(feature = "test")]
12pub mod test;
13
14#[doc(hidden)]
15pub mod reexport {
16 pub use ::metrics;
17 pub use paste::paste;
18}
19
20/// A type that can be converted into a `SharedString`.
21///
22/// This is a blanket trait used to generically support converting any type which already supports conversion to
23/// `String` into a `SharedString`. This is purely used by the `static_metrics!` macro to allow for ergonomic handling
24/// of labels, and should generally not need to be implemented manually.
25pub trait Stringable {
26 /// Converts the given value to a `SharedString`.
27 fn to_shared_string(&self) -> ::metrics::SharedString;
28}
29
30impl<T> Stringable for T
31where
32 T: std::fmt::Display,
33{
34 fn to_shared_string(&self) -> ::metrics::SharedString {
35 std::string::ToString::to_string(&self).into()
36 }
37}