pub struct Sample {
pub metric: String,
pub at: Timestamp,
pub value: f64,
pub kind: Kind,
}Expand description
One measurement of one metric at one instant.
Build one with Sample::new, which refuses a non-finite value. The
fields are public, so a caller can also write a Sample literal directly;
in that case the finite-value check is the caller’s to have done.
Fields§
§metric: StringThe metric this sample belongs to.
at: TimestampSeconds since the Unix epoch.
value: f64The measured value.
kind: KindHow this sample aggregates.
Implementations§
Source§impl Sample
impl Sample
Sourcepub fn new(
metric: impl Into<String>,
at: Timestamp,
value: f64,
kind: Kind,
) -> Option<Self>
pub fn new( metric: impl Into<String>, at: Timestamp, value: f64, kind: Kind, ) -> Option<Self>
One sample. Refuses a non-finite value.
use interval_align::{Kind, Sample};
let sample = Sample::new("hall.kw", 1_772_949_600, 100.0, Kind::Power);
assert!(sample.is_some());
assert!(Sample::new("hall.kw", 1_772_949_600, f64::NAN, Kind::Power).is_none());Trait Implementations§
impl StructuralPartialEq for Sample
Auto Trait Implementations§
impl Forget for Sample
impl Freeze for Sample
impl Move for Sample
impl RefUnwindSafe for Sample
impl Send for Sample
impl Sync for Sample
impl Unpin for Sample
impl UnsafeUnpin for Sample
impl UnwindSafe for Sample
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