I collect time series Data in [timestamp, [...values]]
How would I tell the rust compiler about its type?
struct TimeSeries {
id: String,
name: String,
aggregation: Aggregation, // some enum
length: u32,
series: Vec[Array[unix_time, Vec[float]]], // help with this
}
kornel
December 12, 2022, 5:35pm
2
Rust's arrays are for things that have strictly fixed length known at compile time, and all elements of the same type, so probably not applicable here at all.
You could use Vec<SeriesItem>
and
struct SeriesItem { unix_time: u64 /* or SystemTime */, data: Vec<f32> }
If you're looking for a type with anonymous fields, then use tuples (u64, Vec<f32>)
.
2 Likes