Skip to main content

AlertEvent

Struct AlertEvent 

Source
pub struct AlertEvent {
    pub alert: IndicatorAlert,
    pub timestamp: i64,
    pub phase: EventPhase,
    pub event_id: String,
    /* private fields */
}
Expand description

An IndicatorAlert enriched with timestamp, instrument, timeframe, a stable event ID, and an explicit lifecycle phase, suitable for deduplication and cross-bar tracking.

instrument and timeframe are private (with AlertEvent::instrument/ AlertEvent::timeframe accessors) so that AlertEvent::with_instrument/ AlertEvent::with_timeframe are the only way to change them, guaranteeing event_id is always recomputed from the complete, current identity context and can never go stale relative to it — regardless of the order those builders are called in.

Fields§

§alert: IndicatorAlert§timestamp: i64§phase: EventPhase§event_id: String

Implementations§

Source§

impl AlertEvent

Source

pub fn new(alert: IndicatorAlert, timestamp: i64, phase: EventPhase) -> Self

Builds an event with a deterministic ID derived from the alert kind, phase, and timestamp (instrument/timeframe default to absent; attach them via AlertEvent::with_instrument/ AlertEvent::with_timeframe), so re-emitting the same logical event on the same bar always yields the same ID.

Source

pub fn instrument(&self) -> Option<&str>

Source

pub fn timeframe(&self) -> Option<Timeframe>

Source

pub fn with_instrument(self, instrument: impl Into<String>) -> Self

Attaches an instrument and recomputes event_id from the complete identity context, so two events that only differ by instrument never collide.

Source

pub fn with_timeframe(self, timeframe: Timeframe) -> Self

Attaches a timeframe and recomputes event_id from the complete identity context, so two events that only differ by timeframe never collide.

Trait Implementations§

Source§

impl Clone for AlertEvent

Source§

fn clone(&self) -> AlertEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AlertEvent

Source§

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

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

impl<'de> Deserialize<'de> for AlertEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for AlertEvent

Source§

fn eq(&self, other: &AlertEvent) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for AlertEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AlertEvent

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.