Skip to main content

EmitterState

Struct EmitterState 

Source
pub struct EmitterState {
    pub context: Context,
    pub last_seen: u64,
    pub message_count: u64,
    pub recent_values: Vec<f64>,
    pub is_anomalous: bool,
    /* private fields */
}
Expand description

State for a single emitter

Fields§

§context: Context

Emitter’s context

§last_seen: u64

Last seen timestamp

§message_count: u64

Message count from this emitter

§recent_values: Vec<f64>

Recent values (for cross-fleet comparison)

§is_anomalous: bool

Is this emitter behaving anomalously?

Implementations§

Source§

impl EmitterState

Source

pub fn new() -> Self

Create a new emitter state

Source

pub fn with_capacity(max_recent: usize) -> Self

Create with custom recent values capacity

Source

pub fn record_value(&mut self, value: f64, timestamp: u64)

Record a new value

Source

pub fn mean(&self) -> Option<f64>

Calculate mean of recent values

Source

pub fn std_dev(&self) -> Option<f64>

Calculate standard deviation of recent values

Source

pub fn last_value(&self) -> Option<f64>

Get the last recorded value

Trait Implementations§

Source§

impl Debug for EmitterState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EmitterState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.