pub struct TimeQueue<T> { /* private fields */ }Expand description
A struct to manage a sliding window of RR intervals and process heart rate variability (HRV) metrics.
It stores a collection of RR intervals in data and calculates HRV using a custom or default pipeline.
Implementations§
Source§impl<T: Float + Sum<T> + Copy + 'static + Debug + Signed + AddAssign + Send + Sync + SubAssign + Into<f64> + FromPrimitive> TimeQueue<T>
impl<T: Float + Sum<T> + Copy + 'static + Debug + Signed + AddAssign + Send + Sync + SubAssign + Into<f64> + FromPrimitive> TimeQueue<T>
Sourcepub fn new(time: usize) -> Self
pub fn new(time: usize) -> Self
Creates a new TimeQueue with a sliding window of size time. A default pipeline is used.
§Arguments
time- The length of the time window (in ms).
Sourcepub fn set_pipeline(&mut self, pipeline: Box<dyn AnalysisPipeline<T>>)
pub fn set_pipeline(&mut self, pipeline: Box<dyn AnalysisPipeline<T>>)
Sets a custom pipeline to be used for HRV calculation.
§Arguments
pipeline- A boxedAnalysisPipelinethat implements the HRV processing logic.
Sourcepub fn push(&mut self, rr_interval: T)
pub fn push(&mut self, rr_interval: T)
Pushes a new RR interval to the queue. The queue maintains the sliding window of RR intervals. Once the current time exceeds the defined window time, the oldest interval is removed.
Sourcepub fn get_hrv(&self) -> HrvMetrics<T>
pub fn get_hrv(&self) -> HrvMetrics<T>
Processes the current RR intervals using the pipeline and returns the HRV metrics.
This function calls the process method on the custom or default pipeline to calculate HRV.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for TimeQueue<T>
impl<T> !Send for TimeQueue<T>
impl<T> !Sync for TimeQueue<T>
impl<T> !UnwindSafe for TimeQueue<T>
impl<T> Freeze for TimeQueue<T>where
T: Freeze,
impl<T> Unpin for TimeQueue<T>where
T: Unpin,
impl<T> UnsafeUnpin for TimeQueue<T>where
T: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more