Introduce unified Series trait
This commit introduces the `Series` trait to provide a unified interface for accessing indexed data across different series types (RecordSeries, SeriesView, and future SharedSeries). This simplifies the VM's indexer logic and lays the groundwork for the dual series architecture.
This commit is contained in:
@@ -180,6 +180,18 @@ impl RecordLayout {
|
||||
pub trait Object: fmt::Debug {
|
||||
fn type_name(&self) -> &'static str;
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
|
||||
/// Optional optimization: If this object behaves like a time series (indexable lookbacks),
|
||||
/// it can return a reference to its Series trait implementation.
|
||||
fn as_series(&self) -> Option<&dyn Series> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Unified interface for all series types (Local RecordSeries, SeriesViews, and future SharedSeries).
|
||||
pub trait Series {
|
||||
/// Gets the value at the specified lookback index (0 = newest).
|
||||
fn get_item(&self, index: usize) -> Option<Value>;
|
||||
}
|
||||
|
||||
/// A shared sequence of values, used by both Tuples and Records.
|
||||
|
||||
Reference in New Issue
Block a user