pub struct Column { /* private fields */ }Expand description
A named value column: numbers, text or true/false values. Handed to
TimeSeries::new, and read back with TimeSeries::column.
let s = TimeSeries::new("hosts", vec![0, 1000], vec![
Column::required("cpu", vec![0.5, 0.7]),
Column::optional("host", vec![Some("a"), None]),
Column::required("up", vec![true, false]),
])?;
assert_eq!(s.column("host")?.kind(), ColumnKind::String);
assert_eq!(s.column("host")?.strings()?.get(0), Some("a"));
assert!(s.column("host")?.numbers().is_err()); // not a number columnImplementations§
Source§impl Column
impl Column
Sourcepub fn required(name: impl Into<String>, values: impl Into<ColumnData>) -> Self
pub fn required(name: impl Into<String>, values: impl Into<ColumnData>) -> Self
A column with no gaps: Vec<f64>, Vec<&str>, Vec<String>,
Vec<bool> (or an array of them, or a built column). A gap (a
non-finite number, or a None) is rejected when the series is built.
Sourcepub fn optional(name: impl Into<String>, values: impl Into<ColumnData>) -> Self
pub fn optional(name: impl Into<String>, values: impl Into<ColumnData>) -> Self
A column that may have gaps: as Column::required, or with
Option values (vec![Some(1.0), None], [Some("a"), None]) where
None is a gap. A non-finite number is a gap too.
Sourcepub fn optional_raw(name: impl Into<String>, values: Vec<f64>) -> Self
pub fn optional_raw(name: impl Into<String>, values: Vec<f64>) -> Self
A number column that may have gaps, given as raw f64 where any
non-finite value (NaN, ±inf) is a gap. The same as
Column::optional with a Vec<f64>.
Sourcepub fn is_required(&self) -> bool
pub fn is_required(&self) -> bool
true when the column may not have gaps.
Sourcepub fn kind(&self) -> ColumnKind
pub fn kind(&self) -> ColumnKind
What the column holds: ColumnKind::Number, Decimal, String,
Boolean or Array.
Sourcepub fn data(&self) -> &ColumnData
pub fn data(&self) -> &ColumnData
The values, whichever kind they are.
Sourcepub fn numbers(&self) -> Result<&Float64Column>
pub fn numbers(&self) -> Result<&Float64Column>
The values of a number column; an error for any other kind.
Sourcepub fn strings(&self) -> Result<&StringColumn>
pub fn strings(&self) -> Result<&StringColumn>
The values of a text column; an error for any other kind.
Sourcepub fn decimals(&self) -> Result<&DecimalColumn>
pub fn decimals(&self) -> Result<&DecimalColumn>
The values of a decimal column; an error for any other kind.
Sourcepub fn booleans(&self) -> Result<&BooleanColumn>
pub fn booleans(&self) -> Result<&BooleanColumn>
The values of a true/false column; an error for any other kind.
Sourcepub fn arrays(&self) -> Result<&ArrayColumn>
pub fn arrays(&self) -> Result<&ArrayColumn>
The values of an array column; an error for any other kind.
Trait Implementations§
impl StructuralPartialEq for Column
Auto Trait Implementations§
impl !RefUnwindSafe for Column
impl !UnwindSafe for Column
impl Freeze for Column
impl Send for Column
impl Sync for Column
impl Unpin for Column
impl UnsafeUnpin for Column
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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> ⓘ
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