TimeSeries

Struct TimeSeries 

Source
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>

Source

pub fn new(namespace: &str, name: &str) -> Result<Self>

Creates a new connection to the named time series.

Source

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.

Source

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.

Source

pub fn purge_before<S>(&mut self, ts: S) -> Result<()>
where S: Into<Timestamp>,

Deletes all the values in the time series before the specified time stamp, ts.

Source

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

pub fn delete(&mut self) -> Result<()>

Removes the entire timeseries from the Redis DB.

Source§

impl<T: Serialize> TimeSeries<T>

Source

pub fn add<S>(&mut self, ts: S, val: T) -> Result<()>
where S: Into<Timestamp>,

Adds a point to the time series.

Source

pub fn add_now(&mut self, val: T) -> Result<()>

Adds a point to the time series, using the current time as the timestamp.

Source

pub fn add_value<V>(&mut self, val: V) -> Result<()>
where V: Into<TimeValue<T>>,

Adds a point to the time series as a TimeValue.

Source

pub fn add_multiple(&mut self, vals: &[TimeValue<T>]) -> Result<()>

Adds multiple points to the time series.

Source

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>

Source

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.

Source

pub fn get_range<S, U>(&mut self, ts1: S, ts2: U) -> Result<Vec<TimeValue<T>>>
where S: Into<Timestamp>, U: Into<Timestamp>,

Gets values from a time range. This gets the values from ts1 up to, but not including, ts2.

Source

pub fn get_from<S>(&mut self, ts: S) -> Result<Vec<TimeValue<T>>>
where S: Into<Timestamp>,

Gets values starting from the specified time up to the latest value.

Source

pub fn get_last(&mut self, dur: Duration) -> Result<Vec<TimeValue<T>>>

Gets the most recent points for the specified duration.

Source

pub fn get_all(&mut self) -> Result<Vec<TimeValue<T>>>

Gets all the values in the series. This should be used with caution if the series is large.

Auto Trait Implementations§

§

impl<T> Freeze for TimeSeries<T>

§

impl<T> !RefUnwindSafe for TimeSeries<T>

§

impl<T> Send for TimeSeries<T>
where T: Send,

§

impl<T> Sync for TimeSeries<T>
where T: Sync,

§

impl<T> Unpin for TimeSeries<T>
where T: Unpin,

§

impl<T> !UnwindSafe for TimeSeries<T>

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.