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:
Michael Schimmel
2026-03-01 21:24:42 +01:00
parent fc858de59c
commit b74ddcfd61
3 changed files with 38 additions and 24 deletions
+19
View File
@@ -285,6 +285,15 @@ impl Object for RecordSeries {
fn as_any(&self) -> &dyn Any {
self
}
fn as_series(&self) -> Option<&dyn crate::ast::types::Series> {
Some(self)
}
}
impl crate::ast::types::Series for RecordSeries {
fn get_item(&self, index: usize) -> Option<Value> {
self.get_record(index)
}
}
// ============================================================================
@@ -328,6 +337,16 @@ impl Object for SeriesView {
fn as_any(&self) -> &dyn Any {
self
}
fn as_series(&self) -> Option<&dyn crate::ast::types::Series> {
Some(self)
}
}
impl crate::ast::types::Series for SeriesView {
fn get_item(&self, index: usize) -> Option<Value> {
self.inner.borrow().get_value(index)
}
}
// ============================================================================