pub struct TimeSeries<T> { /* private fields */ }Expand description
Connection to a Redis Time Series
This contains a connection to the Redis database that can be used to create, delete, and interact with a single time series.
To be completely readable and writeable, the data type, T must
implement the traits Clone, serde::Serialize and
serde::DeserializeOwned.
Implementations§
Source§impl<T> TimeSeries<T>
impl<T> TimeSeries<T>
Sourcepub fn new(namespace: &str, name: &str) -> Result<Self>
pub fn new(namespace: &str, name: &str) -> Result<Self>
Creates a new connection to the named time series.
Sourcepub fn with_host(host: &str, namespace: &str, name: &str) -> Result<Self>
pub fn with_host(host: &str, namespace: &str, name: &str) -> Result<Self>
Creates a new connection to the named time series on the specified host.
Sourcepub fn with_uri(uri: &str, namespace: &str, name: &str) -> Result<Self>
pub fn with_uri(uri: &str, namespace: &str, name: &str) -> Result<Self>
Creates a new connection to the named time series on the host with the specified URI.
Sourcepub fn purge_before<S>(&mut self, ts: S) -> Result<()>
pub fn purge_before<S>(&mut self, ts: S) -> Result<()>
Deletes all the values in the time series before the specified
time stamp, ts.
Sourcepub fn purge_older_than(&mut self, dur: Duration) -> Result<()>
pub fn purge_older_than(&mut self, dur: Duration) -> Result<()>
Deletes all the values in the time series older than the specified duration.
This deletes all the data except points that fall in the most recent time specified by the duration.
Source§impl<T: Serialize> TimeSeries<T>
impl<T: Serialize> TimeSeries<T>
Sourcepub fn add_now(&mut self, val: T) -> Result<()>
pub fn add_now(&mut self, val: T) -> Result<()>
Adds a point to the time series, using the current time as the timestamp.
Sourcepub fn add_value<V>(&mut self, val: V) -> Result<()>
pub fn add_value<V>(&mut self, val: V) -> Result<()>
Adds a point to the time series as a TimeValue.
Sourcepub fn add_multiple(&mut self, vals: &[TimeValue<T>]) -> Result<()>
pub fn add_multiple(&mut self, vals: &[TimeValue<T>]) -> Result<()>
Adds multiple points to the time series.
Sourcepub fn add_multiple_values(&mut self, vals: &[(Timestamp, T)]) -> Result<()>
pub fn add_multiple_values(&mut self, vals: &[(Timestamp, T)]) -> Result<()>
Adds multiple points to the time series from a slice of tuples.
Source§impl<T: DeserializeOwned> TimeSeries<T>
impl<T: DeserializeOwned> TimeSeries<T>
Sourcepub fn get_range_any<S, U>(
&mut self,
ts1: S,
ts2: U,
) -> Result<Vec<TimeValue<T>>>where
S: ToRedisArgs,
U: ToRedisArgs,
pub fn get_range_any<S, U>(
&mut self,
ts1: S,
ts2: U,
) -> Result<Vec<TimeValue<T>>>where
S: ToRedisArgs,
U: ToRedisArgs,
Gets values from an arbitrary time range. The timestamps can be floating point values, or anything that can be converted to a Redis argument, such as special strings like “-inf”, “+inf”, or “2.0)” to indicate open ranges.
Sourcepub fn get_range<S, U>(&mut self, ts1: S, ts2: U) -> Result<Vec<TimeValue<T>>>
pub fn get_range<S, U>(&mut self, ts1: S, ts2: U) -> Result<Vec<TimeValue<T>>>
Gets values from a time range.
This gets the values from ts1 up to, but not including, ts2.
Sourcepub fn get_from<S>(&mut self, ts: S) -> Result<Vec<TimeValue<T>>>
pub fn get_from<S>(&mut self, ts: S) -> Result<Vec<TimeValue<T>>>
Gets values starting from the specified time up to the latest value.